Skip to content

Commit

Permalink
parse error message
Browse files Browse the repository at this point in the history
  • Loading branch information
ceddybi committed Jan 31, 2024
1 parent 29c1859 commit c930a51
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/app/auth/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ import _get from "lodash/get";
import { isEmpty } from "lodash";
// import logo from "../../assets/icon.png";

const parseMesaage = (message: string) => {
if (message.includes("credit")) {
return "You don't have enough credits, please add more credits to continue";
}
if (message.includes("auth")) {
return "Please login to continue";
}
return "Something went wrong, please try again later";
};

export const AuthPage = ({ state }: LayoutPageProps) => {
const authMessage = _get(state, "auth.res.message", "");

Expand All @@ -20,12 +30,13 @@ export const AuthPage = ({ state }: LayoutPageProps) => {
src={"static://assets/icon.png"}
style={{ width: "100px", padding: "5px", marginBottom: "20px" }}
/>

{!isEmpty(authMessage) && (
<div className="flex justify-center">
<div className="text-2xl font-bold">{authMessage}</div>
<div className="text-2xl font-bold">{parseMesaage(authMessage)}</div>
</div>
)}

<div className="flex justify-center mt-2">
<button
onClick={openAuthLink}
Expand Down

0 comments on commit c930a51

Please sign in to comment.