From f7dc0ddd0a90e9be93b68fe5f92aeabf0b2ed11d Mon Sep 17 00:00:00 2001
From: Linc2427 <ahmadmiqdad27@te.student.pens.ac.id>
Date: Tue, 15 Apr 2025 17:27:17 +0700
Subject: <miqdad> change invoice input to required

---
 src/lib/pengajuan-tempo/component/Pengiriman.jsx | 39 ++++++++++++------------
 1 file changed, 20 insertions(+), 19 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 fcfa7e1e..bbf22345 100644
--- a/src/lib/pengajuan-tempo/component/Pengiriman.jsx
+++ b/src/lib/pengajuan-tempo/component/Pengiriman.jsx
@@ -1052,9 +1052,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
                                   <HookFormSelect
                                     {...props}
                                     options={zips}
-                                    disabled={
-                                      sameAddressStreet
-                                    }
+                                    disabled={sameAddressStreet}
                                     placeholder='Zip'
                                   />
                                 ) : (
@@ -1065,9 +1063,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
                                     ref={zipRef}
                                     placeholder='Kode Pos'
                                     type='number'
-                                    disabled={
-                                      sameAddressStreet
-                                    }
+                                    disabled={sameAddressStreet}
                                     value={formPengiriman.zipPengiriman}
                                     className='form-input'
                                     onChange={handleInputChange}
@@ -1322,9 +1318,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
                                   <HookFormSelect
                                     {...props}
                                     options={zipsInvoice}
-                                    disabled={
-                                      sameAddress
-                                    }
+                                    disabled={sameAddress}
                                     placeholder='Zip'
                                   />
                                 ) : (
@@ -1334,9 +1328,7 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
                                     ref={zipInvoiceRef}
                                     placeholder='Kode Pos'
                                     type='number'
-                                    disabled={
-                                      sameAddress
-                                    }
+                                    disabled={sameAddress}
                                     value={formPengiriman.zipInvoice}
                                     className='form-input'
                                     onChange={handleInputChange}
@@ -1361,11 +1353,11 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
                 <div className='w-2/5'>
                   <label className='form-label   text-wrap'>
                     Jadwal Penukaran Invoice{' '}
-                    <span className=' opacity-60'>(Opsional)</span>
+                    <span className=' opacity-60'>(Wajib Diisi)</span>
                   </label>
                   {!isKonfirmasi && (
                     <span className='text-xs opacity-60'>
-                      isi jika perusahaan anda memiliki jadwal penukaran invoice
+                      isi jadwal penukaran invoice
                     </span>
                   )}
                 </div>
@@ -1380,7 +1372,13 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
                     rows={4}
                     cols={40}
                     onChange={handleInputChange}
+                    required
                   />
+                  {chekValid && (
+                    <div className='text-caption-2 text-danger-500 mt-1'>
+                      {errorsPengiriman.tukarInvoiceInput}
+                    </div>
+                  )}
                 </div>
               </div>
 
@@ -1388,11 +1386,11 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
                 <div className='w-2/5'>
                   <label className='form-label text-nowrap'>
                     Jadwal Pembayaran{' '}
-                    <span className=' opacity-60'>(Opsional)</span>
+                    <span className=' opacity-60'>(Wajib Diisi)</span>
                   </label>
                   {!isKonfirmasi && (
                     <span className='text-xs opacity-60'>
-                      isi jika perusahaan anda memiliki jadwal pembayaran
+                      isi jadwal pembayaran
                     </span>
                   )}
                 </div>
@@ -1406,7 +1404,13 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
                     rows={4}
                     cols={40}
                     onChange={handleInputChange}
+                    required
                   />
+                  {chekValid && (
+                    <div className='text-caption-2 text-danger-500 mt-1'>
+                      {errorsPengiriman.tukarInvoiceInputPembayaran}
+                    </div>
+                  )}
                 </div>
               </div>
 
@@ -1601,7 +1605,6 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
                   )}
                 </div>
               </div>
-              
             </div>
           </form>
         </div>
@@ -2330,8 +2333,6 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
                 </div>
                 <div className='w-2/5'></div>
               </div>
-
-              
             </div>
           </form>
         </div>
-- 
cgit v1.2.3


From ee135f9d54e92350c5e639d64f1948ca41f47509 Mon Sep 17 00:00:00 2001
From: Miqdad <ahmadkimpir@gmail.com>
Date: Wed, 16 Apr 2025 14:40:48 +0700
Subject: <miqdad> make scroll to the error field

---
 src/lib/pengajuan-tempo/component/Pengiriman.jsx | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 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 bbf22345..a8e7fd22 100644
--- a/src/lib/pengajuan-tempo/component/Pengiriman.jsx
+++ b/src/lib/pengajuan-tempo/component/Pengiriman.jsx
@@ -360,6 +360,8 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
     [errorsPengiriman]
   );
 
+  const tukarInvoiceInputRef = useRef(null);
+  const tukarInvoiceInputPembayaranRef = useRef(null);
   const PICNameRef = useRef(null);
   const streetPengirimanRef = useRef(null);
   const statePengirimanRef = useRef(null);
@@ -390,6 +392,14 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
           behavior: 'smooth',
           block: 'center',
         };
+        if (errorsPengiriman.tukarInvoiceInput && tukarInvoiceInputRef.current) {
+          tukarInvoiceInputRef.current.scrollIntoView(options);
+          return;
+        }
+        if (errorsPengiriman.tukarInvoiceInputPembayaran && tukarInvoiceInputPembayaranRef.current) {
+          tukarInvoiceInputPembayaranRef.current.scrollIntoView(options);
+          return;
+        }
         if (errorsPengiriman.PICName && PICNameRef.current) {
           PICNameRef.current.scrollIntoView(options);
           return;
@@ -1353,7 +1363,6 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
                 <div className='w-2/5'>
                   <label className='form-label   text-wrap'>
                     Jadwal Penukaran Invoice{' '}
-                    <span className=' opacity-60'>(Wajib Diisi)</span>
                   </label>
                   {!isKonfirmasi && (
                     <span className='text-xs opacity-60'>
@@ -1370,6 +1379,8 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
                     value={formPengiriman.tukarInvoiceInput}
                     className='form-input'
                     rows={4}
+                    aria-invalid={errorsPengiriman.tukarInvoiceInput}
+                    ref={tukarInvoiceInputRef}
                     cols={40}
                     onChange={handleInputChange}
                     required
@@ -1386,7 +1397,6 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
                 <div className='w-2/5'>
                   <label className='form-label text-nowrap'>
                     Jadwal Pembayaran{' '}
-                    <span className=' opacity-60'>(Wajib Diisi)</span>
                   </label>
                   {!isKonfirmasi && (
                     <span className='text-xs opacity-60'>
@@ -1401,6 +1411,8 @@ const Pengiriman = ({ chekValid, buttonSubmitClick, isKonfirmasi }) => {
                     placeholder='Masukkan jadwal pembayaran'
                     value={formPengiriman.tukarInvoiceInputPembayaran}
                     className='form-input'
+                    aria-invalid={errorsPengiriman.tukarInvoiceInputPembayaran}
+                    ref={tukarInvoiceInputPembayaranRef}
                     rows={4}
                     cols={40}
                     onChange={handleInputChange}
-- 
cgit v1.2.3

