summaryrefslogtreecommitdiff
path: root/src-migrate/common
diff options
context:
space:
mode:
Diffstat (limited to 'src-migrate/common')
-rw-r--r--src-migrate/common/components/elements/Modal.tsx18
-rw-r--r--src-migrate/common/components/elements/ReCaptcha.tsx17
-rw-r--r--src-migrate/common/stores/useRegisterStore.ts5
-rw-r--r--src-migrate/common/types/auth.ts31
4 files changed, 59 insertions, 12 deletions
diff --git a/src-migrate/common/components/elements/Modal.tsx b/src-migrate/common/components/elements/Modal.tsx
index ad1fe51b..91421251 100644
--- a/src-migrate/common/components/elements/Modal.tsx
+++ b/src-migrate/common/components/elements/Modal.tsx
@@ -11,7 +11,8 @@ type Props = {
active: boolean
title?: string
close?: () => void,
- className?: string
+ className?: string,
+ mode?: "mobile" | "desktop"
}
const Modal = ({
@@ -19,11 +20,14 @@ const Modal = ({
active = false,
title,
close,
- className
+ className,
+ mode
}: Props) => {
const { width } = useWindowSize()
const [rendered, setRendered] = useState<boolean>(false)
+ mode = mode || width >= 768 ? "desktop" : "mobile"
+
useEffect(() => {
setRendered(true)
}, [])
@@ -31,16 +35,16 @@ const Modal = ({
const modalClassNames = clsxm(
"fixed bg-white max-h-[80vh] overflow-auto p-4 pt-0 z-[60] border-gray_r-6",
{
- "left-1/2 -translate-x-1/2 translate-y-1/2 bottom-1/2 md:w-1/4 lg:w-1/3 border rounded-xl": width >= 768,
- "left-0 w-full border-t bottom-0 rounded-t-xl": width < 768
+ "left-1/2 -translate-x-1/2 translate-y-1/2 bottom-1/2 w-11/12 md:w-1/4 lg:w-1/3 border rounded-xl": mode === 'desktop',
+ "left-0 w-full border-t bottom-0 rounded-t-xl": mode === 'mobile'
},
className
)
const variant = {
- initial: { bottom: width >= 768 ? '45%' : '-100%', opacity: 0 },
- animate: { bottom: width >= 768 ? '50%' : 0, opacity: 1 },
- exit: { bottom: width >= 768 ? '55%' : '-100%', opacity: 0 },
+ initial: { bottom: mode === 'desktop' ? '45%' : '-100%', opacity: 0 },
+ animate: { bottom: mode === 'desktop' ? '50%' : 0, opacity: 1 },
+ exit: { bottom: mode === 'desktop' ? '55%' : '-100%', opacity: 0 },
transition: { ease: 'linear', duration: 0.25 }
}
diff --git a/src-migrate/common/components/elements/ReCaptcha.tsx b/src-migrate/common/components/elements/ReCaptcha.tsx
new file mode 100644
index 00000000..1bc31d90
--- /dev/null
+++ b/src-migrate/common/components/elements/ReCaptcha.tsx
@@ -0,0 +1,17 @@
+import ReCAPTCHA, { ReCAPTCHAProps } from "react-google-recaptcha"
+
+const GOOGLE_RECAPTCHA_KEY = process.env.NEXT_PUBLIC_RECAPTCHA_GOOGLE || ''
+
+type Props = Omit<ReCAPTCHAProps, 'sitekey'> & {
+ sitekey?: string;
+}
+
+const ReCaptcha = (props: Props) => {
+ const { sitekey, ...rest } = props
+
+ return (
+ <ReCAPTCHA sitekey={sitekey || GOOGLE_RECAPTCHA_KEY} {...rest} />
+ )
+}
+
+export default ReCaptcha \ No newline at end of file
diff --git a/src-migrate/common/stores/useRegisterStore.ts b/src-migrate/common/stores/useRegisterStore.ts
index fcd2cd8b..725bbfda 100644
--- a/src-migrate/common/stores/useRegisterStore.ts
+++ b/src-migrate/common/stores/useRegisterStore.ts
@@ -6,10 +6,12 @@ type State = {
isValid: boolean;
isCheckedTNC: boolean;
isOpenTNC: boolean;
+ isValidCaptcha: boolean;
};
type Action = {
updateForm: (name: string, value: string) => void;
+ updateValidCaptcha: (value: boolean) => void;
toggleCheckTNC: () => void;
openTNC: () => void;
closeTNC: () => void;
@@ -21,10 +23,12 @@ export const useRegisterStore = create<State & Action>((set) => ({
name: '',
email: '',
password: '',
+ phone: '',
},
isValid: false,
isCheckedTNC: false,
isOpenTNC: false,
+ isValidCaptcha: false,
updateForm: (name, value) =>
set((state) => {
const updatedForm = { ...state.form, [name]: value };
@@ -49,4 +53,5 @@ export const useRegisterStore = create<State & Action>((set) => ({
toggleCheckTNC: () => set((state) => ({ isCheckedTNC: !state.isCheckedTNC })),
openTNC: () => set(() => ({ isOpenTNC: true })),
closeTNC: () => set(() => ({ isOpenTNC: false })),
+ updateValidCaptcha: (value) => set(() => ({ isValidCaptcha: value })),
}));
diff --git a/src-migrate/common/types/auth.ts b/src-migrate/common/types/auth.ts
index 63fac6e0..3d9ffee4 100644
--- a/src-migrate/common/types/auth.ts
+++ b/src-migrate/common/types/auth.ts
@@ -22,11 +22,32 @@ export type RegisterProps = {
email: string;
password: string;
company: string;
+ phone: string;
+};
+
+export type RegisterResApiProps = {
+ register: boolean;
+ reason: 'EMAIL_USED' | null;
+};
+
+type ActivationResProps = {
+ activation: boolean;
+ user: AuthProps | null;
+};
+
+export type ActivationTokenProps = {
+ token: string;
+};
+
+export type ActivationTokenResApiProps = ActivationResProps & {
+ reason: 'INVALID_TOKEN' | null;
+};
+
+export type ActivationOtpProps = {
+ email: string;
+ otp: string;
};
-export type RegisterApiProps = OdooApiProps & {
- result: {
- register: boolean;
- reason?: 'EMAIL_USED';
- };
+export type ActivationOtpResApiProps = ActivationResProps & {
+ reason: 'INVALID_OTP' | null;
};