FIX Build

Fix build
This commit is contained in:
danelkungla
2025-07-09 14:02:53 +03:00
committed by GitHub
6 changed files with 152 additions and 134 deletions

View File

@@ -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;

View File

@@ -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>

View File

@@ -139,7 +139,7 @@ function getPatterns() {
handler: adminMiddleware,
},
{
pattern: new URLPattern({ pathname: '/auth/*?' }),
pattern: new URLPattern({ pathname: '/auth/update-account' }),
handler: async (req: NextRequest, res: NextResponse) => {
const {
data: { user },

View File

@@ -1,25 +1,27 @@
import { deleteLineItem } from "@lib/data/cart"
import { Spinner, Trash } from "@medusajs/icons"
import { clx } from "@medusajs/ui"
import { useState } from "react"
"use client";
import { deleteLineItem } from "@lib/data/cart";
import { Spinner, Trash } from "@medusajs/icons";
import { clx } from "@medusajs/ui";
import { useState } from "react";
const DeleteButton = ({
id,
children,
className,
}: {
id: string
children?: React.ReactNode
className?: string
id: string;
children?: React.ReactNode;
className?: string;
}) => {
const [isDeleting, setIsDeleting] = useState(false)
const [isDeleting, setIsDeleting] = useState(false);
const handleDelete = async (id: string) => {
setIsDeleting(true)
setIsDeleting(true);
await deleteLineItem(id).catch((err) => {
setIsDeleting(false)
})
}
setIsDeleting(false);
});
};
return (
<div
@@ -36,7 +38,7 @@ const DeleteButton = ({
<span>{children}</span>
</button>
</div>
)
}
);
};
export default DeleteButton
export default DeleteButton;

View File

@@ -1,37 +1,39 @@
import { Label } from "@medusajs/ui"
import React, { useEffect, useImperativeHandle, useState } from "react"
"use client";
import Eye from "@modules/common/icons/eye"
import EyeOff from "@modules/common/icons/eye-off"
import { Label } from "@medusajs/ui";
import React, { useEffect, useImperativeHandle, useState } from "react";
import Eye from "@modules/common/icons/eye";
import EyeOff from "@modules/common/icons/eye-off";
type InputProps = Omit<
Omit<React.InputHTMLAttributes<HTMLInputElement>, "size">,
"placeholder"
> & {
label: string
errors?: Record<string, unknown>
touched?: Record<string, unknown>
name: string
topLabel?: string
}
label: string;
errors?: Record<string, unknown>;
touched?: Record<string, unknown>;
name: string;
topLabel?: string;
};
const Input = React.forwardRef<HTMLInputElement, InputProps>(
({ type, name, label, touched, required, topLabel, ...props }, ref) => {
const inputRef = React.useRef<HTMLInputElement>(null)
const [showPassword, setShowPassword] = useState(false)
const [inputType, setInputType] = useState(type)
const inputRef = React.useRef<HTMLInputElement>(null);
const [showPassword, setShowPassword] = useState(false);
const [inputType, setInputType] = useState(type);
useEffect(() => {
if (type === "password" && showPassword) {
setInputType("text")
setInputType("text");
}
if (type === "password" && !showPassword) {
setInputType("password")
setInputType("password");
}
}, [type, showPassword])
}, [type, showPassword]);
useImperativeHandle(ref, () => inputRef.current!)
useImperativeHandle(ref, () => inputRef.current!);
return (
<div className="flex flex-col w-full">
@@ -67,10 +69,10 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
)}
</div>
</div>
)
);
}
)
);
Input.displayName = "Input"
Input.displayName = "Input";
export default Input
export default Input;

View File

@@ -1,5 +1,7 @@
import { ChevronUpDown } from "@medusajs/icons"
import { clx } from "@medusajs/ui"
"use client";
import { ChevronUpDown } from "@medusajs/icons";
import { clx } from "@medusajs/ui";
import {
SelectHTMLAttributes,
forwardRef,
@@ -7,34 +9,34 @@ import {
useImperativeHandle,
useRef,
useState,
} from "react"
} from "react";
export type NativeSelectProps = {
placeholder?: string
errors?: Record<string, unknown>
touched?: Record<string, unknown>
} & SelectHTMLAttributes<HTMLSelectElement>
placeholder?: string;
errors?: Record<string, unknown>;
touched?: Record<string, unknown>;
} & SelectHTMLAttributes<HTMLSelectElement>;
const NativeSelect = forwardRef<HTMLSelectElement, NativeSelectProps>(
(
{ placeholder = "Select...", defaultValue, className, children, ...props },
ref
) => {
const innerRef = useRef<HTMLSelectElement>(null)
const [isPlaceholder, setIsPlaceholder] = useState(false)
const innerRef = useRef<HTMLSelectElement>(null);
const [isPlaceholder, setIsPlaceholder] = useState(false);
useImperativeHandle<HTMLSelectElement | null, HTMLSelectElement | null>(
ref,
() => innerRef.current
)
);
useEffect(() => {
if (innerRef.current && innerRef.current.value === "") {
setIsPlaceholder(true)
setIsPlaceholder(true);
} else {
setIsPlaceholder(false)
setIsPlaceholder(false);
}
}, [innerRef.current?.value])
}, [innerRef.current?.value]);
return (
<div>
@@ -65,10 +67,10 @@ const NativeSelect = forwardRef<HTMLSelectElement, NativeSelectProps>(
</span>
</div>
</div>
)
);
}
)
);
NativeSelect.displayName = "NativeSelect"
NativeSelect.displayName = "NativeSelect";
export default NativeSelect
export default NativeSelect;