From 89345a3d1d7201272bff1b4e4a8ffb4fcf5b3e9e Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 22 Aug 2024 10:15:35 +0700
Subject: <iman> add ? to data fetch

---
 src-migrate/modules/promo/components/Voucher.tsx | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

(limited to 'src-migrate/modules/promo/components/Voucher.tsx')

diff --git a/src-migrate/modules/promo/components/Voucher.tsx b/src-migrate/modules/promo/components/Voucher.tsx
index e5877e51..510fe746 100644
--- a/src-migrate/modules/promo/components/Voucher.tsx
+++ b/src-migrate/modules/promo/components/Voucher.tsx
@@ -56,7 +56,7 @@ const VoucherComponent = () => {
     spaceBetween: 2,
   };
   
-  const dataVouchers = useMemo(() => voucherQuery.data || [], [voucherQuery.data]);
+  const dataVouchers = useMemo(() => voucherQuery?.data || [], [voucherQuery?.data]);
 
   const vouchers = auth?.id? listVouchers : dataVouchers;
 
@@ -121,30 +121,30 @@ const VoucherComponent = () => {
 
       <div className='h-6' />
 
-      {voucherQuery.isLoading && (
+      {voucherQuery?.isLoading && (
         <div className='grid grid-cols-3 gap-x-4 animate-pulse'>
           {Array.from({ length: 3 }).map((_, index) => (
             <div key={index} className='w-full h-[160px] bg-gray-200 rounded-xl' />
           ))}
         </div>
       )}
-      {!voucherQuery.isLoading && (
+      {!voucherQuery?.isLoading && (
         <div className={style['voucher-section']}>
           <Swiper {...swiperVoucher}>
             {vouchers?.map((voucher) => (
               <SwiperSlide key={voucher.id} className='pb-2'>
                 <div className={style['voucher-card']}>
-                  <Image src={voucher.image} alt={voucher.name} width={128} height={128} className={style['voucher-image']} />
+                  <Image src={voucher?.image} alt={voucher?.name} width={128} height={128} className={style['voucher-image']} />
 
                   <div className={style['voucher-content']}>
-                    <div className={style['voucher-title']}>{voucher.name}</div>
-                    <div className={style['voucher-desc']}>{voucher.description}</div>
+                    <div className={style['voucher-title']}>{voucher?.name}</div>
+                    <div className={style['voucher-desc']}>{voucher?.description}</div>
                     <div className={style['voucher-bottom']}>
                       <div>
                         <div className={style['voucher-code-desc']}>Kode Promo</div>
-                        <div className={style['voucher-code']}>{voucher.code}</div>
+                        <div className={style['voucher-code']}>{voucher?.code}</div>
                       </div>
-                      <button className={style['voucher-copy']} onClick={() => copyText(voucher.code)}>Salin</button>
+                      <button className={style['voucher-copy']} onClick={() => copyText(voucher?.code)}>Salin</button>
                     </div>
                   </div>
                 </div>
-- 
cgit v1.2.3

