1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
|
import React from 'react';
import { useMemo, useState, useEffect, useRef } from 'react';
import Image from '~/components/ui/image';
import Stepper from './Stepper';
import InformasiPerusahaan from './informasiPerusahaan';
import KontakPerusahaan from './KontakPerusahaan';
import Pengiriman from './Pengiriman';
import Referensi from './Referensi';
import Dokumen from './Dokumen';
import Konfirmasi from './Konfirmasi';
import { getAuth } from '~/libs/auth';
import { setAuth } from '@/core/utils/auth';
import useAuth from '@/core/hooks/useAuth';
import { useRouter } from 'next/router';
import { Controller, useForm } from 'react-hook-form';
import {
usePengajuanTempoStore,
usePengajuanTempoStoreKontakPerson,
usePengajuanTempoStorePengiriman,
usePengajuanTempoStoreSupplier,
usePengajuanTempoStoreDokumen,
} from '../../../../src-migrate/modules/register/stores/usePengajuanTempoStore';
import { ChevronRightIcon, ChevronLeftIcon } from '@heroicons/react/24/outline';
import createPengajuanTempoApi from '../api/createPengajuanTempoApi';
import { Button, Checkbox, Spinner, Tooltip } from '@chakra-ui/react';
import clsxm from '~/libs/clsxm';
import { toast } from 'react-hot-toast';
import useDevice from '@/core/hooks/useDevice';
import odooApi from '~/libs/odooApi';
import editAuthTempo from '../api/editAuthTempo';
import BottomPopup from '@/core/components/elements/Popup/BottomPopup';
import PageContent from '@/lib/content/components/PageContent';
const PengajuanTempo = () => {
const { isDesktop, isMobile } = useDevice();
const [currentStep, setCurrentStep] = React.useState(0);
const NUMBER_OF_STEPS = 6;
const [isLoading, setIsLoading] = useState(false);
const [bigData, setBigData] = useState();
const [idTempo, setIdTempo] = useState(0);
const { form, errors, validate, updateForm } = usePengajuanTempoStore();
const { control, watch, setValue, setError } = useForm();
const auth = useAuth();
console.log('auth', auth);
const router = useRouter();
const [BannerTempo, setBannerTempo] = useState();
const { formDokumen, errorsDokumen, validateDokumen, updateFormDokumen } =
usePengajuanTempoStoreDokumen();
const {
formKontakPerson,
errorsKontakPerson,
validateKontakPerson,
updateFormKontakPerson,
} = usePengajuanTempoStoreKontakPerson();
const {
formSupplier,
errorsSupplier,
validateSupplier,
updateFormSupplier,
hasSavedata,
updateHasSave,
} = usePengajuanTempoStoreSupplier();
const {
formPengiriman,
errorsPengiriman,
validatePengiriman,
updateFormPengiriman,
} = usePengajuanTempoStorePengiriman();
const [notValid, setNotValid] = useState(false);
const [buttonSubmitClick, setButtonSubmitClick] = useState(false);
const stepDivs = [
<InformasiPerusahaan
key='informasi-perusahaan'
chekValid={notValid}
buttonSubmitClick={buttonSubmitClick}
/>,
<KontakPerusahaan
key='kontak-perusahaan'
chekValid={notValid}
buttonSubmitClick={buttonSubmitClick}
/>,
<Pengiriman
key='pengiriman'
chekValid={notValid}
buttonSubmitClick={buttonSubmitClick}
/>,
<Referensi
key='referensi'
chekValid={notValid}
buttonSubmitClick={buttonSubmitClick}
data={bigData?.supplierIds}
/>,
<Dokumen
key='dokumen'
chekValid={notValid}
buttonSubmitClick={buttonSubmitClick}
/>,
<Konfirmasi
key='konfirmasi'
chekValid={notValid}
buttonSubmitClick={buttonSubmitClick}
/>,
];
const stepDivsError = [
errors,
errorsKontakPerson,
errorsPengiriman,
errorsSupplier,
errorsDokumen,
<div key='konfirmasi'>Konfirmasi</div>,
];
const stepDivsForm = [
form,
formKontakPerson,
formPengiriman,
formSupplier,
formDokumen,
'',
];
const stepDivsUpdateForm = [
updateForm,
updateFormKontakPerson,
updateFormPengiriman,
updateFormSupplier,
updateFormDokumen,
<div key='konfirmasi'>Konfirmasi</div>,
];
const stepLabels = [
'informasi_perusahaan',
'kontak_person',
'Pengiriman',
'Referensi',
'Dokumen',
'Konfirmasi',
];
const isFormValid = useMemo(
() => Object.keys(stepDivsError[currentStep]).length === 0,
[stepDivsError[currentStep]]
);
useEffect(() => {
validate();
validateKontakPerson();
validatePengiriman();
validateDokumen();
updateHasSave(true);
if (isFormValid) {
window.scrollTo({
top: 0,
behavior: 'smooth',
});
}
}, [currentStep, buttonSubmitClick]);
useEffect(() => {
window.scrollTo({
top: 0,
behavior: 'smooth',
});
}, [currentStep]);
useEffect(() => {
const loadBigData = async () => {
const toCamelCase = (str) =>
str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
const transformKeysToCamelCase = (data) => {
if (Array.isArray(data)) {
return data.map((item) => transformKeysToCamelCase(item));
} else if (data && typeof data === 'object') {
return Object.keys(data).reduce((acc, key) => {
const camelKey = toCamelCase(key); // Ubah kunci menjadi camelCase
acc[camelKey] = transformKeysToCamelCase(data[key]); // Rekursif untuk nested object atau array
return acc;
}, {});
}
return data; // Jika bukan object atau array, kembalikan nilai aslinya
};
const payment = auth?.parentId ? auth?.parentId : auth?.partnerId;
try {
const dataPaymentTerm = await odooApi(
'GET',
`/api/v1/partner/detail-tempo/${payment}`
);
const transformedData = transformKeysToCamelCase(dataPaymentTerm);
setBigData(transformedData);
} catch (error) {
console.error('Error loading dataPaymentTerm:', error);
}
};
loadBigData();
}, [auth]);
useEffect(() => {
const cachedData = bigData;
const loadBigData = async () => {
if (cachedData) {
// Ambil kunci-kunci yang relevan berdasarkan currentStep dari stepDivsForm
const formKeys = stepDivsForm[currentStep]
? Object.keys(stepDivsForm[currentStep])
: [];
if (currentStep === 3) {
stepDivsUpdateForm[currentStep](cachedData.supplierIds);
} else if (currentStep === 4) {
formKeys.forEach((key) => {
if (cachedData[key]) {
// Proses hanya kunci yang ada di cachedData
const { name, format, base64 } = cachedData[key];
stepDivsUpdateForm[currentStep](key, name, format, base64);
}
});
} else {
formKeys.forEach((key) => {
if (bigData[key]) {
// Ubah data menjadi string
const stringData =
typeof bigData[key] === 'object'
? JSON.stringify(bigData[key]) // Untuk objek atau array
: String(bigData[key]); // Untuk tipe primitif
// Kirim data yang sudah diubah ke string ke stepDivsUpdateForm
stepDivsUpdateForm[currentStep](key, stringData);
if (key == 'dokumenProsedur') {
const stringData = bigData[key];
stepDivsUpdateForm[currentStep](key, stringData);
}
}
});
}
}
};
loadBigData();
validate();
validateKontakPerson();
validatePengiriman();
validateDokumen();
validateSupplier();
updateHasSave(true);
}, [currentStep, bigData, auth]);
const goToNextStep = () => {
if (!isFormValid) {
setNotValid(true);
setButtonSubmitClick(!buttonSubmitClick);
return;
} else {
// saveToLocalStorage(stepLabels[currentStep], stepDivsForm[currentStep]);
if (currentStep == 3) {
handleDaftarTempoSupplier();
} else if (currentStep == 4) {
handleDaftarTempoDokumen();
} else {
handleDaftarTempoPerPage(
stepLabels[currentStep],
stepDivsForm[currentStep]
);
}
setButtonSubmitClick(!buttonSubmitClick);
setNotValid(false);
}
setCurrentStep((prev) => (prev === NUMBER_OF_STEPS - 1 ? prev : prev + 1));
};
const goPrevStep = () => {
// if (!isFormValid) {
// setNotValid(true);
// setButtonSubmitClick(!buttonSubmitClick);
// return;
// } else {
// // saveToLocalStorage(stepLabels[currentStep], stepDivsForm[currentStep]);
// if (currentStep == 3) {
// handleDaftarTempoSupplier();
// } else if (currentStep == 4) {
// handleDaftarTempoDokumen();
// } else {
// handleDaftarTempoPerPage(
// stepLabels[currentStep],
// stepDivsForm[currentStep]
// );
// }
// setButtonSubmitClick(!buttonSubmitClick);
// setNotValid(false);
// }
setCurrentStep((prev) => (prev === NUMBER_OF_STEPS - 1 ? prev : prev - 1));
};
const handleDaftarTempoPerPage = async (
label,
formData,
tempoRequest = false
) => {
for (const error of stepDivsError) {
if (error.length > 0) {
return;
}
}
const toastId = toast.loading('Mengirimkan formulir pengajuan tempo...');
setIsLoading(true);
try {
const address = await createPengajuanTempoApi({
id: idTempo,
user_id: auth.parentId ? auth.parentId : auth.partnerId,
partner_id: auth.partnerId,
section: label,
tempo_request: tempoRequest,
...formData,
formDokumenProsedur: formData.dokumenProsedur
? JSON.stringify(formData.dokumenProsedur)
: false,
});
if (address.id) {
setIdTempo(address.id);
}
toast.dismiss(toastId);
setIsLoading(false);
} catch (error) {
toast.dismiss(toastId);
setIsLoading(false);
toast.error('Terjadi kesalahan dalam pengiriman formulir');
console.error(error);
}
};
const handleDaftarTempoDokumen = async () => {
for (const error of stepDivsError) {
if (error.length > 0) {
return;
}
}
// Filter hanya dokumen dengan `format` yang tidak undefined
const formattedDokumen = Object.entries(formDokumen)
.filter(([_, doc]) => doc.format !== undefined) // Hanya dokumen dengan `format` tidak undefined
.map(([key, doc]) => ({
documentName: key,
details: {
name: doc.name,
format: doc.format,
base64: doc.base64,
},
}));
const toastId = toast.loading('Mengirimkan formulir pengajuan tempo...');
if (formattedDokumen.length === 0) {
// toast.error('Tidak ada dokumen valid untuk dikirim.');
return;
}
setIsLoading(true);
try {
const address = await createPengajuanTempoApi({
id: idTempo,
user_id: auth.parentId ? auth.parentId : auth.partnerId,
partner_id: auth.partnerId,
formDocs: JSON.stringify(formattedDokumen),
});
if (address.id) {
setIdTempo(address.id);
}
toast.dismiss(toastId);
setIsLoading(false);
} catch (error) {
toast.dismiss(toastId);
setIsLoading(false);
toast.error('Terjadi kesalahan dalam pengiriman formulir');
console.error(error);
}
};
const isSupplierDataChanged = (formSupplier, supplierIds) => {
if (formSupplier.length !== supplierIds.length) {
return true;
}
return formSupplier.some((supplier, index) => {
const original = supplierIds[index];
return (
supplier.supplier !== original.supplier ||
supplier.pic !== original.pic ||
supplier.telepon !== original.telepon ||
supplier.durasiTempo !== original.durasiTempo ||
supplier.creditLimit !== original.creditLimit
);
});
};
const handleDaftarTempoSupplier = async () => {
for (const error of stepDivsError) {
if (error.length > 0) {
return;
}
}
const productOrder = formSupplier.map((product) => ({
supplier: product.supplier,
pic: product.pic,
telepon: product.telepon,
durasiTempo: product.durasiTempo,
creditLimit: product.creditLimit,
}));
// Periksa perubahan
const toastId = toast.loading('Mengirimkan formulir pengajuan tempo...');
if (bigData?.supplierIds) {
if (!isSupplierDataChanged(productOrder, bigData.supplierIds)) {
return;
}
}
setIsLoading(true);
try {
const address = await createPengajuanTempoApi({
id: idTempo,
user_id: auth.parentId ? auth.parentId : auth.partnerId,
partner_id: auth.partnerId,
formSupplier: JSON.stringify(productOrder),
});
if (address.id) {
setIdTempo(address.id);
}
toast.dismiss(toastId);
setIsLoading(false);
} catch (error) {
toast.dismiss(toastId);
setIsLoading(false);
toast.error('Terjadi kesalahan dalam pengiriman formulir');
console.error(error);
}
};
const handleDaftarTempo = async () => {
const phones = [
{ key: 'mobile', label: 'No. HP Perusahaan', value: form.mobile?.trim() },
{
key: 'direkturMobile',
label: 'No. HP Direktur',
value: formKontakPerson.direkturMobile?.trim(),
},
{
key: 'purchasingMobile',
label: 'No. HP Purchasing',
value: formKontakPerson.purchasingMobile?.trim(),
},
{
key: 'financeMobile',
label: 'No. HP Finance',
value: formKontakPerson.financeMobile?.trim(),
},
{
key: 'PICBarangMobile',
label: 'No. HP PIC Barang',
value: formPengiriman.PICBarangMobile?.trim(),
},
{
key: 'invoicePicMobile',
label: 'No. HP PIC Invoice',
value: formPengiriman.invoicePicMobile?.trim(),
},
].filter((p) => p.value);
const seen = new Map();
let firstErrorField = null;
// Reset error manual
phones.forEach((p) => setError(p.key, { type: 'manual', message: '' }));
for (const phone of phones) {
if (!seen.has(phone.value)) {
seen.set(phone.value, phone);
} else {
const first = seen.get(phone.value);
// Tampilkan toast
toast.error(`${phone.label} tidak boleh sama dengan ${first.label}`);
// Error merah di bawah input
setError(phone.key, {
type: 'manual',
message: `${phone.label} tidak boleh sama dengan ${first.label}`,
});
// Pasangan pertama yang duplikat
setError(first.key, {
type: 'manual',
message: `${first.label} tidak boleh sama dengan ${phone.label}`,
});
if (!firstErrorField) {
firstErrorField = phone.key;
}
}
}
if (firstErrorField) {
setTimeout(() => {
const el = document.querySelector(`[name="${firstErrorField}"]`);
if (el) {
el.scrollIntoView({ behavior: 'smooth', block: 'center' });
el.focus();
}
}, 100);
return;
}
for (const error of stepDivsError) {
if (error.length > 0) {
return;
}
}
const formattedDokumen = Object.entries(formDokumen)
.filter(([_, doc]) => doc.format !== undefined)
.map(([key, doc]) => ({
documentName: key,
details: {
name: doc.name,
format: doc.format,
base64: doc.base64,
},
}));
const toastId = toast.loading('Mengirimkan formulir pengajuan tempo...');
setIsLoading(true);
try {
let address4;
let address3;
const address = await createPengajuanTempoApi({
id: 0,
partner_id: auth.partnerId,
user_id: auth.parentId ? auth.parentId : auth.partnerId,
tempo_request: false,
...form,
});
if (address.id) {
const address2 = await createPengajuanTempoApi({
id: address.id,
partner_id: auth.partnerId,
user_id: address.userId,
tempo_request: false,
...formKontakPerson,
});
if (address2.id) {
address3 = await createPengajuanTempoApi({
id: address2.id,
partner_id: auth.partnerId,
user_id: address2.userId,
tempo_request: false,
...formPengiriman,
formDokumenProsedur: formPengiriman.dokumenProsedur
? JSON.stringify(formPengiriman.dokumenProsedur)
: false,
});
if (address3.id && formattedDokumen.length > 0) {
address4 = await createPengajuanTempoApi({
id: address3.id,
partner_id: auth.partnerId,
user_id: address3.userId,
tempo_request: true,
formDocs: JSON.stringify(formattedDokumen),
});
} else {
address4 = await createPengajuanTempoApi({
id: address3.id,
partner_id: auth.partnerId,
user_id: address3.userId,
tempo_request: true,
});
}
}
}
if (address4?.id) {
toast.success('Pengajuan tempo berhasil dilakukan');
const toastId2 = toast.loading('Mengubah status akun...');
const isUpdated = await editAuthTempo();
if (isUpdated?.user) {
const update = await setAuth(isUpdated.user);
if (update) {
toast.dismiss(toastId2);
setIsLoading(false);
toast.success('Berhasil mengubah status akun', { duration: 1000 });
router.push('/pengajuan-tempo/finish');
} else {
toast.dismiss(toastId2);
setIsLoading(false);
toast.success('Pengajuan tempo berhasil dilakukan');
toast.error('Gagal mengubah status akun', { duration: 1000 });
router.push('/pengajuan-tempo');
}
removeFromLocalStorage();
return;
}
} else {
toast.dismiss(toastId);
setIsLoading(false);
toast.error('Terjadi kesalahan dalam pengiriman formulir');
}
} catch (error) {
toast.dismiss(toastId);
setIsLoading(false);
toast.error('Terjadi kesalahan dalam pengiriman formulir');
console.error(error);
}
};
const removeFromLocalStorage = () => {
for (const key of stepLabels) {
localStorage.removeItem(key);
}
};
const [isCheckedTNC, setIsCheckedTNC] = useState(false);
const handleCheckChange = (checked) => {
setIsCheckedTNC(checked);
};
useEffect(() => {
const getBanner = async () => {
const get = await odooApi('GET', '/api/v1/banner?type=banner-form-tempo');
setBannerTempo(get[0].image);
// setBannerTempo(
// 'https://erp.indoteknik.com/api/image/x_banner.banner/x_banner_image/431'
// );
};
getBanner();
}, []);
return (
<>
<div className='container flex flex-col items-center '>
{BannerTempo && (
<Image
src={BannerTempo}
alt='FORM Tempo'
width={500}
height={160}
className='w-full mt-6'
/>
)}
<h1 className=' font-semibold text-center mb-6'>
Form Pengajuan Tempo
</h1>
<p
className={`text-center ${
isMobile ? 'w-full text-sm' : 'w-3/4 mb-4'
}`}
>
Pembayaran tempo adalah layanan pembayaran berjangka yang difasilitasi
indoteknik.com untuk konsumen akun bisnis yang terdaftar dengan waktu
pembayaran mulai dari 7, 14, 21 hingga 30 Hari.
</p>
</div>
<div
className={`h-[2px] w-full ${isMobile ? 'mt-4' : 'mb-20'} bg-gray_r-3`}
/>
<div className={`container ${isMobile ? 'mt-4' : 'mt-10'} flex flex-col`}>
<div className='flex items-center justify-center'>
<Stepper currentStep={currentStep} numberOfSteps={NUMBER_OF_STEPS} />
</div>
<div>{stepDivs[currentStep]}</div>
{isDesktop && <section className='flex gap-10 mt-10'></section>}
{isMobile && (
<div className='h-[2px] bg-gray-300 w-[120%] inset-0 mt-4 mb-4 relative transform -translate-x-5'></div>
)}
<div
className={`flex ${
isMobile
? 'flex-col justify-start items-start'
: 'flex-col justify-end items-end'
} mb-8 gap-2`}
>
<span className='text-xs opacity-60'>
*Pastikan data yang anda masukan sudah benar dan sesuai
</span>
<div
className={` flex flex-row ${
currentStep > 0 && currentStep < 5
? 'justify-between'
: 'justify-end'
} items-center w-full ${isMobile ? 'gap-x-4 ' : ''}`}
>
{currentStep < 5 && currentStep > 0 && (
<Button
colorScheme='yellow'
w={`${isMobile ? 'full' : 'fit'}`}
onClick={goPrevStep}
>
{<ChevronLeftIcon className='w-5' />}
<span className={`font-medium ${isMobile ? 'text-xs' : ''} `}>
Langkah Sebelumnya
</span>
</Button>
)}
{currentStep < 5 && (
<>
<Tooltip
label={clsxm({
'Klik simpan data terlebih dahulu':
currentStep === 3 && !hasSavedata,
})}
>
<Button
colorScheme='red'
w={`${isMobile ? 'full' : 'fit'}`}
isDisabled={
(currentStep === 3 && !hasSavedata) ||
currentStep === NUMBER_OF_STEPS - 1
}
onClick={goToNextStep}
>
<span className={`${isMobile ? 'text-xs' : ''} `}>
Langkah Selanjutnya
</span>
{<ChevronRightIcon className='w-5' />}
</Button>
</Tooltip>
</>
)}
</div>
{currentStep == 5 && (
<div
className={`flex flex-col ${
isMobile ? 'items-start' : 'items-end'
} w-full justify-start gap-4`}
>
<TempoTermCondition onCheckChange={handleCheckChange} />
<Button
colorScheme='red'
w={`${isMobile ? 'full' : '48'}`}
isDisabled={!isCheckedTNC || isLoading}
onClick={handleDaftarTempo}
>
{isLoading ? 'Loading...' : 'Daftar Tempo'}
{!isLoading && <ChevronRightIcon className='w-5' />}
</Button>
</div>
)}
</div>
</div>
</>
);
};
const TempoTermCondition = ({ onCheckChange }) => {
const [isCheckedTNC, SetIsCheckedTNC] = useState(false);
const [openTNC, SetOpenTNC] = useState(false);
const { isDesktop, isMobile } = useDevice();
const openTNCHandle = () => {
SetOpenTNC(!openTNC);
};
const toggleCheckTNC = () => {
const newValue = !isCheckedTNC;
SetIsCheckedTNC(newValue);
if (onCheckChange) {
onCheckChange(newValue);
}
};
return (
<>
<div className='flex items-center gap-x-2'>
<Checkbox
id='tnc'
name='tnc'
colorScheme='red'
isChecked={isCheckedTNC}
onChange={toggleCheckTNC}
/>
<div className={`${isMobile ? 'text-xs' : ''}`}>
<label htmlFor='tnc' className='cursor-pointer'>
Dengan ini saya menyetujui
</label>{' '}
<span
className='font-medium text-danger-500 cursor-pointer'
onClick={openTNCHandle}
>
syarat dan ketentuan
</span>
<label htmlFor='tnc' className='ml-2 cursor-pointer'>
yang berlaku
</label>
</div>
</div>
<BottomPopup
active={openTNC}
close={() => SetOpenTNC(false)}
title='Syarat & Ketentuan Pendaftaran Tempo'
>
<PageContent path='/tempoTnd' />
</BottomPopup>
</>
);
};
export default PengajuanTempo;
|