B2B-29: Create register-company form
This commit is contained in:
88
app/(public)/register-company/page.tsx
Normal file
88
app/(public)/register-company/page.tsx
Normal file
@@ -0,0 +1,88 @@
|
||||
"use client";
|
||||
|
||||
import { MedReportTitle } from "@/components/MedReportTitle";
|
||||
import React from "react";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import Image from "next/image";
|
||||
import medReportBigLogo from "@/assets/medReportBigLogo.png";
|
||||
import { SubmitButton } from "@/components/submit-button";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { companySchema } from "@/lib/validations/companySchema";
|
||||
import { CompanySubmitData } from "@/lib/types/company";
|
||||
import { submitCompanyRegistration } from "@/lib/services/register-company.service";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
export default function RegisterCompany() {
|
||||
const router = useRouter();
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { errors, isValid, isSubmitting },
|
||||
} = useForm({
|
||||
resolver: yupResolver(companySchema),
|
||||
mode: "onChange",
|
||||
});
|
||||
|
||||
async function onSubmit(data: CompanySubmitData) {
|
||||
const formData = new FormData();
|
||||
Object.entries(data).forEach(([key, value]) => {
|
||||
if (value !== undefined) formData.append(key, value);
|
||||
});
|
||||
|
||||
try {
|
||||
await submitCompanyRegistration(formData);
|
||||
router.push("/register-company/success");
|
||||
} catch (err: any) {
|
||||
alert("Server validation error: " + err.message);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-row border rounded-3xl border-border">
|
||||
<div className="flex flex-col text-center py-14 px-12 w-1/2">
|
||||
<MedReportTitle />
|
||||
<h1 className="pt-8">Ettevõtte andmed</h1>
|
||||
<p className="pt-2">
|
||||
Pakkumise saamiseks palun sisesta ettevõtte andmed millega MedReport
|
||||
kasutada kavatsed.
|
||||
</p>
|
||||
<form
|
||||
onSubmit={handleSubmit(onSubmit)}
|
||||
noValidate
|
||||
className="flex gap-4 flex-col text-left pt-8 px-6"
|
||||
>
|
||||
<div>
|
||||
<Label>Ettevõtte nimi</Label>
|
||||
<Input {...register("companyName")} />
|
||||
</div>
|
||||
<div>
|
||||
<Label>Kontaktisik</Label>
|
||||
<Input {...register("contactPerson")} />
|
||||
</div>
|
||||
<div>
|
||||
<Label>E-mail</Label>
|
||||
<Input type="email" {...register("email")}></Input>
|
||||
</div>
|
||||
<div>
|
||||
<Label>Telefon</Label>
|
||||
<Input type="tel" {...register("phone")} />
|
||||
</div>
|
||||
<SubmitButton
|
||||
disabled={!isValid || isSubmitting}
|
||||
pendingText="Saatmine..."
|
||||
type="submit"
|
||||
formAction={submitCompanyRegistration}
|
||||
className="mt-4 hover:bg-primary/90"
|
||||
>
|
||||
Küsi pakkumist
|
||||
</SubmitButton>
|
||||
</form>
|
||||
</div>
|
||||
<div className="w-1/2">
|
||||
<Image src={medReportBigLogo} alt="MedReport" priority />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
21
app/(public)/register-company/success/page.tsx
Normal file
21
app/(public)/register-company/success/page.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import { MedReportTitle } from "@/components/MedReportTitle";
|
||||
import Image from "next/image";
|
||||
import sucess from "@/assets/success.png";
|
||||
import Link from "next/link";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
export default function CompanyRegistrationSuccess() {
|
||||
return (
|
||||
<div className="pt-2 px-16 pb-12 border rounded-3xl border-border">
|
||||
<MedReportTitle />
|
||||
<div className="flex flex-col items-center px-4">
|
||||
<Image src={sucess} alt="Success" className="pt-6 pb-8" />
|
||||
<h1 className="pb-2">Päring edukalt saadetud!</h1>
|
||||
<p>Saadame teile esimesel võimalusel vastuse</p>
|
||||
</div>
|
||||
<Button className="w-full mt-8">
|
||||
<Link href="/">Tagasi kodulehele</Link>
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
22
app/(public)/sign-in/page.tsx
Normal file
22
app/(public)/sign-in/page.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Button } from "@/components/ui/button";
|
||||
import Link from "next/link";
|
||||
import React from "react";
|
||||
|
||||
export default async function SignIn() {
|
||||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
<Button variant="outline">
|
||||
<Link href="/">Smart-ID</Link>
|
||||
</Button>
|
||||
<Button variant="outline">
|
||||
<Link href="/">Mobiil-ID</Link>
|
||||
</Button>
|
||||
<Button variant="outline">
|
||||
<Link href="/">ID-Kaart</Link>
|
||||
</Button>
|
||||
<Button variant="outline">
|
||||
<Link href="/register-company">Loo ettevõtte konto</Link>
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user