fix build
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
'use client';
|
||||
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
import { SubmitButton } from '@/components/ui/submit-button';
|
||||
import { sendCompanyOfferEmail } from '@/lib/services/mailer.service';
|
||||
import { CompanySubmitData } from '@/lib/types/company';
|
||||
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';
|
||||
|
||||
import { FormItem } from '@kit/ui/form';
|
||||
import { Input } from '@kit/ui/input';
|
||||
import { Label } from '@kit/ui/label';
|
||||
import { Trans } from '@kit/ui/trans';
|
||||
|
||||
const CompanyOfferForm = () => {
|
||||
const router = useRouter();
|
||||
const language = useTranslation().i18n.language;
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { isValid, isSubmitting },
|
||||
} = useForm({
|
||||
resolver: zodResolver(companyOfferSchema),
|
||||
mode: 'onChange',
|
||||
});
|
||||
|
||||
const onSubmit = async (data: CompanySubmitData) => {
|
||||
const formData = new FormData();
|
||||
Object.entries(data).forEach(([key, value]) => {
|
||||
if (value !== undefined) formData.append(key, value);
|
||||
});
|
||||
|
||||
try {
|
||||
sendCompanyOfferEmail(data, language)
|
||||
.then(() => router.push('/company-offer/success'))
|
||||
.catch((error) => alert('error: ' + error));
|
||||
} catch (err: unknown) {
|
||||
if (err instanceof Error) {
|
||||
console.warn('Server validation error: ' + err.message);
|
||||
}
|
||||
console.warn('Server validation error: ', err);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<form
|
||||
onSubmit={handleSubmit(onSubmit)}
|
||||
noValidate
|
||||
className="flex flex-col gap-6 px-6 pt-8 text-left"
|
||||
>
|
||||
<FormItem>
|
||||
<Label>
|
||||
<Trans i18nKey={'common:formField:companyName'} />
|
||||
</Label>
|
||||
<Input {...register('companyName')} />
|
||||
</FormItem>
|
||||
<FormItem>
|
||||
<Label>
|
||||
<Trans i18nKey={'common:formField:contactPerson'} />
|
||||
</Label>
|
||||
<Input {...register('contactPerson')} />
|
||||
</FormItem>
|
||||
<FormItem>
|
||||
<Label>
|
||||
<Trans i18nKey={'common:formField:email'} />
|
||||
</Label>
|
||||
<Input type="email" {...register('email')}></Input>
|
||||
</FormItem>
|
||||
<FormItem>
|
||||
<Label>
|
||||
<Trans i18nKey={'common:formField:phone'} />
|
||||
</Label>
|
||||
<Input type="tel" {...register('phone')} />
|
||||
</FormItem>
|
||||
<SubmitButton
|
||||
disabled={!isValid || isSubmitting}
|
||||
pendingText="Saatmine..."
|
||||
type="submit"
|
||||
>
|
||||
<Trans i18nKey={'account:requestCompanyAccount:button'} />
|
||||
</SubmitButton>
|
||||
</form>
|
||||
);
|
||||
};
|
||||
|
||||
export default CompanyOfferForm;
|
||||
@@ -1,54 +1,13 @@
|
||||
'use client';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
import { MedReportLogo } from '@/components/med-report-logo';
|
||||
import { SubmitButton } from '@/components/ui/submit-button';
|
||||
import { withI18n } from '@/lib/i18n/with-i18n';
|
||||
import { sendCompanyOfferEmail } from '@/lib/services/mailer.service';
|
||||
import { CompanySubmitData } from '@/lib/types/company';
|
||||
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';
|
||||
|
||||
import { FormItem } from '@kit/ui/form';
|
||||
import { Input } from '@kit/ui/input';
|
||||
import { Label } from '@kit/ui/label';
|
||||
import { Trans } from '@kit/ui/trans';
|
||||
|
||||
import CompanyOfferForm from './_components/company-offer-form';
|
||||
|
||||
function CompanyOffer() {
|
||||
const router = useRouter();
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { isValid, isSubmitting },
|
||||
} = useForm({
|
||||
resolver: zodResolver(companyOfferSchema),
|
||||
mode: 'onChange',
|
||||
});
|
||||
const language = useTranslation().i18n.language;
|
||||
|
||||
const onSubmit = async (data: CompanySubmitData) => {
|
||||
const formData = new FormData();
|
||||
Object.entries(data).forEach(([key, value]) => {
|
||||
if (value !== undefined) formData.append(key, value);
|
||||
});
|
||||
|
||||
try {
|
||||
sendCompanyOfferEmail(data, language)
|
||||
.then(() => router.push('/company-offer/success'))
|
||||
.catch((error) => alert('error: ' + error));
|
||||
} catch (err: unknown) {
|
||||
if (err instanceof Error) {
|
||||
console.warn('Server validation error: ' + err.message);
|
||||
}
|
||||
console.warn('Server validation error: ', err);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="border-border flex max-w-5xl flex-row overflow-hidden rounded-3xl border">
|
||||
<div className="flex w-1/2 flex-col px-12 py-14 text-center">
|
||||
@@ -59,43 +18,7 @@ function CompanyOffer() {
|
||||
<p className="text-muted-foreground pt-2 text-sm">
|
||||
<Trans i18nKey={'account:requestCompanyAccount:description'} />
|
||||
</p>
|
||||
<form
|
||||
onSubmit={handleSubmit(onSubmit)}
|
||||
noValidate
|
||||
className="flex flex-col gap-6 px-6 pt-8 text-left"
|
||||
>
|
||||
<FormItem>
|
||||
<Label>
|
||||
<Trans i18nKey={'common:formField:companyName'} />
|
||||
</Label>
|
||||
<Input {...register('companyName')} />
|
||||
</FormItem>
|
||||
<FormItem>
|
||||
<Label>
|
||||
<Trans i18nKey={'common:formField:contactPerson'} />
|
||||
</Label>
|
||||
<Input {...register('contactPerson')} />
|
||||
</FormItem>
|
||||
<FormItem>
|
||||
<Label>
|
||||
<Trans i18nKey={'common:formField:email'} />
|
||||
</Label>
|
||||
<Input type="email" {...register('email')}></Input>
|
||||
</FormItem>
|
||||
<FormItem>
|
||||
<Label>
|
||||
<Trans i18nKey={'common:formField:phone'} />
|
||||
</Label>
|
||||
<Input type="tel" {...register('phone')} />
|
||||
</FormItem>
|
||||
<SubmitButton
|
||||
disabled={!isValid || isSubmitting}
|
||||
pendingText="Saatmine..."
|
||||
type="submit"
|
||||
>
|
||||
<Trans i18nKey={'account:requestCompanyAccount:button'} />
|
||||
</SubmitButton>
|
||||
</form>
|
||||
<CompanyOfferForm />
|
||||
</div>
|
||||
<div className="w-1/2 min-w-[460px] bg-[url(/assets/med-report-logo-big.png)] bg-cover bg-center bg-no-repeat"></div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user