"use client"; import { Progress } from "@/components/ui/progress"; import { ArrowLeft, ArrowRight } from "lucide-react"; import React, { useState } from "react"; import { Button } from "@/components/ui/button"; import UserType from "./UserType"; import GeneralUserForm from "../Settings/UserForm"; import DoctorForm from "../Settings/DoctorForm"; import { useRouter } from "next/navigation"; import { Label } from "@/components/ui/label"; import { Input } from "@/components/ui/input"; import { checkDoctorAction } from "@/app/actions"; import { useToast } from "@/components/ui/use-toast"; type TUserType = "doctor" | "user" | "business"; const Steps: React.FC<{ selectedUser: IUser; }> = ({ selectedUser }) => { const router = useRouter(); const { toast } = useToast(); const [progress, setProgress] = React.useState(40); const [step, setStep] = React.useState(0); const [selectedType, setSelectedType] = useState(null); const [doctorAuthCode, setDoctorAuthCode] = useState(""); const onSelectType = (type: TUserType) => { setSelectedType(type); setStep(1); setProgress(progress + 30); }; const onClickBack = () => { setStep(step - 1); setProgress(progress - 30); }; const onClickFormCallback = async () => { if (selectedType === "doctor") { const res = await checkDoctorAction(doctorAuthCode); if (!res) { toast({ description: "Your sign-up code did not match our records. Try again or reach out to us for help.", }); return; } } setStep(step + 1); setProgress(progress + 30); router.push("/home"); }; const CurrentForm = () => { if (step === 0) { return ( ); } else { if (selectedType === "doctor") { return ( } onClickCallback={onClickFormCallback} /> ); } else { return ( } onClickCallback={onClickFormCallback} /> ); } } }; const Navigation = () => { return (
{step > 0 && ( )} {step > 0 && ( )}
{selectedType === "doctor" && (
setDoctorAuthCode(e.target.value)} placeholder="Sign-up code" className="max-w-screen-sm h-10 bg-white" autoComplete="on" style={{ fontSize: 16, }} />
)}
); }; let heading = "Let's get your Elato device & account set up"; let subHeading = "We want to make sure that your Elato is set up to provide you the best experience possible."; if (step === 1) { if (selectedType === "doctor") { heading = "Hello Doctor!"; subHeading = "With the following details we will be able to personalize your and your patients' Elato experience."; } else { heading = "Hello there!"; subHeading = "With the following details we will be able to personalize your Elato experience."; } } return (

{heading}

{subHeading}

); }; export default Steps;