(
props: ButtonProps & {
tenant: ServerPublic | undefined;
dashboard?: boolean;
},
)
| 5 | import { LinkButton } from '../ui/link-button'; |
| 6 | |
| 7 | export function SignInButton( |
| 8 | props: ButtonProps & { |
| 9 | tenant: ServerPublic | undefined; |
| 10 | dashboard?: boolean; |
| 11 | }, |
| 12 | ) { |
| 13 | const { tenant } = props; |
| 14 | if (tenant) { |
| 15 | const link = makeMainSiteLink('/api/auth/tenant/signin'); |
| 16 | const redirect = |
| 17 | typeof window !== 'undefined' |
| 18 | ? window.location.href |
| 19 | : `http://${tenant.customDomain!}`; |
| 20 | |
| 21 | return ( |
| 22 | <LinkButton |
| 23 | variant="outline" |
| 24 | href={`${link}?redirect=${encodeURIComponent(redirect)}`} |
| 25 | > |
| 26 | Login |
| 27 | </LinkButton> |
| 28 | ); |
| 29 | } |
| 30 | if (props.dashboard) { |
| 31 | return ( |
| 32 | <LinkButton |
| 33 | variant="outline" |
| 34 | href={ |
| 35 | // eslint-disable-next-line n/no-process-env |
| 36 | (process.env.NEXT_PUBLIC_DEPLOYMENT_ENV === 'local' |
| 37 | ? 'http://localhost:3000/' |
| 38 | : 'https://www.answeroverflow.com/') + `app-auth` |
| 39 | } |
| 40 | > |
| 41 | Sign In |
| 42 | </LinkButton> |
| 43 | ); |
| 44 | } |
| 45 | return ( |
| 46 | // TODO: Swap to href |
| 47 | // eslint-disable-next-line @typescript-eslint/no-misused-promises |
| 48 | <Button |
| 49 | variant="outline" |
| 50 | onClick={() => { |
| 51 | void import('next-auth/react').then(({ signIn }) => { |
| 52 | void signIn('discord'); |
| 53 | }); |
| 54 | }} |
| 55 | {...props} |
| 56 | > |
| 57 | Login |
| 58 | </Button> |
| 59 | ); |
| 60 | } |
nothing calls this directly
no test coverage detected