summaryrefslogtreecommitdiff
path: root/src-migrate/modules/promo/components/Voucher.tsx
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-09-24 16:12:50 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-09-24 16:12:50 +0700
commit36601aba6017aeef16f89351eb487238402ab52e (patch)
tree45bc3c78d5f36299922e6c03050e061b86a0d1e7 /src-migrate/modules/promo/components/Voucher.tsx
parent1e834e45f9a11911036496151b71f99de480862e (diff)
<iman> update Perapihan Tag
Diffstat (limited to 'src-migrate/modules/promo/components/Voucher.tsx')
-rw-r--r--src-migrate/modules/promo/components/Voucher.tsx65
1 files changed, 45 insertions, 20 deletions
diff --git a/src-migrate/modules/promo/components/Voucher.tsx b/src-migrate/modules/promo/components/Voucher.tsx
index 510fe746..034d13e9 100644
--- a/src-migrate/modules/promo/components/Voucher.tsx
+++ b/src-migrate/modules/promo/components/Voucher.tsx
@@ -55,15 +55,18 @@ const VoucherComponent = () => {
slidesPerView: isMobile ? 1.2 : 3.2,
spaceBetween: 2,
};
-
- const dataVouchers = useMemo(() => voucherQuery?.data || [], [voucherQuery?.data]);
- const vouchers = auth?.id? listVouchers : dataVouchers;
+ const dataVouchers = useMemo(
+ () => voucherQuery?.data || [],
+ [voucherQuery?.data]
+ );
+ const vouchers = auth?.id ? listVouchers : dataVouchers;
const copyText = (text: string) => {
if (navigator.clipboard && navigator.clipboard.writeText) {
- navigator.clipboard.writeText(text)
+ navigator.clipboard
+ .writeText(text)
.then(() => {
toast({
title: 'Salin ke papan klip',
@@ -72,7 +75,7 @@ const VoucherComponent = () => {
duration: 3000,
isClosable: true,
position: 'top',
- })
+ });
})
.catch(() => {
fallbackCopyTextToClipboard(text);
@@ -80,10 +83,10 @@ const VoucherComponent = () => {
} else {
fallbackCopyTextToClipboard(text);
}
- }
+ };
const fallbackCopyTextToClipboard = (text: string) => {
- const textArea = document.createElement("textarea");
+ const textArea = document.createElement('textarea');
textArea.value = text;
// Tambahkan style untuk menyembunyikan textArea secara visual
textArea.style.position = 'fixed';
@@ -108,23 +111,26 @@ const VoucherComponent = () => {
duration: 3000,
isClosable: true,
position: 'top',
- })
+ });
} catch (err) {
console.error('Fallback: Oops, unable to copy', err);
}
document.body.removeChild(textArea);
- }
+ };
return (
<>
- <div className={style['title']}>Pakai Voucher Belanja</div>
+ <h1 className={style['title']}>Pakai Voucher Belanja</h1>
<div className='h-6' />
{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
+ key={index}
+ className='w-full h-[160px] bg-gray-200 rounded-xl'
+ />
))}
</div>
)}
@@ -134,17 +140,36 @@ const VoucherComponent = () => {
{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-desc']}>
+ Kode Promo
+ </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>
@@ -154,7 +179,7 @@ const VoucherComponent = () => {
</div>
)}
</>
- )
-}
+ );
+};
-export default VoucherComponent
+export default VoucherComponent;