diff --git a/src/front/Components/Layouts/Login/StepEmail/index.tsx b/src/front/Components/Layouts/Login/StepEmail/index.tsx index 17b108dd..d87a8cc1 100644 --- a/src/front/Components/Layouts/Login/StepEmail/index.tsx +++ b/src/front/Components/Layouts/Login/StepEmail/index.tsx @@ -4,7 +4,7 @@ import Typography, { ETypo, ETypoColor } from "@Front/Components/DesignSystem/Ty //import Image from "next/image"; import Form from "@Front/Components/DesignSystem/Form"; import TextField from "@Front/Components/DesignSystem/Form/TextField"; -import Button from "@Front/Components/DesignSystem/Button"; +import Button, { EButtonVariant, EButtonstyletype } from "@Front/Components/DesignSystem/Button"; //import franceConnectLogo from "../france-connect.svg"; // import { useRouter } from "next/router"; // import Customers from "@Front/Api/Auth/Id360/Customers/Customers"; @@ -20,10 +20,11 @@ import Confirm from "@Front/Components/DesignSystem/OldModal/Confirm"; type IProps = { onSubmit: (e: React.FormEvent | null, values: { [key: string]: string }) => void; validationErrors: ValidationError[]; + onImportProfile?: () => void; }; export default function StepEmail(props: IProps) { - const { onSubmit, validationErrors } = props; + const { onSubmit, validationErrors, onImportProfile } = props; const [isErrorModalOpen, setIsErrorModalOpen] = useState(0); /* const router = useRouter(); @@ -111,6 +112,20 @@ export default function StepEmail(props: IProps) { + {onImportProfile && ( +
+ + Options avancées : + + +
+ )} (""); const [validationErrors, setValidationErrors] = useState([]); const [isAuthModalOpen, setIsAuthModalOpen] = useState(false); + const [isLoading, setIsLoading] = useState(false); // const openErrorModal = useCallback(() => { // setIsErrorModalOpen(true); @@ -241,10 +244,55 @@ export default function Login() { } }, [email, totpCodeUid]); + const onImportProfileSubmit = useCallback(async (profileData: any) => { + try { + setIsLoading(true); + setValidationErrors([]); + + // Call API to validate and import profile + // Note: You'll need to implement this method in your Auth service + // const response = await Auth.getInstance().importProfile(profileData); + + // For now, we'll simulate a successful import + // In a real implementation, you would: + // 1. Send the profile data to your backend + // 2. Validate the profile on the server + // 3. Return authentication tokens + // 4. Connect the user + + // Simulate API call + await new Promise(resolve => setTimeout(resolve, 1000)); + + // For demo purposes, we'll just redirect to the dashboard + // In reality, you'd use the response from the API + // CustomerStore.instance.connect(response.accessToken, response.refreshToken); + + // Redirect to dashboard + router.push(Module.getInstance().get().modules.pages.Folder.pages.Select.props.path); + } catch (error: any) { + setValidationErrors([ + { + property: "import", + constraints: { + [error.http_status || "500"]: error.message || "Erreur lors de l'import du profil", + }, + }, + ]); + } finally { + setIsLoading(false); + } + }, [router]); + return (
- {step === LoginStep.EMAIL && } + {step === LoginStep.EMAIL && ( + setStep(LoginStep.IMPORT_PROFILE)} + /> + )} {step === LoginStep.TOTP && ( } + {step === LoginStep.IMPORT_PROFILE && ( + setStep(LoginStep.EMAIL)} + validationErrors={validationErrors} + /> + )}
{/*