From c19c7eee924b70d25cb47d40fd7c8e00d5efa867 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 23 Oct 2024 17:07:37 +0700
Subject: <iman> update pengajuan tempo section konfirmasi

---
 src/lib/pengajuan-tempo/component/Pengiriman.jsx | 101 ++++++++++++++---------
 1 file changed, 64 insertions(+), 37 deletions(-)

(limited to 'src/lib/pengajuan-tempo/component/Pengiriman.jsx')

diff --git a/src/lib/pengajuan-tempo/component/Pengiriman.jsx b/src/lib/pengajuan-tempo/component/Pengiriman.jsx
index 2e1b1bba..2497fb00 100644
--- a/src/lib/pengajuan-tempo/component/Pengiriman.jsx
+++ b/src/lib/pengajuan-tempo/component/Pengiriman.jsx
@@ -6,7 +6,7 @@ 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 { usePengajuanTempoStorePengiriman } from '../../../../src-migrate/modules/register/stores/usePengajuanTempoStore';
-const Pengiriman = ({ chekValid, buttonSubmitClick }) => {
+const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
   const { control, watch, setValue } = useForm();
   const {
     formPengiriman,
@@ -263,6 +263,14 @@ const Pengiriman = ({ chekValid, buttonSubmitClick }) => {
 
   useEffect(() => {
     validatePengiriman();
+    if (formPengiriman.isSameAddrees) {
+      const isSame = formPengiriman.isSameAddrees;
+      if (isSame == 'true') {
+        setSameAddress(true);
+      } else {
+        setSameAddress(false);
+      }
+    }
   }, [buttonSubmitClick]);
   useEffect(() => {
     if (sameAddress) {
@@ -270,6 +278,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick }) => {
       updateFormPengiriman('stateInvoice', formPengiriman.statePengiriman);
       updateFormPengiriman('cityInvoice', formPengiriman.cityPengiriman);
     }
+    updateFormPengiriman('isSameAddrees', `${sameAddress}`);
   }, [sameAddress]);
 
   const getFromLocalStorage = (key) => {
@@ -294,17 +303,23 @@ const Pengiriman = ({ chekValid, buttonSubmitClick }) => {
     if (cachedData.cityInvoice) {
       setValue('cityInvoice', parseInt(cachedData.cityInvoice));
     }
+    if (cachedData.isSameAddrees) {
+      updateFormPengiriman('isSameAddrees', `${cachedData.isSameAddrees}`);
+    }
   }, [cachedData.cityPengiriman]);
+  const handleChangeSameAddress = () => {
+    setSameAddress(!sameAddress);
+  };
   return (
     <>
-      <div className='flex justify-start'>
-        <h1 className='font-bold'>Pengiriman</h1>
-      </div>
-      <form className='flex mt-4 flex-col w-full '>
+      <h1 className={`font-bold ${isKonfirmasi ? 'text-xl' : ''}`}>
+        Pengiriman
+      </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>
-              <label className='form-label w-2/5 text-nowrap'>
+            <div className='w-2/5'>
+              <label className='form-label  text-nowrap'>
                 Nama PIC Penerimaan Barang
               </label>
             </div>
@@ -329,13 +344,16 @@ const Pengiriman = ({ chekValid, buttonSubmitClick }) => {
           </div>
 
           <div className='flex flex-row  justify-between items-start'>
-            <div>
-              <label className='form-label w-2/5 text-nowrap'>
+            <div className='w-2/5'>
+              <label className='form-label   text-nowrap'>
                 Alamat Pengiriman Barang
               </label>
-              <span className='text-xs opacity-60'>
-                pastikan alamat yang anda isi sesuai dengan alamat kirim barang
-              </span>
+              {!isKonfirmasi && (
+                <span className='text-xs opacity-60'>
+                  pastikan alamat yang anda isi sesuai dengan alamat kirim
+                  barang
+                </span>
+              )}
             </div>
             <div className='w-3/5 flex gap-3 flex-col'>
               <div>
@@ -415,8 +433,8 @@ const Pengiriman = ({ chekValid, buttonSubmitClick }) => {
           </div>
 
           <div className='flex flex-row  justify-between items-start'>
-            <div>
-              <label className='form-label w-2/5 text-nowrap'>
+            <div className='w-2/5'>
+              <label className='form-label  text-nowrap'>
                 Nama PIC Penerimaan Invoice
               </label>
             </div>
@@ -441,20 +459,23 @@ const Pengiriman = ({ chekValid, buttonSubmitClick }) => {
           </div>
 
           <div className='flex flex-row  justify-between items-start'>
-            <div>
-              <label className='form-label w-2/5 text-nowrap'>
+            <div className='w-2/5'>
+              <label className='form-label text-nowrap'>
                 Alamat Pengiriman Invoice
               </label>
-              <span className='text-xs opacity-60'>
-                Pastikan alamat yang anda isi sesuai dengan alamat kirim invoice
-              </span>
+              {!isKonfirmasi && (
+                <span className='text-xs opacity-60'>
+                  Pastikan alamat yang anda isi sesuai dengan alamat kirim
+                  invoice
+                </span>
+              )}
             </div>
             <div className='w-3/5 flex gap-3 flex-col'>
               <div>
                 <Checkbox
                   colorScheme='red'
                   isChecked={sameAddress}
-                  onChange={() => setSameAddress(!sameAddress)}
+                  onChange={handleChangeSameAddress}
                 >
                   Alamat invoice sama dengan alamat pengiriman
                 </Checkbox>
@@ -523,14 +544,16 @@ const Pengiriman = ({ chekValid, buttonSubmitClick }) => {
           </div>
 
           <div className='flex flex-row  justify-between items-start'>
-            <div>
-              <label className='form-label w-2/5 text-nowrap'>
+            <div className='w-2/5'>
+              <label className='form-label   text-wrap'>
                 Jadwal Penukaran Invoice{' '}
                 <span className=' opacity-60'>(Opsional)</span>
               </label>
-              <span className='text-xs opacity-60'>
-                Pilih jika bisnis anda memiliki jadwal penukaran invoice
-              </span>
+              {!isKonfirmasi && (
+                <span className='text-xs opacity-60'>
+                  Pilih jika bisnis anda memiliki jadwal penukaran invoice
+                </span>
+              )}
             </div>
             <div className='w-3/5 flex gap-3 flex-col'>
               <div className='flex gap-3 flex-col'>
@@ -595,14 +618,16 @@ const Pengiriman = ({ chekValid, buttonSubmitClick }) => {
           </div>
 
           <div className='flex flex-row  justify-between items-start'>
-            <div>
-              <label className='form-label w-2/5 text-nowrap'>
+            <div className='w-2/5'>
+              <label className='form-label text-nowrap'>
                 Jadwal Pembayaran{' '}
                 <span className=' opacity-60'>(Opsional)</span>
               </label>
-              <span className='text-xs opacity-60'>
-                Pilih jika bisnis anda memiliki jadwal pembayaran
-              </span>
+              {!isKonfirmasi && (
+                <span className='text-xs opacity-60'>
+                  Pilih jika bisnis anda memiliki jadwal pembayaran
+                </span>
+              )}
             </div>
             <div className='w-3/5 flex gap-3 flex-col'>
               <div className='flex gap-3 flex-col'>
@@ -665,13 +690,15 @@ const Pengiriman = ({ chekValid, buttonSubmitClick }) => {
           </div>
 
           <div className='flex flex-row  justify-between items-start'>
-            <div>
-              <label className='form-label w-2/5 text-nowrap'>
+            <div className='w-2/5'>
+              <label className='form-label   text-wrap'>
                 Dokumen saat Pengiriman Barang
               </label>
-              <span className='text-xs opacity-60'>
-                Pilih dokumen lampiran saat pengiriman barang
-              </span>
+              {!isKonfirmasi && (
+                <span className='text-xs opacity-60'>
+                  Pilih dokumen lampiran saat pengiriman barang
+                </span>
+              )}
             </div>
             <div
               className='w-3/5 flex gap-3 flex-col'
@@ -741,8 +768,8 @@ const Pengiriman = ({ chekValid, buttonSubmitClick }) => {
           </div>
 
           <div className='flex flex-row  justify-between items-start'>
-            <div>
-              <label className='form-label w-2/5 text-nowrap'>
+            <div className='w-2/5'>
+              <label className='form-label  text-wrap'>
                 Dokumen yang dilampirkan saat Pengiriman Invoice
               </label>
               <span className='text-xs opacity-60'>
-- 
cgit v1.2.3

