feat: Implement company offer submission page and success notification
- Added CompanyOffer component for submitting company offers with validation. - Integrated email sending functionality upon form submission. - Created a success page for company registration confirmation. - Introduced a reusable SuccessNotification component for displaying success messages. - Updated account update functionality with new fields and validation. - Enhanced user experience with back button and logo components. - Added necessary database migrations for account updates.
This commit is contained in:
@@ -4,12 +4,11 @@ import React from 'react';
|
||||
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
import { MedReportLogo } from '@/components/med-report-title';
|
||||
import { MedReportLogo } from '@/components/med-report-logo';
|
||||
import { SubmitButton } from '@/components/ui/submit-button';
|
||||
import { sendCompanyOfferEmail } from '@/lib/services/mailer.service';
|
||||
import { submitCompanyRegistration } from '@/lib/services/register-company.service';
|
||||
import { CompanySubmitData } from '@/lib/types/company';
|
||||
import { companySchema } from '@/lib/validations/companySchema';
|
||||
import { companyOfferSchema } from '@/lib/validations/company-offer.schema';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@@ -19,36 +18,35 @@ import { Input } from '@kit/ui/input';
|
||||
import { Label } from '@kit/ui/label';
|
||||
import { Trans } from '@kit/ui/trans';
|
||||
|
||||
export default function RegisterCompany() {
|
||||
export default function CompanyOffer() {
|
||||
const router = useRouter();
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { errors, isValid, isSubmitting },
|
||||
formState: { isValid, isSubmitting },
|
||||
} = useForm({
|
||||
resolver: zodResolver(companySchema),
|
||||
resolver: zodResolver(companyOfferSchema),
|
||||
mode: 'onChange',
|
||||
});
|
||||
const language = useTranslation().i18n.language;
|
||||
|
||||
async function onSubmit(data: CompanySubmitData) {
|
||||
const onSubmit = async (data: CompanySubmitData) => {
|
||||
const formData = new FormData();
|
||||
Object.entries(data).forEach(([key, value]) => {
|
||||
if (value !== undefined) formData.append(key, value);
|
||||
});
|
||||
|
||||
try {
|
||||
await submitCompanyRegistration(formData);
|
||||
sendCompanyOfferEmail(data, language)
|
||||
.then(() => router.push('/register-company/success'))
|
||||
.then(() => router.push('/company-offer/success'))
|
||||
.catch((error) => alert('error: ' + error));
|
||||
} catch (err: unknown) {
|
||||
if (err instanceof Error) {
|
||||
alert('Server validation error: ' + err.message);
|
||||
console.warn('Server validation error: ' + err.message);
|
||||
}
|
||||
alert('Server validation error');
|
||||
console.warn('Server validation error: ', err);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="border-border flex max-w-5xl flex-row overflow-hidden rounded-3xl border">
|
||||
16
app/(public)/company-offer/success/page.tsx
Normal file
16
app/(public)/company-offer/success/page.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
'use client';
|
||||
|
||||
import { SuccessNotification } from '@/packages/features/notifications/src/components';
|
||||
|
||||
export default function CompanyRegistrationSuccess() {
|
||||
return (
|
||||
<SuccessNotification
|
||||
titleKey="account:requestCompanyAccount:successTitle"
|
||||
descriptionKey="account:requestCompanyAccount:successDescription"
|
||||
buttonProps={{
|
||||
buttonTitleKey: 'account:requestCompanyAccount:successButton',
|
||||
href: '/',
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import Image from 'next/image';
|
||||
import Link from 'next/link';
|
||||
|
||||
import { MedReportLogo } from '@/components/med-report-title';
|
||||
|
||||
import { Button } from '@kit/ui/button';
|
||||
import { Trans } from '@kit/ui/trans';
|
||||
|
||||
export default function CompanyRegistrationSuccess() {
|
||||
return (
|
||||
<div className="border-border rounded-3xl border px-16 pt-4 pb-12">
|
||||
<MedReportLogo />
|
||||
<div className="flex flex-col items-center px-4">
|
||||
<Image
|
||||
src="/assets/success.png"
|
||||
alt="Success"
|
||||
className="pt-6 pb-8"
|
||||
width={326}
|
||||
height={195}
|
||||
/>
|
||||
<h1 className="pb-2">
|
||||
<Trans i18nKey="account:requestCompanyAccount:successTitle" />
|
||||
</h1>
|
||||
<p className="text-muted-foreground text-sm">
|
||||
<Trans i18nKey="account:requestCompanyAccount:successDescription" />
|
||||
</p>
|
||||
</div>
|
||||
<Button className="mt-8 w-full">
|
||||
<Link href="/">
|
||||
<Trans i18nKey="account:requestCompanyAccount:successButton" />
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
import React from 'react';
|
||||
|
||||
import Link from 'next/link';
|
||||
|
||||
import { Button } from '@kit/ui/button';
|
||||
import Link from "next/link";
|
||||
import React from "react";
|
||||
|
||||
export default async function SignIn() {
|
||||
return (
|
||||
@@ -15,7 +17,7 @@ export default async function SignIn() {
|
||||
<Link href="/">ID-Kaart</Link>
|
||||
</Button>
|
||||
<Button variant="outline">
|
||||
<Link href="/register-company">Loo ettevõtte konto</Link>
|
||||
<Link href="/company-offer">Loo ettevõtte konto</Link>
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user