Skip to content

Commit d2a7618

Browse files
committed
style: missed corrections
1 parent 453d545 commit d2a7618

File tree

4 files changed

+18
-28
lines changed

4 files changed

+18
-28
lines changed

front-end/src/app/(home)/create-route/page.tsx

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,6 @@ import { SeatsSelect } from "@/components/ui/Inputs/SeatSelect";
3030
import { CustomTextarea } from "@/components/ui/Inputs/CustomTextarea";
3131
import { onError } from "@/utils/formUtils";
3232

33-
const FIELD_LABELS: Record<string, string> = {
34-
departureLocation: "Departure location",
35-
arrivalLocation: "Arrival location",
36-
dateTrip: "Travel Date",
37-
time: "Time",
38-
availableSeats: "Available seats",
39-
pricePerSeat: "Price per seat",
40-
smoking: "Smoking",
41-
petsAllowed: "Pets allowed",
42-
additionalInfo: "Additional info",
43-
};
44-
4533
export default function CreateRoute() {
4634
const { register, control, handleSubmit } = useForm<CreateRouteFormValues>({
4735
resolver: zodResolver(createRouteSchema),
@@ -94,26 +82,28 @@ export default function CreateRoute() {
9482
mutation.mutate(body);
9583
};
9684

97-
const onError = (errors: FieldErrors) => {
98-
const firstErrorKey = Object.keys(errors)[0];
99-
const firstError = errors[firstErrorKey as keyof CreateRouteFormValues];
85+
const handleOnError = (errors: FieldErrors) => {
86+
const FIELD_LABELS: Record<string, string> = {
87+
departureLocation: "Departure location",
88+
arrivalLocation: "Arrival location",
89+
dateTrip: "Travel Date",
90+
time: "Time",
91+
availableSeats: "Available seats",
92+
pricePerSeat: "Price per seat",
93+
smoking: "Smoking",
94+
petsAllowed: "Pets allowed",
95+
additionalInfo: "Additional info",
96+
};
10097

101-
if (firstError?.message && firstErrorKey) {
102-
const fieldLabel = FIELD_LABELS[firstErrorKey] || firstErrorKey;
103-
toast.error(`${fieldLabel}: ${firstError.message}`);
104-
} else {
105-
toast.error("Please check the form for errors");
106-
}
98+
onError(FIELD_LABELS, errors);
10799
};
108100

109101
return (
110102
<section className="flex justify-center w-full py-8 px-4">
111103
<div className="flex flex-col gap-8 max-w-xl w-full">
112104
{/* Header */}
113105
<div className="flex flex-col gap-2">
114-
<Typography variant="h2">
115-
Offer a ride
116-
</Typography>
106+
<Typography variant="h2">Offer a ride</Typography>
117107
<Typography className="text-muted-foreground text-lg">
118108
Share your journey and split the costs. Fill in the details below to
119109
post your ride.
@@ -122,7 +112,7 @@ export default function CreateRoute() {
122112

123113
<form
124114
id="create-route"
125-
onSubmit={handleSubmit(onSubmit, onError)}
115+
onSubmit={handleSubmit(onSubmit, handleOnError)}
126116
className="flex flex-col gap-6 w-full"
127117
noValidate
128118
>

front-end/src/app/(home)/login/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default function LoginPage() {
5757
};
5858

5959
return (
60-
<div className="h-full flex-1 flex justify-center items-center">
60+
<div className="h-full w-full flex-1 flex justify-center items-center">
6161
<Card className="w-full max-w-sm">
6262
<CardHeader>
6363
<CardTitle className="text-2xl">Login</CardTitle>

front-end/src/app/(home)/register/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default function RegisterPage() {
7373
);
7474

7575
return (
76-
<div className="h-full flex-1 flex justify-center items-center">
76+
<div className="h-full w-full flex-1 flex justify-center items-center">
7777
<Card className="w-full max-w-sm">
7878
<CardHeader>
7979
<CardTitle className="text-2xl">Register</CardTitle>

front-end/src/components/HomePage/HomePage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default async function HomePage({ searchParams }: HomePageProps) {
8282
isInitialLoad={isInitialLoad}
8383
page={page}
8484
totalPages={searchResult.totalPages}
85-
limit={LIMIT}
85+
limit={searchResult?.pageData?.length ?? 0}
8686
hasResults={hasResults}
8787
searchForm={
8888
<SearchRoutesForm

0 commit comments

Comments
 (0)