Skip to content

Commit cae8702

Browse files
committed
AYS-283: WIP
1 parent f71cd3d commit cae8702

File tree

3 files changed

+124
-119
lines changed

3 files changed

+124
-119
lines changed

src/app/(private)/emergency-evacuation-applications/[id]/page.tsx

Lines changed: 122 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { zodResolver } from '@hookform/resolvers/zod'
1515
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
1616
import { useTranslation } from 'react-i18next'
1717
import { LoadingSpinner } from '@/components/ui/loadingSpinner'
18-
import { Toaster } from '@/components/ui/toaster'
1918
import { useToast } from '@/components/ui/use-toast'
2019
import { formatPhoneNumber } from '@/lib/formatPhoneNumber'
2120
import PrivateRoute from '@/app/hocs/isAuth'
@@ -73,25 +72,23 @@ const Page = ({ params }: { params: { slug: string; id: string } }) => {
7372
<PrivateRoute requiredPermissions={[Permission.EVACUATION_DETAIL]}>
7473
<div className="p-6 bg-white dark:bg-gray-800 rounded-md shadow-md text-black dark:text-white">
7574
{isLoading && <LoadingSpinner />}
76-
{error && <Toaster />}
7775
{!isLoading && !error && emergencyEvacuationApplicationDetails && (
7876
<Form {...form}>
7977
<form className="space-y-6">
8078
<h1 className="text-2xl font-bold mb-6">
8179
{t('emergencyEvacuationApplications.detailsTitle')}
8280
</h1>
83-
8481
<Card className="mb-6">
8582
<CardHeader>
8683
<CardTitle>{t('applicationInformation')}</CardTitle>
8784
</CardHeader>
8885
<CardContent>
89-
<div className="grid grid-cols-1 gap-y-6 sm:grid-cols-2 sm:gap-x-6">
86+
<div className="grid grid-cols-1 gap-y-6 sm:grid-cols-3 sm:gap-x-6">
9087
<FormField
9188
control={control}
9289
name="referenceNumber"
9390
render={({ field }) => (
94-
<FormItem className="sm:col-span-2">
91+
<FormItem className="sm:col-span-1">
9592
<FormLabel>{t('referenceNumber')}</FormLabel>
9693
<FormControl>
9794
<Input
@@ -158,64 +155,92 @@ const Page = ({ params }: { params: { slug: string; id: string } }) => {
158155
</FormItem>
159156
)}
160157
/>
161-
{emergencyEvacuationApplicationDetails.isInPerson ? null : (
162-
<>
163-
<FormField
164-
control={control}
165-
name="applicantNameSurname"
166-
render={({ field }) => (
167-
<FormItem className="sm:col-span-1">
168-
<FormLabel>
169-
{t(
170-
'emergencyEvacuationApplications.applicantNameSurname',
171-
)}
172-
</FormLabel>
173-
<FormControl>
174-
<Input
175-
{...field}
176-
disabled
177-
defaultValue={
178-
emergencyEvacuationApplicationDetails.applicantFirstName ??
179-
'' +
180-
emergencyEvacuationApplicationDetails.applicantLastName ??
181-
''
182-
}
183-
/>
184-
</FormControl>
185-
</FormItem>
186-
)}
187-
/>
188-
<FormField
189-
control={control}
190-
name="applicantPhoneNumber"
191-
render={({ field }) => (
192-
<FormItem className="sm:col-span-1">
193-
<FormLabel>
194-
{t(
195-
'emergencyEvacuationApplications.applicantPhoneNumber',
196-
)}
197-
</FormLabel>
198-
<FormControl>
199-
<Input
200-
{...field}
201-
disabled
202-
defaultValue={
203-
emergencyEvacuationApplicationDetails
204-
?.applicantPhoneNumber?.countryCode &&
205-
emergencyEvacuationApplicationDetails
206-
?.applicantPhoneNumber?.lineNumber
207-
? formatPhoneNumber(
208-
emergencyEvacuationApplicationDetails.applicantPhoneNumber,
209-
)
210-
: ''
211-
}
212-
/>
213-
</FormControl>
214-
</FormItem>
215-
)}
216-
/>
217-
</>
218-
)}
158+
<FormField
159+
control={control}
160+
name="isInPerson"
161+
render={({ field }) => (
162+
<FormItem className="sm:col-span-3">
163+
<div className="flex items-center">
164+
<FormLabel className="mr-2">
165+
{t('emergencyEvacuationApplications.isInPerson')}
166+
</FormLabel>
167+
<FormControl>
168+
<Checkbox
169+
{...field}
170+
disabled
171+
checked={
172+
emergencyEvacuationApplicationDetails.isInPerson
173+
}
174+
/>
175+
</FormControl>
176+
</div>
177+
</FormItem>
178+
)}
179+
/>
180+
</div>
181+
{!emergencyEvacuationApplicationDetails.isInPerson && (
182+
<div className="grid grid-cols-1 gap-y-6 sm:grid-cols-2 sm:gap-x-6 my-6">
183+
<FormField
184+
control={control}
185+
name="applicantNameSurname"
186+
render={({ field }) => (
187+
<FormItem className="col-span-1">
188+
<FormLabel>
189+
{t(
190+
'emergencyEvacuationApplications.applicantNameSurname',
191+
)}
192+
</FormLabel>
193+
<FormControl>
194+
<Input
195+
{...field}
196+
disabled
197+
defaultValue={
198+
(emergencyEvacuationApplicationDetails.applicantFirstName ??
199+
'') +
200+
(emergencyEvacuationApplicationDetails.applicantFirstName &&
201+
emergencyEvacuationApplicationDetails.applicantLastName
202+
? ' '
203+
: '') +
204+
(emergencyEvacuationApplicationDetails.applicantLastName ??
205+
'')
206+
}
207+
/>
208+
</FormControl>
209+
</FormItem>
210+
)}
211+
/>
212+
<FormField
213+
control={control}
214+
name="applicantPhoneNumber"
215+
render={({ field }) => (
216+
<FormItem className="col-span-1">
217+
<FormLabel>
218+
{t(
219+
'emergencyEvacuationApplications.applicantPhoneNumber',
220+
)}
221+
</FormLabel>
222+
<FormControl>
223+
<Input
224+
{...field}
225+
disabled
226+
defaultValue={
227+
emergencyEvacuationApplicationDetails
228+
?.applicantPhoneNumber?.countryCode &&
229+
emergencyEvacuationApplicationDetails
230+
?.applicantPhoneNumber?.lineNumber
231+
? formatPhoneNumber(
232+
emergencyEvacuationApplicationDetails.applicantPhoneNumber,
233+
)
234+
: ''
235+
}
236+
/>
237+
</FormControl>
238+
</FormItem>
239+
)}
240+
/>
241+
</div>
242+
)}
243+
<div className="grid grid-cols-1 gap-y-6 sm:grid-cols-2 sm:gap-x-6">
219244
<FormField
220245
control={control}
221246
name="sourcecityAndDistrict"
@@ -247,19 +272,27 @@ const Page = ({ params }: { params: { slug: string; id: string } }) => {
247272
/>
248273
<FormField
249274
control={control}
250-
name="address"
275+
name="targetCityAndDistrict"
251276
render={({ field }) => (
252277
<FormItem className="sm:col-span-1">
253278
<FormLabel>
254-
{t('emergencyEvacuationApplications.address')}
279+
{t(
280+
'emergencyEvacuationApplications.targetCityAndDistrict',
281+
)}
255282
</FormLabel>
256283
<FormControl>
257284
<Input
258285
{...field}
259286
disabled
260287
defaultValue={
261-
emergencyEvacuationApplicationDetails.address ??
262-
''
288+
(emergencyEvacuationApplicationDetails.targetCity ??
289+
'') +
290+
(emergencyEvacuationApplicationDetails.targetCity &&
291+
emergencyEvacuationApplicationDetails.targetDistrict
292+
? ' / '
293+
: '') +
294+
(emergencyEvacuationApplicationDetails.targetDistrict ??
295+
'')
263296
}
264297
/>
265298
</FormControl>
@@ -268,27 +301,19 @@ const Page = ({ params }: { params: { slug: string; id: string } }) => {
268301
/>
269302
<FormField
270303
control={control}
271-
name="targetCityAndDistrict"
304+
name="address"
272305
render={({ field }) => (
273-
<FormItem className="sm:col-span-1">
306+
<FormItem className="sm:col-span-2">
274307
<FormLabel>
275-
{t(
276-
'emergencyEvacuationApplications.targetCityAndDistrict',
277-
)}
308+
{t('emergencyEvacuationApplications.address')}
278309
</FormLabel>
279310
<FormControl>
280311
<Input
281312
{...field}
282313
disabled
283314
defaultValue={
284-
(emergencyEvacuationApplicationDetails.targetCity ??
285-
'') +
286-
(emergencyEvacuationApplicationDetails.targetCity &&
287-
emergencyEvacuationApplicationDetails.targetDistrict
288-
? ' / '
289-
: '') +
290-
(emergencyEvacuationApplicationDetails.targetDistrict ??
291-
'')
315+
emergencyEvacuationApplicationDetails.address ??
316+
''
292317
}
293318
/>
294319
</FormControl>
@@ -316,23 +341,24 @@ const Page = ({ params }: { params: { slug: string; id: string } }) => {
316341
/>
317342
<FormField
318343
control={control}
319-
name="isInPerson"
344+
name="confirmedSeatCount"
320345
render={({ field }) => (
321346
<FormItem className="sm:col-span-1">
322-
<div className="flex items-center">
323-
<FormLabel className="mr-2">
324-
{t('emergencyEvacuationApplications.isInPerson')}
325-
</FormLabel>
326-
<FormControl>
327-
<Checkbox
328-
{...field}
329-
disabled
330-
checked={
331-
emergencyEvacuationApplicationDetails.isInPerson
332-
}
333-
/>
334-
</FormControl>
335-
</div>
347+
<FormLabel>
348+
{t(
349+
'emergencyEvacuationApplications.confirmedSeatCount',
350+
)}
351+
</FormLabel>
352+
<FormControl>
353+
<Input
354+
{...field}
355+
disabled
356+
defaultValue={
357+
emergencyEvacuationApplicationDetails.seatingCount ??
358+
''
359+
}
360+
/>
361+
</FormControl>
336362
</FormItem>
337363
)}
338364
/>
@@ -404,34 +430,11 @@ const Page = ({ params }: { params: { slug: string; id: string } }) => {
404430
</FormItem>
405431
)}
406432
/>
407-
<FormField
408-
control={control}
409-
name="confirmedSeatCount"
410-
render={({ field }) => (
411-
<FormItem className="sm:col-span-1">
412-
<FormLabel>
413-
{t(
414-
'emergencyEvacuationApplications.confirmedSeatCount',
415-
)}
416-
</FormLabel>
417-
<FormControl>
418-
<Input
419-
{...field}
420-
disabled
421-
defaultValue={
422-
// emergencyEvacuationApplicationDetails.confirmedSeatCount ??
423-
''
424-
}
425-
/>
426-
</FormControl>
427-
</FormItem>
428-
)}
429-
/>
430433
<FormField
431434
control={control}
432435
name="operatorNotes"
433436
render={({ field }) => (
434-
<FormItem className="sm:col-span-1">
437+
<FormItem className="sm:col-span-2">
435438
<FormLabel>
436439
{t('emergencyEvacuationApplications.notes')}
437440
</FormLabel>

src/i18n/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
"title": "Emergency Evacuation Applications",
8989
"detailsTitle": "Emergency Evacuation Application Details",
9090
"nameSurname": "Name and Surname",
91+
"applicantInformation": "Information of the Applicant",
9192
"applicantNameSurname": "Name and Surname of Person to Contact",
9293
"applicantPhoneNumber": "Phone Number of Person to Contact",
9394
"sourceCityAndDistrict": "Current City / District",

src/i18n/locales/tr.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
"title": "Acil Durum Tahliye Başvurusu",
8888
"detailsTitle": "Acil Durum Tahliye Başvurusu Detayları",
8989
"nameSurname": "Ad ve Soyad",
90+
"applicantInformation": "Başvuru Sahibinin Bilgileri",
9091
"applicantNameSurname": "İletişime Geçilecek Kişinin Adı ve Soyadı",
9192
"applicantPhoneNumber": "İletişime Geçilecek Kişininin Telefon Numarası",
9293
"sourceCityAndDistrict": "Bulunulan Şehir / İlçe",

0 commit comments

Comments
 (0)