diff --git a/frontend/components/Notice.tsx b/frontend/components/Notice.tsx new file mode 100644 index 0000000..53b0d74 --- /dev/null +++ b/frontend/components/Notice.tsx @@ -0,0 +1,56 @@ +import { ReactNode } from "react"; +import { ButtonStyle } from "./Button"; + +export type NoticeStyle = ButtonStyle; + +export interface Props { + header?: string; + style?: NoticeStyle; + children?: ReactNode; +} + +export default function Notice(props: Props) { + if (props.style === undefined) { + return PrimaryNotice(props); + } + + switch (props.style) { + case ButtonStyle.primary: + return PrimaryNotice(props); + case ButtonStyle.success: + return SuccessNotice(props); + case ButtonStyle.danger: + return DangerNotice(props); + } +} + +function PrimaryNotice(props: Props) { + return ( +
+ {props.children} +
+ ); +} + +function SuccessNotice(props: Props) { + return ( +
+ {props.children} +
+ ); +} + +function DangerNotice(props: Props) { + return ( +
+ {props.header && ( +

+ {props.header} +

+ )} +
+ {props.children} +
+
+ ); +} diff --git a/frontend/pages/login/discord.tsx b/frontend/pages/login/discord.tsx index 3974eff..63edfc3 100644 --- a/frontend/pages/login/discord.tsx +++ b/frontend/pages/login/discord.tsx @@ -8,6 +8,7 @@ import TextInput from "../../components/TextInput"; import Loading from "../../components/Loading"; import { stat } from "fs"; import Button, { ButtonStyle } from "../../components/Button"; +import Notice from "../../components/Notice"; interface CallbackResponse { has_account: boolean; @@ -97,12 +98,12 @@ export default function Discord() { if (!state.ticket && !state.error) { return ; - } else if (state.error) { + } else if (!state.ticket && state.error) { return ( -
-

Error: {state.error.message ?? state.error}

+ +

{state.error.message ?? state.error}

Try again?

-
+ ); } @@ -137,10 +138,10 @@ export default function Discord() {

{state.error && ( -
-

Error: {state.error.message ?? state.error}

+ +

{state.error.message ?? state.error}

Try again?

-
+ )}