summaryrefslogtreecommitdiff
path: root/src/lib/pengajuan-tempo/component/informasiPerusahaan.jsx
blob: 53181027161a8f372ca84882d967e9bc7d0b2260 (plain)
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
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
import React, { useState, useEffect, useMemo, useRef } from 'react';
import { Controller, set, useForm } from 'react-hook-form';
import HookFormSelect from '@/core/components/elements/Select/HookFormSelect';
import odooApi from '~/libs/odooApi';
import stateApi from '@/lib/address/api/stateApi.js';
import cityApi from '@/lib/address/api/cityApi';
import { Radio, RadioGroup, Stack, Checkbox } from '@chakra-ui/react';
import { usePengajuanTempoStore } from '../../../../src-migrate/modules/register/stores/usePengajuanTempoStore';
const informasiPerusahaan = ({
  chekValid,
  buttonSubmitClick,
  isKonfirmasi,
}) => {
  const { control, watch, setValue, getValues } = useForm();
  const { form, errors, validate, updateForm } = usePengajuanTempoStore();
  const [industries, setIndustries] = useState([]);
  const [selectedCategory, setSelectedCategory] = useState('');
  const [states, setState] = useState([]);
  const [cities, setCities] = useState([]);
  const [bersedia, setBersedia] = useState(null);
  const category_produk = [
    { id: 1, name: 'Pengaman, Kesehatan & Keamanan' },
    { id: 2, name: 'Perkakas Tangan, Listrik & Pneumatic' },
    { id: 3, name: 'Mesin Industrial' },
    { id: 4, name: 'Mesin Pertanian & Perkebunan' },
    { id: 5, name: 'Mesin Pembersih & Janitorial' },
    { id: 6, name: 'Cairan Berbahan Kimia' },
    { id: 7, name: 'Perlengkapan Pengukuran & Pengujian' },
    { id: 8, name: 'Peralatan Listrik & Elektronik' },
    { id: 9, name: 'Perlengkapan Logistik & Gudang' },
    { id: 10, name: 'Peralatan Kantor & Stationery' },
    { id: 11, name: 'Komponen & Aksesoris' },
    { id: 12, name: 'Peralatan Horeca & Food Service' },
  ];
  const radioOptions = [
    { label: '5.000.000', value: '5000000' },
    { label: '10.000.000', value: '10000000' },
    { label: '15.000.000', value: '15000000' },
    { label: '20.000.000', value: '20000000' },
    { label: '25.000.000', value: '25000000' },
    { label: '30.000.000', value: '30000000' },
    { label: '35.000.000', value: '35000000' },
  ];

  useEffect(() => {
    const loadState = async () => {
      let dataState = await stateApi();
      dataState = dataState.map((state) => ({
        value: state.id,
        label: state.name,
      }));
      setState(dataState);
    };
    loadState();
  }, []);

  const watchState = watch('state');
  useEffect(() => {
    updateForm('city', '');
    if (watchState) {
      updateForm('state', `${watchState}`);
      validate();
      const loadCities = async () => {
        let dataCities = await cityApi({ stateId: watchState });
        dataCities = dataCities.map((city) => ({
          value: city.id,
          label: city.name,
        }));
        setCities(dataCities);
      };
      loadCities();
    }
  }, [watchState]);

  const watchCity = watch('city');
  useEffect(() => {
    if (watchCity) {
      updateForm('city', `${watchCity}`);
      validate();
    }
  }, [watchCity]);

  useEffect(() => {
    const loadIndustries = async () => {
      const dataIndustries = await odooApi('GET', '/api/v1/partner/industry');
      setIndustries(
        dataIndustries?.map((o) => ({
          value: o.id,
          label: o.name,
          category: o.category,
        }))
      );
    };
    loadIndustries();
  }, []);

  useEffect(() => {
    const selectedIndustryType = industries.find(
      (industry) => industry.value === watch('industry_id')
    );
    if (selectedIndustryType) {
      updateForm('industry_id', `${selectedIndustryType?.value}`);
      validate();
      setSelectedCategory(selectedIndustryType.category);
    }
  }, [watch('industry_id'), industries]);

  const estimasiValue = watch('estimasi');
  const tempoLimitValue = watch('tempoLimit');

  // Memformat angka menjadi format rupiah
  const formatRupiah = (value) => {
    if (!value) return '';
    const numberString = value.replace(/[^0-9]/g, ''); // Menghapus karakter non-digit
    return numberString
      ? 'Rp ' + new Intl.NumberFormat('id-ID').format(numberString)
      : '';
  };

  const handleChange = (e) => {
    const value = e.target.value;
    const formattedValue = formatRupiah(value);
    updateForm('estimasi', formattedValue.replace(/^Rp\s*/, ''));
    validate();
  };
  const onChangeTempoDuration = (e) => {
    updateForm('tempoDuration', `${e}`);
    validate();
  };

  const onChangeTempoLimit = (e) => {
    updateForm('tempoLimit', `${e}`);
    validate();
  };
  const [isCustom, setIsCustom] = React.useState(false);
  const [tempoLimitValueEx, setTempoLimitValueEx] = React.useState('');
  const handleCheckboxBersediaChange = (value) => {
    // if (value === 'bersedia') {
    //   setBersedia(true);
    // } else if (value === 'tidakBersedia') {
    //   setBersedia(false);
    // }
    // updateForm('bersedia', `${value === 'bersedia'}`);
    updateForm('bersedia', `${value}`);
    validate();
  };
  const [selectedIds, setSelectedIds] = useState(
    form.categoryProduk ? form.categoryProduk.split(',').map(Number) : [] // Parse string menjadi array angka
  );

  const handleCheckboxChange = (id) => {
    const updatedSelected = selectedIds.includes(id)
      ? selectedIds.filter((selectedId) => selectedId !== id)
      : [...selectedIds, id];

    setSelectedIds(updatedSelected);

    // Mengubah array kembali menjadi string yang dipisahkan oleh koma
    updateForm('categoryProduk', updatedSelected.join(','));
    validate();
  };

  useEffect(() => {
    if (form.categoryProduk) {
      setSelectedIds(form.categoryProduk.split(',').map(Number)); // Parse string menjadi array angka
    }
  }, [form.categoryProduk]);
  const isChecked = (id) => selectedIds.includes(id);

  const handleInputChange = (event) => {
    const { name, value } = event.target;
    updateForm(name, value);
    validate();
  };

  const midIndex = Math.ceil(category_produk.length / 2);
  const firstColumn = category_produk.slice(0, midIndex);
  const secondColumn = category_produk.slice(midIndex);
  const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors]);

  const nameRef = useRef(null);
  const industry_idRef = useRef(null);
  const streetRef = useRef(null);
  const stateRef = useRef(null);
  const cityRef = useRef(null);
  const zipRef = useRef(null);
  const mobileRef = useRef(null);
  const bankNameRef = useRef(null);
  const accountNameRef = useRef(null);
  const accountNumberRef = useRef(null);
  const estimasiRef = useRef(null);
  const tempoDurationRef = useRef(null);
  const bersediaRef = useRef(null);
  const categoryProdukRef = useRef(null);
  const tempoLimitRef = useRef(null);
  useEffect(() => {
    const loadIndustries = async () => {
      if (!isFormValid) {
        const options = {
          behavior: 'smooth',
          block: 'center',
        };
        if (errors.name && nameRef.current) {
          nameRef.current.scrollIntoView(options);
          return;
        }
        if (errors.industry_id && industry_idRef.current) {
          industry_idRef.current.scrollIntoView(options);
          return;
        }
        if (errors.street && streetRef.current) {
          streetRef.current.scrollIntoView(options);
          return;
        }
        if (errors.state && stateRef.current) {
          stateRef.current.scrollIntoView(options);
          return;
        }
        if (errors.city && cityRef.current) {
          cityRef.current.scrollIntoView(options);
          return;
        }
        if (errors.zip && zipRef.current) {
          zipRef.current.scrollIntoView(options);
          return;
        }
        if (errors.mobile && mobileRef.current) {
          mobileRef.current.scrollIntoView(options);
          return;
        }
        if (errors.bankName && bankNameRef.current) {
          bankNameRef.current.scrollIntoView(options);
          return;
        }
        if (errors.accountName && accountNameRef.current) {
          accountNameRef.current.scrollIntoView(options);
          return;
        }
        if (errors.accountNumber && accountNumberRef.current) {
          accountNumberRef.current.scrollIntoView(options);
          return;
        }
        if (errors.estimasi && estimasiRef.current) {
          estimasiRef.current.scrollIntoView(options);
          return;
        }
        if (errors.tempoDuration && tempoDurationRef.current) {
          tempoDurationRef.current.scrollIntoView(options);
          return;
        }
        if (errors.bersedia && bersediaRef.current) {
          bersediaRef.current.scrollIntoView(options);
          return;
        }
        if (errors.categoryProduk && categoryProdukRef.current) {
          categoryProdukRef.current.scrollIntoView(options);
          return;
        }
        if (errors.tempoLimit && tempoLimitRef.current) {
          tempoLimitRef.current.scrollIntoView(options);
          return;
        }
      }
    };
    loadIndustries();
  }, [buttonSubmitClick, chekValid]);
  useEffect(() => {
    if (form.industry_id) {
      setValue('industry_id', parseInt(form.industry_id));
    }
    if (form.state) {
      setValue('state', parseInt(form.state));
    }
    if (form.city) {
      setValue('city', parseInt(form.city));
    }
    if (form.tempoDuration) {
      setValue('tempoDuration', form.tempoDuration);
    }
    if (form.tempoLimit) {
      setValue('tempoLimit', form.tempoLimit);
    }
    if (form.tempoLimit) {
      const isValueInOptions = radioOptions.some(
        (option) => option.value === form.tempoLimit
      );

      if (isValueInOptions) {
        setValue('tempoLimit', form.tempoLimit); // Set value dari radio options
        setIsCustom(false); // Pastikan custom tidak aktif
      } else {
        setValue('tempoLimit', 'custom'); // Set value ke custom jika tidak termasuk dalam options
        setIsCustom(true); // Aktifkan custom input
        setTempoLimitValueEx(form.tempoLimit); // Set nilai input custom ke form.tempoLimit
      }
    }
  }, [form]);
  return (
    <div className=''>
      <h1 className={`font-bold ${isKonfirmasi ? 'text-xl' : ''}`}>
        Informasi Perusahaan
      </h1>
      <form className='flex flex-col w-full '>
        <div className='w-full grid grid-row-2 gap-5'>
          <div className='flex flex-row  justify-between items-start'>
            <div className='w-2/5'>
              <label className='form-label  text-nowrap'>Nama Perusahaan</label>
              {!isKonfirmasi && (
                <span className='text-xs opacity-60'>
                  isi detail perusahaan sesuai dengan nama yang terdaftar{' '}
                </span>
              )}
            </div>
            <div className='w-3/5'>
              <input
                id='name'
                name='name'
                placeholder='Masukkan nama perusahaan'
                type='text'
                className='form-input'
                aria-invalid={errors.name}
                value={form.name}
                ref={nameRef}
                onChange={handleInputChange}
              />
              {!isKonfirmasi && (
                <span className='text-xs opacity-60'>
                  Format: PT. INDOTEKNIK DOTCOM GEMILANG
                </span>
              )}
              {chekValid && (
                <div className='text-caption-2 text-danger-500 mt-1'>
                  {errors.name}
                </div>
              )}
            </div>
          </div>
          <div className='flex flex-row  justify-between items-start'>
            <div className='w-2/5' ref={industry_idRef}>
              <label className='form-label  text-nowrap'>Industri</label>
              {!isKonfirmasi && (
                <span className='text-xs opacity-60'>
                  isi detail perusahaan sesuai dengan nama yang terdaftar
                </span>
              )}
            </div>
            <div className='w-3/5'>
              <Controller
                name='industry_id'
                control={control}
                render={(props) => (
                  <HookFormSelect
                    {...props}
                    options={industries}
                    placeholder={'Pilih industri bisnis anda'}
                  />
                )}
              />
              {!isKonfirmasi && selectedCategory && (
                <span className='text-gray_r-11 text-xs opacity-60'>
                  Kategori : {selectedCategory}
                </span>
              )}
              {chekValid && (
                <div className='text-caption-2 text-danger-500 mt-1'>
                  {errors.industry_id}
                </div>
              )}
            </div>
          </div>

          <div className='flex flex-row  justify-between items-start'>
            <div>
              <label className='form-label w-2/5 text-nowrap'>
                Alamat Perusahaan
              </label>
              {!isKonfirmasi && (
                <span className='text-xs opacity-60'>
                  alamat sesuai dengan alamat kantor pusat
                </span>
              )}
            </div>
            <div className='w-3/5 flex gap-3 flex-col'>
              <div>
                <input
                  id='street'
                  name='street'
                  ref={streetRef}
                  placeholder='Masukkan alamat lengkap perusahaan'
                  type='text'
                  value={form.street}
                  className='form-input'
                  onChange={handleInputChange}
                />
                {chekValid && (
                  <div className='text-caption-2 text-danger-500 mt-1'>
                    {errors.street}
                  </div>
                )}
              </div>
              <div className='sub-alamat flex flex-row w-full gap-3'>
                <div className='w-2/5' ref={stateRef}>
                  <Controller
                    name='state'
                    control={control}
                    render={(props) => (
                      <HookFormSelect
                        {...props}
                        options={states}
                        placeholder='Provinsi'
                      />
                    )}
                  />
                  {chekValid && (
                    <div className='text-caption-2 text-danger-500 mt-1'>
                      {errors.state}
                    </div>
                  )}
                </div>
                <div className='w-1/3' ref={cityRef}>
                  <Controller
                    name='city'
                    control={control}
                    render={(props) => (
                      <HookFormSelect
                        {...props}
                        options={cities}
                        disabled={!watchState}
                        placeholder='Kota'
                      />
                    )}
                  />
                  {chekValid && (
                    <div className='text-caption-2 text-danger-500 mt-1'>
                      {errors.city}
                    </div>
                  )}
                </div>
                <div className='w-1/3'>
                  <input
                    id='zip'
                    name='zip'
                    ref={zipRef}
                    placeholder='Kode Pos'
                    type='number'
                    value={form.zip}
                    className='form-input'
                    onChange={handleInputChange}
                  />
                  {chekValid && (
                    <div className='text-caption-2 text-danger-500 mt-1'>
                      {errors.zip}
                    </div>
                  )}
                </div>
              </div>
            </div>
          </div>
          <div className='flex flex-row  justify-between items-start'>
            <div>
              <label className='form-label w-2/5 text-nowrap'>
                No. Telfon Perusahaan
              </label>
              {!isKonfirmasi && (
                <span className='text-xs opacity-60'>
                  isi no telfon perusahaan yang sesuai
                </span>
              )}
            </div>
            <div className='w-3/5'>
              <input
                id='mobile'
                name='mobile'
                ref={mobileRef}
                placeholder='Masukkan nomor telfon perusahaan'
                type='tel'
                value={form.mobile}
                className='form-input'
                aria-invalid={errors.mobile}
                onChange={handleInputChange}
              />
              {chekValid && (
                <div className='text-caption-2 text-danger-500 mt-1'>
                  {errors.mobile}
                </div>
              )}
            </div>
          </div>

          <div className='flex flex-row  justify-between items-start'>
            <div>
              <label className='form-label w-2/5 text-nowrap'>Data Bank</label>
              {!isKonfirmasi && (
                <span className='text-xs opacity-60'>
                  Isi detail data bank perusahaan anda
                </span>
              )}
            </div>
            <div className='w-3/5 flex gap-3 flex-row'>
              <div>
                <input
                  id='bankName'
                  name='bankName'
                  ref={bankNameRef}
                  placeholder='Nama bank'
                  type='text'
                  value={form.bankName}
                  className='form-input'
                  onChange={handleInputChange}
                />
                {!isKonfirmasi && (
                  <span className='text-xs opacity-60'>
                    Format: BCA, Mandiri, CIMB, BNI dll
                  </span>
                )}
                {chekValid && (
                  <div className='text-caption-2 text-danger-500 mt-1'>
                    {errors.bankName}
                  </div>
                )}
              </div>
              <div>
                <input
                  id='accountName'
                  name='accountName'
                  ref={accountNameRef}
                  placeholder='Nama Rekening'
                  type='text'
                  value={form.accountName}
                  className='form-input'
                  onChange={handleInputChange}
                />
                {!isKonfirmasi && (
                  <span className='text-xs opacity-60'>Format: John Doe</span>
                )}
                {chekValid && (
                  <div className='text-caption-2 text-danger-500 mt-1'>
                    {errors.accountName}
                  </div>
                )}
              </div>
              <div>
                <input
                  id='accountNumber'
                  name='accountNumber'
                  ref={accountNumberRef}
                  placeholder='Nomor Rekening Bank'
                  type='text'
                  value={form.accountNumber}
                  className='form-input'
                  onChange={handleInputChange}
                />
                {!isKonfirmasi && (
                  <span className='text-xs opacity-60'>
                    Format: 01234567896
                  </span>
                )}
                {chekValid && (
                  <div className='text-caption-2 text-danger-500 mt-1'>
                    {errors.accountNumber}
                  </div>
                )}
              </div>
            </div>
          </div>

          <div className='flex flex-row  justify-between items-start'>
            <div>
              <label className='form-label w-2/5 text-nowrap'>
                Website <span className=' opacity-60'>(Opsional)</span>
              </label>
            </div>
            <div className='w-3/5'>
              <input
                id='website'
                name='website'
                placeholder='www.indoteknik.com'
                type='text'
                value={form.website}
                className='form-input'
                onChange={handleInputChange}
              />
            </div>
          </div>

          <div className='flex flex-row  justify-between items-start'>
            <div>
              <label className='form-label w-2/5 text-nowrap'>
                Estimasi Pembelian pertahun
              </label>
            </div>
            <div className='w-3/5'>
              <div className='relative'>
                <input
                  id='estimasi'
                  name='estimasi'
                  ref={estimasiRef}
                  // {...register('estimasi', {
                  //   setValueAs: (value) => value.replace(/^Rp\s*/, ''), // Menyimpan hanya angka
                  // })}
                  placeholder='Isi estimasi pembelian produk pertahun'
                  type='text'
                  className='form-input' // padding untuk memberi ruang untuk "RP"
                  value={formatRupiah(form.estimasi)}
                  onChange={handleChange} // Mengatur perubahan input
                />
              </div>
              {chekValid && (
                <div className='text-caption-2 text-danger-500 mt-1'>
                  {errors.estimasi}
                </div>
              )}
            </div>
          </div>

          <div className='flex flex-row  justify-between items-center'>
            <div className='w-2/5'>
              <label className='form-label text-nowrap'>Durasi Tempo</label>
              <span className='text-xs opacity-60'>
                Pilih durasi tempo yang anda inginkan
              </span>
            </div>
            <div className='w-3/5 flex flex-row items-center'>
              <div className='w-1/5' ref={tempoDurationRef}>
                <RadioGroup
                  onChange={onChangeTempoDuration}
                  value={form.tempoDuration}
                >
                  <Stack direction='column' className=''>
                    <Radio colorScheme='red' value='7'>
                      7 Hari
                    </Radio>
                    <Radio colorScheme='red' value='14' className=''>
                      14 Hari
                    </Radio>
                    <Radio colorScheme='red' value='30' className=''>
                      30 Hari
                    </Radio>
                  </Stack>
                </RadioGroup>
                {chekValid && (
                  <div className='text-caption-2 text-danger-500 mt-1'>
                    {errors.tempoDuration}
                  </div>
                )}
              </div>
              {!isKonfirmasi && (
                <div className='w-4/5 flex flex-row justify-between items-center'>
                  <div>
                    <label className='form-label w-2/5 text-nowrap'>
                      Limit Tempo
                    </label>
                    <span className='text-xs opacity-60'>
                      Ajukan nilai limit yang anda mau
                    </span>
                  </div>
                  <div
                    className='flex flex-col justify-start items-start'
                    ref={tempoLimitRef}
                  >
                    <RadioGroup
                      onChange={(value) => {
                        if (value === 'custom') {
                          setIsCustom(true);
                          updateForm('tempoLimit', tempoLimitValue); // Update dengan nilai input custom jika dipilih
                        } else {
                          setIsCustom(false);
                          onChangeTempoLimit(value); // Update dengan nilai radio button yang dipilih
                        }
                      }}
                      className='flex items-center justify-between'
                      value={isCustom ? 'custom' : form.tempoLimit}
                    >
                      <Stack direction='row'>
                        {/* Kolom 1 */}
                        <Stack direction='column' spacing={2} className='mr-4'>
                          {radioOptions.slice(0, 4).map((option) => (
                            <Radio
                              key={option.value}
                              colorScheme='red'
                              value={option.value}
                            >
                              {option.label}
                            </Radio>
                          ))}
                        </Stack>

                        {/* Kolom 2 */}
                        <Stack direction='column' className='ml-8' spacing={2}>
                          {radioOptions.slice(4).map((option) => (
                            <Radio
                              key={option.value}
                              colorScheme='red'
                              value={option.value}
                            >
                              {option.label}
                            </Radio>
                          ))}
                          <div className='flex flex-row items-center'>
                            <Radio colorScheme='red' value='custom'></Radio>

                            <input
                              placeholder='Isi limit yang anda inginkan'
                              type='text'
                              className='border ml-2 p-1' // padding untuk memberi ruang untuk "RP"
                              value={formatRupiah(tempoLimitValueEx)} // Menampilkan nilai terformat
                              onChange={(e) => {
                                const value = e.target.value;
                                const formattedValue = formatRupiah(value);
                                setTempoLimitValueEx(formattedValue);
                                updateForm(
                                  'tempoLimit',
                                  formattedValue.replace(/^Rp\s*/, '')
                                ); // Mengupdate nilai di react-hook-form
                              }}
                            />
                          </div>
                        </Stack>
                      </Stack>
                    </RadioGroup>
                    {chekValid && (
                      <div className='text-caption-2 text-danger-500 mt-1'>
                        {errors.tempoLimit}
                      </div>
                    )}
                  </div>
                </div>
              )}
            </div>
          </div>
          {isKonfirmasi && (
            <div className='flex flex-row justify-between items-center'>
              <div className='w-2/5'>
                <label className='form-label w-2/5 text-nowrap'>
                  Limit Tempo
                </label>
                <span className='text-xs opacity-60'>
                  Ajukan nilai limit yang anda mau
                </span>
              </div>
              <div
                className='w-3/5 flex flex-col justify-start items-start'
                ref={tempoLimitRef}
              >
                <RadioGroup
                  onChange={(value) => {
                    if (value === 'custom') {
                      setIsCustom(true);
                      updateForm('tempoLimit', tempoLimitValue); // Update dengan nilai input custom jika dipilih
                    } else {
                      setIsCustom(false);
                      onChangeTempoLimit(value); // Update dengan nilai radio button yang dipilih
                    }
                  }}
                  className='flex items-center justify-between'
                  value={isCustom ? 'custom' : form.tempoLimit}
                >
                  <Stack direction='row'>
                    {/* Kolom 1 */}
                    <Stack direction='column' spacing={2} className='mr-4'>
                      {radioOptions.slice(0, 4).map((option) => (
                        <Radio
                          key={option.value}
                          colorScheme='red'
                          value={option.value}
                        >
                          {option.label}
                        </Radio>
                      ))}
                    </Stack>

                    {/* Kolom 2 */}
                    <Stack direction='column' className='ml-8' spacing={2}>
                      {radioOptions.slice(4).map((option) => (
                        <Radio
                          key={option.value}
                          colorScheme='red'
                          value={option.value}
                        >
                          {option.label}
                        </Radio>
                      ))}
                      <div className='flex flex-row items-center'>
                        <Radio colorScheme='red' value='custom'></Radio>

                        <input
                          placeholder='Isi limit yang anda inginkan'
                          type='text'
                          className='border ml-2 p-1' // padding untuk memberi ruang untuk "RP"
                          value={formatRupiah(tempoLimitValueEx)} // Menampilkan nilai terformat
                          onChange={(e) => {
                            const value = e.target.value;
                            const formattedValue = formatRupiah(value);
                            setTempoLimitValueEx(formattedValue);
                            updateForm(
                              'tempoLimit',
                              formattedValue.replace(/^Rp\s*/, '')
                            ); // Mengupdate nilai di react-hook-form
                          }}
                        />
                      </div>
                    </Stack>
                  </Stack>
                </RadioGroup>
                {chekValid && (
                  <div className='text-caption-2 text-danger-500 mt-1'>
                    {errors.tempoLimit}
                  </div>
                )}
              </div>
            </div>
          )}

          <div className='text-red-500'>
            *Durasi dan limit dapat berbeda sesuaui dengan verifikasi oleh tim
            Indoteknik.com
          </div>

          <div className='flex flex-row justify-between items-start'>
            <div className='w-2/5'>
              <label className='form-label  text-wrap '>
                Apakah bersedia transaksi via website?
              </label>
              {!isKonfirmasi && (
                <span className='text-xs opacity-60'>
                  Pilih produk bisa lebih dari 1
                </span>
              )}
            </div>
            <div className='w-3/5 flex flex-col justify-start'>
              <div className='flex gap-x-4' ref={bersediaRef}>
                <RadioGroup
                  onChange={handleCheckboxBersediaChange}
                  value={form.bersedia}
                >
                  <Stack direction='row'>
                    <Radio colorScheme='red' value='bersedia'>
                      Saya bersedia
                    </Radio>
                    <Radio colorScheme='red' value='tidakBersedia'>
                      Tidak bersedia
                    </Radio>
                  </Stack>
                </RadioGroup>
                {/* <Checkbox
                  name='bersedia'
                  borderColor='gray.600'
                  colorScheme='red'
                  isChecked={bersedia === true} // Checked when bersedia is true
                  onChange={() => handleCheckboxBersediaChange('bersedia')}
                  value={true}
                  size='md'
                >
                  Saya bersedia
                </Checkbox>
                <Checkbox
                  name='bersedia'
                  borderColor='gray.600'
                  colorScheme='red'
                  isChecked={bersedia === false} // Checked when bersedia is false
                  onChange={() => handleCheckboxBersediaChange('tidakBersedia')}
                  value={false}
                  size='md'
                >
                  Tidak bersedia
                </Checkbox> */}
              </div>
              {chekValid && (
                <div className='text-caption-2 text-danger-500 mt-1'>
                  {errors.estimasi}
                </div>
              )}
            </div>
          </div>

          <div
            className={`flex flex-row  justify-between ${
              isKonfirmasi ? 'items-center' : 'items-start'
            }`}
          >
            <div>
              <label className='form-label w-2/5 text-nowrap'>
                Kategori Produk yang Digunakan
              </label>
              {!isKonfirmasi && (
                <span className='text-xs opacity-60'>
                  Pilih produk bisa lebih dari 1
                </span>
              )}
            </div>
            <div className='w-3/5 flex flex-col'>
              <div className='flex flex-row justify-between'>
                <div className='flex flex-col gap-2' ref={categoryProdukRef}>
                  {firstColumn.map((item) => (
                    <Checkbox
                      colorScheme='red'
                      key={item.id}
                      onChange={() => handleCheckboxChange(item.id)}
                      isChecked={isChecked(item.id)}
                    >
                      {item.name}
                    </Checkbox>
                  ))}
                </div>
                <div className='flex flex-col gap-2'>
                  {secondColumn.map((item) => (
                    <Checkbox
                      colorScheme='red'
                      key={item.id}
                      isChecked={isChecked(item.id)}
                      onChange={() => handleCheckboxChange(item.id)}
                    >
                      {item.name}
                    </Checkbox>
                  ))}
                </div>
              </div>
              {chekValid && (
                <div className='text-caption-2 text-danger-500 mt-1'>
                  {errors.categoryProduk}
                </div>
              )}
            </div>
          </div>
        </div>
      </form>
    </div>
  );
};

export default informasiPerusahaan;