diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2025-01-13 17:08:44 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2025-01-13 17:08:44 +0700 |
| commit | e06905990de608585320754eb6a477cf32263595 (patch) | |
| tree | c2ffa0b95bec6da309eebf852e5c181a8da6c285 /src-migrate | |
| parent | 40f762589601de0fe1d5b06164b2553ebdbf5ecd (diff) | |
| parent | a868498e7327593b40d1e02fd96531fefd9548d5 (diff) | |
Merge branch 'new-release' into Feature/pengajuan-tempo
# Conflicts:
# src/core/components/elements/Navbar/NavbarDesktop.jsx
Diffstat (limited to 'src-migrate')
9 files changed, 48 insertions, 60 deletions
diff --git a/src-migrate/modules/cart/components/CartSummaryMobile.tsx b/src-migrate/modules/cart/components/CartSummaryMobile.tsx index d9f72e0e..02258204 100644 --- a/src-migrate/modules/cart/components/CartSummaryMobile.tsx +++ b/src-migrate/modules/cart/components/CartSummaryMobile.tsx @@ -29,6 +29,7 @@ const CartSummaryMobile = ({ isLoaded = false, }: Props) => { const [showPopup, setShowPopup] = useState(false); + const PPN : number = process.env.NEXT_PUBLIC_PPN ? parseFloat(process.env.NEXT_PUBLIC_PPN) : 0; return ( <> <BottomPopup @@ -63,7 +64,7 @@ const CartSummaryMobile = ({ </Skeleton> <Skeleton isLoaded={isLoaded} className={style.line}> - <span className={style.label}>Tax 11%</span> + <span className={style.label}>Tax {((PPN - 1) * 100).toFixed(0)}%</span> <span className={style.value}>Rp {formatCurrency(tax || 0)}</span> </Skeleton> diff --git a/src-migrate/modules/cart/components/Summary.tsx b/src-migrate/modules/cart/components/Summary.tsx index 2e55c8df..0af5ab18 100644 --- a/src-migrate/modules/cart/components/Summary.tsx +++ b/src-migrate/modules/cart/components/Summary.tsx @@ -25,6 +25,7 @@ const CartSummary = ({ grandTotal, isLoaded = false, }: Props) => { + const PPN : number = process.env.NEXT_PUBLIC_PPN ? parseFloat(process.env.NEXT_PUBLIC_PPN) : 0; return ( <> <div className='text-h-sm font-medium'>Ringkasan Pesanan</div> @@ -50,7 +51,7 @@ const CartSummary = ({ </Skeleton> <Skeleton isLoaded={isLoaded} className={style.line}> - <span className={style.label}>Tax 11%</span> + <span className={style.label}>Tax {((PPN - 1) * 100).toFixed(0)}%</span> <span className={style.value}>Rp {formatCurrency(tax || 0)}</span> </Skeleton> diff --git a/src-migrate/modules/cart/stores/useCartStore.ts b/src-migrate/modules/cart/stores/useCartStore.ts index c2ebf50f..e7d2cdd3 100644 --- a/src-migrate/modules/cart/stores/useCartStore.ts +++ b/src-migrate/modules/cart/stores/useCartStore.ts @@ -43,17 +43,20 @@ export const useCartStore = create<State & Action>((set, get) => ({ updateCartItem: (updatedCart) => { const cart = get().cart; if (!cart) return; - + set({ cart: updatedCart }); const summary = computeSummary(updatedCart); set({ summary }); }, - + })); const computeSummary = (cart: CartProps) => { let subtotal = 0; let discount = 0; + + const PPN: number = process.env.NEXT_PUBLIC_PPN ? parseFloat(process.env.NEXT_PUBLIC_PPN) : 0; + for (const item of cart?.products) { if (!item.selected) continue; @@ -67,8 +70,9 @@ const computeSummary = (cart: CartProps) => { discount += price - item.price.price_discount * item.quantity; } let total = subtotal - discount; - let tax = Math.round(total * 0.11); - let grandTotal = total + tax; + let grandTotal = total * PPN; + let tax = grandTotal - total; + // let grandTotal = total + tax; - return { subtotal, discount, total, tax, grandTotal }; + return { subtotal, discount, total, grandTotal, tax }; };
\ No newline at end of file diff --git a/src-migrate/modules/product-card/components/ProductCard.tsx b/src-migrate/modules/product-card/components/ProductCard.tsx index a439cdc8..8d3b55fb 100644 --- a/src-migrate/modules/product-card/components/ProductCard.tsx +++ b/src-migrate/modules/product-card/components/ProductCard.tsx @@ -16,6 +16,7 @@ type Props = { layout?: 'vertical' | 'horizontal'; }; +const PPN : number = process.env.NEXT_PUBLIC_PPN ? parseFloat(process.env.NEXT_PUBLIC_PPN) : 0; const ProductCard = ({ product, layout = 'vertical' }: Props) => { const utmSource = useUtmSource(); const { isDesktop, isMobile } = useDevice(); @@ -127,7 +128,7 @@ const ProductCard = ({ product, layout = 'vertical' }: Props) => { <div className={style['price-inc']}> Inc PPN: Rp{' '} - {formatCurrency(Math.round(product.lowest_price.price * 1.11))} + {formatCurrency(Math.round(product.lowest_price.price * PPN))} </div> <div className='h-1' /> diff --git a/src-migrate/modules/product-detail/components/PriceAction.tsx b/src-migrate/modules/product-detail/components/PriceAction.tsx index 0b27b1b3..9348bbfb 100644 --- a/src-migrate/modules/product-detail/components/PriceAction.tsx +++ b/src-migrate/modules/product-detail/components/PriceAction.tsx @@ -17,6 +17,7 @@ type Props = { product: IProductDetail; }; +const PPN : number = process.env.NEXT_PUBLIC_PPN ? parseFloat(process.env.NEXT_PUBLIC_PPN) : 0; const PriceAction = ({ product }: Props) => { const { activePrice, @@ -101,7 +102,7 @@ const PriceAction = ({ product }: Props) => { <div className='h-1' /> <div className={style['secondary-text']}> Termasuk PPN: Rp{' '} - {formatCurrency(Math.round(activePrice.price_discount * 1.11))} + {formatCurrency(Math.round(activePrice.price_discount * PPN))} </div> </> )} diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx index e4cf3442..12397956 100644 --- a/src-migrate/modules/register/components/FormBisnis.tsx +++ b/src-migrate/modules/register/components/FormBisnis.tsx @@ -1,9 +1,5 @@ import { ChangeEvent, useEffect, useMemo, useRef, useState } from 'react'; -import { useMutation } from 'react-query'; import { useRegisterStore } from '../stores/useRegisterStore'; -import { RegisterProps } from '~/types/auth'; -import { registerUser } from '~/services/auth'; -import { useRouter } from 'next/router'; import { Button, Checkbox, @@ -11,12 +7,10 @@ import { color, useToast, } from '@chakra-ui/react'; -import Link from 'next/link'; import getFileBase64 from '@/core/utils/getFileBase64'; import { Controller, useForm } from 'react-hook-form'; import HookFormSelect from '@/core/components/elements/Select/HookFormSelect'; import odooApi from '~/libs/odooApi'; -import { toast } from 'react-hot-toast'; import { EyeIcon } from '@heroicons/react/24/outline'; import BottomPopup from '@/core/components/elements/Popup/BottomPopup'; import Image from 'next/image'; @@ -60,7 +54,6 @@ const form: React.FC<FormProps> = ({ const [industries, setIndustries] = useState<industry_id[]>([]); const [companyTypes, setCompanyTypes] = useState<companyType[]>([]); - const router = useRouter(); const toast = useToast(); const emailRef = useRef<HTMLInputElement>(null); diff --git a/src-migrate/modules/register/components/RegistrasiBisnis.tsx b/src-migrate/modules/register/components/RegistrasiBisnis.tsx index ce4d3972..40caed65 100644 --- a/src-migrate/modules/register/components/RegistrasiBisnis.tsx +++ b/src-migrate/modules/register/components/RegistrasiBisnis.tsx @@ -1,19 +1,10 @@ -import { ChangeEvent, useEffect, useMemo, useState } from 'react'; +import { useEffect, useMemo, useState } from 'react'; import FormBisnis from './FormBisnis'; import Form from './Form'; -import TermCondition from './TermCondition'; -import FormCaptcha from './FormCaptcha'; import { Radio, RadioGroup, Stack, Divider, Button } from '@chakra-ui/react'; import React from 'react'; import { ChevronDownIcon, ChevronRightIcon } from '@heroicons/react/24/outline'; import { useRegisterStore } from '../stores/useRegisterStore'; -import { useMutation } from 'react-query'; -import { RegisterProps } from '~/types/auth'; -import { registerUser } from '~/services/auth'; -import router from 'next/router'; -import { useRouter } from 'next/router'; -import { UseToastOptions, useToast } from '@chakra-ui/react'; -import Link from 'next/link'; interface FormProps { chekValid: boolean; buttonSubmitClick: boolean; @@ -28,13 +19,7 @@ const RegistrasiBisnis: React.FC<FormProps> = ({ const [isBisnisClicked, setisBisnisClicked] = useState(true); const [selectedValue, setSelectedValue] = useState('PKP'); const [selectedValueBisnis, setSelectedValueBisnis] = useState('false'); - const { form, isCheckedTNC, isValidCaptcha, errors, validate, updateForm } = - useRegisterStore(); - const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors]); - const toast = useToast(); - const mutation = useMutation({ - mutationFn: (data: RegisterProps) => registerUser(data), - }); + const { validate, updateForm } = useRegisterStore(); useEffect(() => { if (selectedValue === 'PKP') { diff --git a/src-migrate/modules/register/index.tsx b/src-migrate/modules/register/index.tsx index 2cc8a28b..39f4771c 100644 --- a/src-migrate/modules/register/index.tsx +++ b/src-migrate/modules/register/index.tsx @@ -1,20 +1,24 @@ -import PageContent from '~/modules/page-content'; -import RegistrasiIndividu from './components/RegistrasiIndividu'; -import RegistrasiBisnis from './components/RegistrasiBisnis'; +import dynamic from 'next/dynamic'; import Link from 'next/link'; import Image from 'next/image'; -import IndoteknikLogo from '~/images/logo.png'; -import AccountActivation from '../account-activation'; import { useMemo, useState } from 'react'; -import { useRegisterStore } from './stores/useRegisterStore'; -import FormCaptcha from './components/FormCaptcha'; -import TermCondition from './components/TermCondition'; +import { useRouter } from 'next/router'; import { Button } from '@chakra-ui/react'; -import { useMutation } from 'react-query'; import { UseToastOptions, useToast } from '@chakra-ui/react'; -import { RegisterProps } from '~/types/auth'; +import { useMutation } from 'react-query'; +import { useRegisterStore } from './stores/useRegisterStore'; import { registerUser } from '~/services/auth'; -import { useRouter } from 'next/router'; +import IndoteknikLogo from '~/images/logo.png'; +import { RegisterProps } from '~/types/auth'; + +const PageContent = dynamic(() => import('~/modules/page-content')); +const RegistrasiIndividu = dynamic( + () => import('./components/RegistrasiIndividu') +); +const RegistrasiBisnis = dynamic(() => import('./components/RegistrasiBisnis')); +const FormCaptcha = dynamic(() => import('./components/FormCaptcha')); +const TermCondition = dynamic(() => import('./components/TermCondition')); +const AccountActivation = dynamic(() => import('../account-activation')); const LOGO_WIDTH = 150; const LOGO_HEIGHT = LOGO_WIDTH / 3; @@ -47,6 +51,7 @@ const Register = () => { setIsIndividuClicked(false); setIsBisnisClicked(true); }; + const handleSubmit = async () => { if (!isFormValid) { setNotValid(true); @@ -98,10 +103,11 @@ const Register = () => { break; } }; + return ( <div className='container'> <div className='grid grid-cols-1 md:grid-cols-2 gap-x-8 pt-10 px-2 md:pt-16'> - <section className=''> + <section> <div className='px-8 py-4 border'> <Link href='/' className='block md:hidden'> <Image @@ -126,7 +132,7 @@ const Register = () => { </label> <div className='grid grid-cols-2 gap-x-3 mt-2 h-14 font-bold text-black hover:cursor-pointer'> <div - className={` border rounded-md flex justify-center items-center transition-colors duration-300 ease-in-out ${ + className={`border rounded-md flex justify-center items-center transition-colors duration-300 ease-in-out ${ isIndividuClicked ? 'bg-red-500 text-white' : '' }`} onClick={handleIndividuClick} @@ -134,7 +140,7 @@ const Register = () => { <p>Individu</p> </div> <div - className={` border rounded-md flex justify-center items-center transition-colors duration-300 ease-in-out ${ + className={`border rounded-md flex justify-center items-center transition-colors duration-300 ease-in-out ${ isBisnisClicked ? 'bg-red-500 text-white' : '' }`} onClick={handleBisnisClick} @@ -144,20 +150,16 @@ const Register = () => { </div> <div className='transition-opacity duration-300 ease-in-out'> {isIndividuClicked && ( - <div className='opacity-100'> - <RegistrasiIndividu - chekValid={notValid} - buttonSubmitClick={buttonSubmitClick} - /> - </div> + <RegistrasiIndividu + chekValid={notValid} + buttonSubmitClick={buttonSubmitClick} + /> )} {isBisnisClicked && ( - <div className='opacity-100'> - <RegistrasiBisnis - chekValid={notValid} - buttonSubmitClick={buttonSubmitClick} - /> - </div> + <RegistrasiBisnis + chekValid={notValid} + buttonSubmitClick={buttonSubmitClick} + /> )} </div> <section className='mt-2'> diff --git a/src-migrate/validations/auth.ts b/src-migrate/validations/auth.ts index 3abdfb57..8e867ade 100644 --- a/src-migrate/validations/auth.ts +++ b/src-migrate/validations/auth.ts @@ -11,7 +11,7 @@ export const registerSchema = z phone: z .string() .min(1, { message: 'Nomor telepon harus diisi' }) - .refine((val) => /^\d{10,12}$/.test(val), { + .refine((val) => /^\d{9,13}$/.test(val), { message: 'Format nomor telepon tidak valid, contoh: 081234567890', }), type_acc: z.string().optional(), |
