Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

refactor: SignIn to hooks (#1002)

Benjamin Levesque1e1b49900743
diff --git a/public/pages/SignIn/SignIn.page.tsx b/public/pages/SignIn/SignIn.page.tsx
index 0068c052b..c34d0da45 100644
--- a/public/pages/SignIn/SignIn.page.tsx
+++ b/public/pages/SignIn/SignIn.page.tsx
@@ -1,32 +1,41 @@
import React from "react"
import { SignInControl, TenantLogo, LegalNotice } from "@fider/components"
-import { notify, Fider } from "@fider/services"
+import { notify } from "@fider/services"
import { Trans } from "@lingui/macro"
+import { useFider } from "@fider/hooks"
-const Locked = (): JSX.Element => (
- <>
- <p className="text-title">
- <Trans id="signin.message.locked.title">
- <strong>{Fider.session.tenant.name}</strong> is currently locked.
- </Trans>
- </p>
- <Trans id="signin.message.locked.text">To reactivate this site, sign in with an administrator account and update the required settings.</Trans>
- </>
-)
+const Locked = (): JSX.Element => {
+ const fider = useFider()
+ return (
+ <>
+ <p className="text-title">
+ <Trans id="signin.message.locked.title">
+ <strong>{fider.session.tenant.name}</strong> is currently locked.
+ </Trans>
+ </p>
+ <Trans id="signin.message.locked.text">To reactivate this site, sign in with an administrator account and update the required settings.</Trans>
+ </>
+ )
+}
+
+const Private = (): JSX.Element => {
+ const fider = useFider()
+ return (
+ <>
+ <p className="text-title">
+ <Trans id="signin.message.private.title">
+ <strong>{fider.session.tenant.name}</strong> is a private space and requires an invitation to join it.
+ </Trans>
+ </p>
+ <Trans id="signin.message.private.text">If you have an account or an invitation, you may use following options to sign in.</Trans>
+ </>
+ )
+}
-const Private = (): JSX.Element => (
- <>
- <p className="text-title">
- <Trans id="signin.message.private.title">
- <strong>{Fider.session.tenant.name}</strong> is a private space and requires an invitation to join it.
- </Trans>
- </p>
- <Trans id="signin.message.private.text">If you have an account or an invitation, you may use following options to sign in.</Trans>
- </>
-)
+export const SignInPage = () => {
+ const fider = useFider()
-export default class SignInPage extends React.Component<any, any> {
- private onEmailSent = (email: string) => {
+ const onEmailSent = (email: string) => {
notify.success(
<span>
<Trans id="signin.message.emailsent">
@@ -36,17 +45,17 @@ export default class SignInPage extends React.Component<any, any> {
)
}
- public render() {
- return (
- <div id="p-signin" className="page container w-max-6xl">
- <div className="h-20 text-center mb-4">
- <TenantLogo size={100} />
- </div>
- <div className="text-center w-max-4xl mx-auto mb-4">{Fider.session.tenant.isPrivate ? <Private /> : <Locked />}</div>
-
- <SignInControl onEmailSent={this.onEmailSent} useEmail={true} redirectTo={Fider.settings.baseURL} />
- <LegalNotice />
+ return (
+ <div id="p-signin" className="page container w-max-6xl">
+ <div className="h-20 text-center mb-4">
+ <TenantLogo size={100} />
</div>
- )
- }
+ <div className="text-center w-max-4xl mx-auto mb-4">{fider.session.tenant.isPrivate ? <Private /> : <Locked />}</div>
+
+ <SignInControl onEmailSent={onEmailSent} useEmail={true} redirectTo={fider.settings.baseURL} />
+ <LegalNotice />
+ </div>
+ )
}
+
+export default SignInPage