From ddb82d97f794d59d846aa9b7c3d1dd1eff9cb9a9 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Fri, 29 Nov 2024 16:31:58 +0700 Subject: ppn 12 persen --- src-migrate/modules/cart/components/Summary.tsx | 3 ++- src-migrate/modules/cart/stores/useCartStore.ts | 14 +++++++++----- .../modules/product-card/components/ProductCard.tsx | 3 ++- .../modules/product-detail/components/PriceAction.tsx | 3 ++- src/lib/checkout/components/Checkout.jsx | 5 +++-- 5 files changed, 18 insertions(+), 10 deletions(-) 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 ( <>
Ringkasan Pesanan
@@ -50,7 +51,7 @@ const CartSummary = ({ - Tax 11% + Tax {((PPN - 1) * 100).toFixed(0)}% Rp {formatCurrency(tax || 0)} 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((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) => {
Inc PPN: Rp{' '} - {formatCurrency(Math.round(product.lowest_price.price * 1.11))} + {formatCurrency(Math.round(product.lowest_price.price * PPN))}
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) => {
Termasuk PPN: Rp{' '} - {formatCurrency(Math.round(activePrice.price_discount * 1.11))} + {formatCurrency(Math.round(activePrice.price_discount * PPN))}
)} diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 6fb5cdb4..4e182745 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -50,6 +50,7 @@ function convertToInternational(number) { } const Checkout = () => { + const PPN = process.env.NEXT_PUBLIC_PPN ? parseFloat(process.env.NEXT_PUBLIC_PPN) : 0; const router = useRouter(); const query = router.query.source ?? null; const qVoucher = router.query.voucher ?? null; @@ -1210,7 +1211,7 @@ const Checkout = () => {
{currencyFormat(cartCheckout?.subtotal)}
-
PPN 11%
+
PPN {((PPN - 1) * 100).toFixed(0)}%
{currencyFormat(cartCheckout?.tax)}
@@ -1514,7 +1515,7 @@ const Checkout = () => {
{currencyFormat(cartCheckout?.subtotal)}
-
PPN 11%
+
PPN {((PPN - 1) * 100).toFixed(0)}%
{currencyFormat(cartCheckout?.tax)}
-- cgit v1.2.3 From 10cd02d6fcc39c75b8db19a874cc0ba49b890376 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 9 Dec 2024 15:48:36 +0700 Subject: add dynamic to call component --- .../modules/register/components/FormBisnis.tsx | 7 --- .../register/components/RegistrasiBisnis.tsx | 19 +------- src-migrate/modules/register/index.tsx | 54 +++++++++++----------- 3 files changed, 30 insertions(+), 50 deletions(-) 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 = ({ const [industries, setIndustries] = useState([]); const [companyTypes, setCompanyTypes] = useState([]); - const router = useRouter(); const toast = useToast(); const emailRef = useRef(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 = ({ 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 da41fd8b..0308e397 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 (
-
+
{
{

Individu

{
{isIndividuClicked && ( -
- -
+ )} {isBisnisClicked && ( -
- -
+ )}
-- cgit v1.2.3 From b3be7e6d5c320764ef3ca38df196218abf9be25b Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 10 Dec 2024 10:05:47 +0700 Subject: move formulis & add state field --- .../components/elements/Footer/BasicFooter.jsx | 10 +- src/lib/form/components/KunjunganSales.jsx | 215 ++++++++---- src/lib/form/components/KunjunganService.jsx | 361 +++++++++++++-------- src/lib/form/components/Merchant.jsx | 56 +++- src/lib/form/components/RequestForQuotation.jsx | 215 ++++++++---- src/lib/form/components/SuratDukungan.jsx | 33 +- src/pages/daftar-merchant.jsx | 15 + src/pages/kunjungan-sales.jsx | 15 + src/pages/kunjungan-service.jsx | 15 + src/pages/my/daftar-merchant.jsx | 15 - src/pages/my/kunjungan-sales.jsx | 15 - src/pages/my/kunjungan-service.jsx | 15 - src/pages/my/request-for-quotation.jsx | 15 - src/pages/my/surat-dukungan.jsx | 16 - src/pages/request-for-quotation.jsx | 15 + src/pages/surat-dukungan.jsx | 16 + 16 files changed, 650 insertions(+), 392 deletions(-) create mode 100644 src/pages/daftar-merchant.jsx create mode 100644 src/pages/kunjungan-sales.jsx create mode 100644 src/pages/kunjungan-service.jsx delete mode 100644 src/pages/my/daftar-merchant.jsx delete mode 100644 src/pages/my/kunjungan-sales.jsx delete mode 100644 src/pages/my/kunjungan-service.jsx delete mode 100644 src/pages/my/request-for-quotation.jsx delete mode 100644 src/pages/my/surat-dukungan.jsx create mode 100644 src/pages/request-for-quotation.jsx create mode 100644 src/pages/surat-dukungan.jsx diff --git a/src/core/components/elements/Footer/BasicFooter.jsx b/src/core/components/elements/Footer/BasicFooter.jsx index 05dc4d8c..c1e0f21f 100644 --- a/src/core/components/elements/Footer/BasicFooter.jsx +++ b/src/core/components/elements/Footer/BasicFooter.jsx @@ -224,17 +224,17 @@ const Form = () => (
Formulir
  • - + Request for Quotation
  • - + Kunjungan Sales
  • - + Kunjungan Service
  • @@ -244,12 +244,12 @@ const Form = () => (
  • - + Surat Dukungan
  • - + Daftar Merchant
  • diff --git a/src/lib/form/components/KunjunganSales.jsx b/src/lib/form/components/KunjunganSales.jsx index ffa8f135..3779b836 100644 --- a/src/lib/form/components/KunjunganSales.jsx +++ b/src/lib/form/components/KunjunganSales.jsx @@ -1,17 +1,18 @@ -import odooApi from '@/core/api/odooApi' -import HookFormSelect from '@/core/components/elements/Select/HookFormSelect' -import cityApi from '@/lib/address/api/cityApi' -import { yupResolver } from '@hookform/resolvers/yup' -import React, { useEffect, useRef, useState } from 'react' -import ReCAPTCHA from 'react-google-recaptcha' -import { Controller, useForm } from 'react-hook-form' -import { toast } from 'react-hot-toast' -import * as Yup from 'yup' -import createLeadApi from '../api/createLeadApi' -import PageContent from '@/lib/content/components/PageContent' - -import useAuth from '@/core/hooks/useAuth' -import { useRouter } from 'next/router' +import odooApi from '@/core/api/odooApi'; +import HookFormSelect from '@/core/components/elements/Select/HookFormSelect'; +import cityApi from '@/lib/address/api/cityApi'; +import stateApi from '@/lib/address/api/stateApi.js'; +import { yupResolver } from '@hookform/resolvers/yup'; +import React, { useEffect, useRef, useState } from 'react'; +import ReCAPTCHA from 'react-google-recaptcha'; +import { Controller, useForm } from 'react-hook-form'; +import { toast } from 'react-hot-toast'; +import * as Yup from 'yup'; +import createLeadApi from '../api/createLeadApi'; +import PageContent from '@/lib/content/components/PageContent'; + +import useAuth from '@/core/hooks/useAuth'; +import { useRouter } from 'next/router'; const KunjunganSales = () => { const { @@ -19,44 +20,72 @@ const KunjunganSales = () => { handleSubmit, formState: { errors }, control, - reset + reset, + watch, + setValue, } = useForm({ resolver: yupResolver(validationSchema), - defaultValues - }) - const [cities, setCities] = useState([]) - const [companyTypes, setCompanyTypes] = useState([]) - const router = useRouter() + defaultValues, + }); + const [cities, setCities] = useState([]); + const [state, setState] = useState([]); + const [companyTypes, setCompanyTypes] = useState([]); + const router = useRouter(); + + const auth = useAuth(); - const auth = useAuth() + const recaptchaRef = useRef(null); - + if (auth == false) { + router.push(`/login?next=${encodeURIComponent('/kunjungan-sales')}`); + } + + useEffect(() => { + const loadState = async () => { + let dataState = await stateApi(); + dataState = dataState.map((state) => ({ + value: state.id, + label: state.name, + })); + setState(dataState); + }; + loadState(); + }, []); - const recaptchaRef = useRef(null) + const watchState = watch('state'); useEffect(() => { - if(auth == false) { - router.push('/login') + if (auth == false) { + return; } const loadCities = async () => { - let dataCities = await cityApi() - dataCities = dataCities.map((obj) => ({ value: obj.name, label: obj.name })) - setCities(dataCities) - } + setValue('city', ''); + let dataCities = await cityApi({ stateId: watchState }); + dataCities = dataCities?.map((obj) => ({ + value: obj.name, + label: obj.name, + })); + setCities(dataCities); + }; const loadCompanyTypes = async () => { - const dataCompanyTypes = await odooApi('GET', '/api/v1/partner/company_type') - setCompanyTypes(dataCompanyTypes?.map((obj) => ({ value: obj.name, label: obj.name }))) - } + const dataCompanyTypes = await odooApi( + 'GET', + '/api/v1/partner/company_type' + ); + setCompanyTypes( + dataCompanyTypes?.map((obj) => ({ value: obj.name, label: obj.name })) + ); + }; - loadCompanyTypes() - loadCities() - }, [auth]) + loadCompanyTypes(); + loadCities(); + }, [auth, watchState, setValue]); const onSubmitHandler = async (values) => { - const recaptchaValue = recaptchaRef.current.getValue() + const recaptchaValue = recaptchaRef.current.getValue(); if (!recaptchaValue) { - toast.error('Recaptcha harus diisi') - return + toast.error('Recaptcha harus diisi'); + return; } const data = { @@ -71,29 +100,37 @@ const KunjunganSales = () => { `Unit Perusahaan: ${values.companyType}`, `No. Handphone: ${values.mobile}`, `Alamat Email: ${values.email}`, - `Keterangan: ${values.description}` - ].join('\n') - } + `Keterangan: ${values.description}`, + ].join('\n'), + }; - const createLead = await createLeadApi({ data }) + const createLead = await createLeadApi({ data }); if (createLead) { - toast.success('Berhasil mengirimkan formulir kunjungan sales') - reset() - recaptchaRef.current.reset() + toast.success('Berhasil mengirimkan formulir kunjungan sales'); + reset(); + recaptchaRef.current.reset(); } + }; + if (!auth) { + return; } return (
    -

    Kunjungan Sales

    +

    + Kunjungan Sales +

    -
    +
    - Hubungi kami untuk mendapatkan kunjungan sales kami dan dapatkan berbagai kelebihannya - dengan menjadi pelanggan korporat kami. + Hubungi kami untuk mendapatkan kunjungan sales kami dan dapatkan + berbagai kelebihannya dengan menjadi pelanggan korporat kami.
    @@ -104,7 +141,9 @@ const KunjunganSales = () => { className='form-input' aria-invalid={errors.company?.message} /> -
    {errors.company?.message}
    +
    + {errors.company?.message} +
    @@ -116,7 +155,9 @@ const KunjunganSales = () => { className='form-input' aria-invalid={errors.phone?.message} /> -
    {errors.phone?.message}
    +
    + {errors.phone?.message} +
    @@ -128,7 +169,21 @@ const KunjunganSales = () => { className='form-input' aria-invalid={errors.address?.message} /> -
    {errors.address?.message}
    +
    + {errors.address?.message} +
    +
    + +
    + + } + /> +
    + {errors.stateId?.message} +
    @@ -138,7 +193,9 @@ const KunjunganSales = () => { control={control} render={(props) => } /> -
    {errors.city?.message}
    +
    + {errors.city?.message} +
    @@ -146,9 +203,13 @@ const KunjunganSales = () => { } + render={(props) => ( + + )} /> -
    {errors.companyType?.message}
    +
    + {errors.companyType?.message} +
    @@ -160,7 +221,9 @@ const KunjunganSales = () => { className='form-input' aria-invalid={errors.mobile?.message} /> -
    {errors.mobile?.message}
    +
    + {errors.mobile?.message} +
    @@ -172,34 +235,49 @@ const KunjunganSales = () => { className='form-input' aria-invalid={errors.email?.message} /> -
    {errors.email?.message}
    +
    + {errors.email?.message} +
    -