From 92c2a229d9c9b510d71b928978872a8b107e9d5a Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 11 Apr 2023 09:47:25 +0700 Subject: Documentation and refactor code --- src/lib/address/components/Addresses.jsx | 5 ++- src/lib/address/components/EditAddress.jsx | 2 +- src/lib/auth/components/Activate.jsx | 52 ++++++---------------- src/lib/auth/components/CompanyProfile.jsx | 37 +++------------ src/lib/auth/components/Login.jsx | 4 +- src/lib/auth/components/PersonalProfile.jsx | 32 +++---------- src/lib/auth/components/RegisterDesktop.jsx | 20 +++++++-- src/lib/auth/components/RegisterMobile.jsx | 2 +- src/lib/auth/hooks/useRegister.js | 2 +- src/lib/brand/components/BrandCard.jsx | 9 ++-- src/lib/cart/components/Cart.jsx | 24 ++++++---- src/lib/checkout/components/Checkout.jsx | 4 +- src/lib/content/components/PageContent.jsx | 2 +- src/lib/home/components/PopularProduct.jsx | 15 ++----- src/lib/home/components/PreferredBrand.jsx | 11 +---- src/lib/invoice/components/Invoice.jsx | 2 +- src/lib/product/api/productSearchApi.js | 4 +- .../product/components/Product/ProductMobile.jsx | 8 ++-- src/lib/product/components/ProductFilter.jsx | 22 ++------- src/lib/product/components/ProductSearch.jsx | 14 +++--- src/lib/product/components/ProductSlider.jsx | 10 +---- src/lib/transaction/components/Transaction.jsx | 4 +- src/lib/variant/components/VariantGroupCard.jsx | 6 +-- 23 files changed, 104 insertions(+), 187 deletions(-) (limited to 'src/lib') diff --git a/src/lib/address/components/Addresses.jsx b/src/lib/address/components/Addresses.jsx index db338983..a610d371 100644 --- a/src/lib/address/components/Addresses.jsx +++ b/src/lib/address/components/Addresses.jsx @@ -61,7 +61,10 @@ const Addresses = () => {

Daftar Alamat

- + Tambah Alamat
diff --git a/src/lib/address/components/EditAddress.jsx b/src/lib/address/components/EditAddress.jsx index 30555ecd..520bba51 100644 --- a/src/lib/address/components/EditAddress.jsx +++ b/src/lib/address/components/EditAddress.jsx @@ -197,7 +197,7 @@ const EditAddress = ({ id, defaultValues }) => { )} /> -
{errors.district?.message}
+
{errors.district?.message}
diff --git a/src/lib/auth/components/Activate.jsx b/src/lib/auth/components/Activate.jsx index 717e178b..c81bcbbd 100644 --- a/src/lib/auth/components/Activate.jsx +++ b/src/lib/auth/components/Activate.jsx @@ -27,10 +27,7 @@ const Activate = () => { children: ( <> Selamat, akun anda berhasil diaktifkan,{' '} - + kembali ke beranda . @@ -43,10 +40,7 @@ const Activate = () => { children: ( <> Mohon maaf token sudah tidak aktif, lakukan permintaan aktivasi akun kembali atau{' '} - + masuk {' '} jika sudah memiliki akun. @@ -67,9 +61,12 @@ const Activate = () => { const activationRequest = async (e) => { e.preventDefault() setIsLoading(true) - let activationRequest = await axios.post(`${process.env.NEXT_PUBLIC_SELF_HOST}/api/activation-request`, { - email - }) + let activationRequest = await axios.post( + `${process.env.NEXT_PUBLIC_SELF_HOST}/api/activation-request`, + { + email + } + ) if (activationRequest.data.activationRequest) { setAlert({ children: <>Mohon cek email anda untuk aktivasi akun Indoteknik, @@ -82,10 +79,7 @@ const Activate = () => { children: ( <> Email tersebut belum terdaftar,{' '} - + daftar sekarang . @@ -99,10 +93,7 @@ const Activate = () => { children: ( <> Email tersebut sudah terdaftar dan sudah aktif,{' '} - + masuk sekarang . @@ -119,29 +110,18 @@ const Activate = () => { return (
- Logo Indoteknik + Logo Indoteknik

Aktivasi Akun Indoteknik

{alert && ( - + {alert.children} )} -
+ { placeholder='Masukan alamat email' autoFocus /> -
diff --git a/src/lib/auth/components/CompanyProfile.jsx b/src/lib/auth/components/CompanyProfile.jsx index 1b25551e..854aa246 100644 --- a/src/lib/auth/components/CompanyProfile.jsx +++ b/src/lib/auth/components/CompanyProfile.jsx @@ -69,11 +69,7 @@ const CompanyProfile = () => { return ( <> - diff --git a/src/lib/auth/components/Login.jsx b/src/lib/auth/components/Login.jsx index 171ff4c8..cbcfd07b 100644 --- a/src/lib/auth/components/Login.jsx +++ b/src/lib/auth/components/Login.jsx @@ -1,5 +1,5 @@ -import LoginDesktop from "./LoginDesktop" -import LoginMobile from "./LoginMobile" +import LoginDesktop from './LoginDesktop' +import LoginMobile from './LoginMobile' const Login = () => { return ( diff --git a/src/lib/auth/components/PersonalProfile.jsx b/src/lib/auth/components/PersonalProfile.jsx index 4f606ed4..4a533ae9 100644 --- a/src/lib/auth/components/PersonalProfile.jsx +++ b/src/lib/auth/components/PersonalProfile.jsx @@ -34,7 +34,7 @@ const PersonalProfile = () => { let data = values if (!values.password) delete data.password const isUpdated = await editPersonalProfileApi({ data }) - + if (isUpdated?.user) { setAuth(isUpdated.user) setValue('password', '') @@ -47,11 +47,7 @@ const PersonalProfile = () => { return ( <> - diff --git a/src/lib/auth/components/RegisterDesktop.jsx b/src/lib/auth/components/RegisterDesktop.jsx index ac6ac960..482a9ce3 100644 --- a/src/lib/auth/components/RegisterDesktop.jsx +++ b/src/lib/auth/components/RegisterDesktop.jsx @@ -89,9 +89,19 @@ const RegisterDesktop = () => { placeholder='••••••••••••' />
-
- - +
+ +
@@ -465,7 +472,7 @@ const Cart = () => {
-

Product Yang Mungkin Kamu Suka

+

Product Yang Mungkin Kamu Suka

{productRecomendation && productRecomendation.response.products.map((product) => ( @@ -474,7 +481,6 @@ const Cart = () => {
- ) diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 96f2f161..cb96b995 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -444,9 +444,7 @@ const PickupAddress = ({ label }) => (

Telp : 021-2933 8828/29

Mobile : 0813 9000 7430

-

- *) Belum termasuk biaya pengiriman -

+

*) Belum termasuk biaya pengiriman

) diff --git a/src/lib/content/components/PageContent.jsx b/src/lib/content/components/PageContent.jsx index 8b07cbfb..61e5381d 100644 --- a/src/lib/content/components/PageContent.jsx +++ b/src/lib/content/components/PageContent.jsx @@ -5,7 +5,7 @@ import Spinner from '@/core/components/elements/Spinner/Spinner' const PageContent = ({ path }) => { const fetchContent = async () => await pageContentApi({ path }) const content = useQuery(`content-${path}`, fetchContent) - + if (content.data?.id) { let parsedContent = content.data.content parsedContent = parsedContent.replaceAll( diff --git a/src/lib/home/components/PopularProduct.jsx b/src/lib/home/components/PopularProduct.jsx index 78dc5d49..3ce7527e 100644 --- a/src/lib/home/components/PopularProduct.jsx +++ b/src/lib/home/components/PopularProduct.jsx @@ -15,10 +15,7 @@ const PopularProduct = () => {
Produk Banyak Dilihat
{popularProducts.isLoading && } {!popularProducts.isLoading && ( - + )} @@ -31,14 +28,8 @@ const PopularProduct = () => {
{popularProducts.data && popularProducts.data.products.map((product) => ( -
- +
+
))}
diff --git a/src/lib/home/components/PreferredBrand.jsx b/src/lib/home/components/PreferredBrand.jsx index 7edd0730..f97943cb 100644 --- a/src/lib/home/components/PreferredBrand.jsx +++ b/src/lib/home/components/PreferredBrand.jsx @@ -14,21 +14,14 @@ const PreferredBrand = () => {
Brand Pilihan
{isDesktop && ( - + Lihat Semua )}
{preferredBrands.isLoading && } {!preferredBrands.isLoading && ( - + {preferredBrands.data?.manufactures.map((brand) => ( diff --git a/src/lib/invoice/components/Invoice.jsx b/src/lib/invoice/components/Invoice.jsx index 7559779b..81202b1c 100644 --- a/src/lib/invoice/components/Invoice.jsx +++ b/src/lib/invoice/components/Invoice.jsx @@ -254,7 +254,7 @@ const Invoice = ({ id }) => {
{currencyFormat(invoice.data?.amountTotal)}
- +
PPN 11% (Incl.)
{currencyFormat(totalAmount * 0.11)}
diff --git a/src/lib/product/api/productSearchApi.js b/src/lib/product/api/productSearchApi.js index f626e8cc..71fb72e6 100644 --- a/src/lib/product/api/productSearchApi.js +++ b/src/lib/product/api/productSearchApi.js @@ -2,7 +2,9 @@ import _ from 'lodash-contrib' import axios from 'axios' const productSearchApi = async ({ query }) => { - const dataProductSearch = await axios(`${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/search?${query}&operation=OR`) + const dataProductSearch = await axios( + `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/search?${query}&operation=OR` + ) return dataProductSearch.data } diff --git a/src/lib/product/components/Product/ProductMobile.jsx b/src/lib/product/components/Product/ProductMobile.jsx index 19b4c4b2..1194419e 100644 --- a/src/lib/product/components/Product/ProductMobile.jsx +++ b/src/lib/product/components/Product/ProductMobile.jsx @@ -130,9 +130,11 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => {

{activeVariant?.name}

- {product.variants.length > 1 && activeVariant.price.priceDiscount > 0 && !selectedVariant && ( -
Harga mulai dari:
- )} + {product.variants.length > 1 && + activeVariant.price.priceDiscount > 0 && + !selectedVariant && ( +
Harga mulai dari:
+ )} {activeVariant?.price?.discountPercentage > 0 && (
diff --git a/src/lib/product/components/ProductFilter.jsx b/src/lib/product/components/ProductFilter.jsx index be1edd18..34357526 100644 --- a/src/lib/product/components/ProductFilter.jsx +++ b/src/lib/product/components/ProductFilter.jsx @@ -35,11 +35,7 @@ const ProductFilter = ({ active, close, brands, categories, prefixUrl, defaultBr } return ( - +
{!defaultBrand && (
@@ -52,10 +48,7 @@ const ProductFilter = ({ active, close, brands, categories, prefixUrl, defaultBr > {brands.map((brand, index) => ( - ))} @@ -72,10 +65,7 @@ const ProductFilter = ({ active, close, brands, categories, prefixUrl, defaultBr > {categories.map((category, index) => ( - ))} @@ -117,11 +107,7 @@ const ProductFilter = ({ active, close, brands, categories, prefixUrl, defaultBr />
-
diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx index 0010a88a..81e7948b 100644 --- a/src/lib/product/components/ProductSearch.jsx +++ b/src/lib/product/components/ProductSearch.jsx @@ -26,13 +26,15 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { ) const productStart = productSearch.data?.responseHeader.params.start const productRows = productSearch.data?.responseHeader.params.rows - const productFound = productSearch.data?.response.numFound - - const brands = productSearch.data?.facetCounts?.facetFields?.manufactureName?.filter((value, index) => { - if (index % 2 === 0) { - return true + const productFound = productSearch.data?.response.numFound + + const brands = productSearch.data?.facetCounts?.facetFields?.manufactureName?.filter( + (value, index) => { + if (index % 2 === 0) { + return true + } } - }) + ) const categories = productSearch.data?.facetCounts?.facetFields?.categoryName?.filter( (value, index) => { if (index % 2 === 0) { diff --git a/src/lib/product/components/ProductSlider.jsx b/src/lib/product/components/ProductSlider.jsx index ed7db486..c8bd3a82 100644 --- a/src/lib/product/components/ProductSlider.jsx +++ b/src/lib/product/components/ProductSlider.jsx @@ -44,18 +44,12 @@ const ProductSlider = ({ products, simpleTitle = false, bannerMode = false }) => > {bannerMode && ( - + )} {products?.products?.map((product, index) => ( - + ))} diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index 7dfb13fb..b4e050c6 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -426,7 +426,9 @@ const Transaction = ({ id }) => {
PPN 11%
-
{currencyFormat(transaction.data?.amountTax)}
+
+ {currencyFormat(transaction.data?.amountTax)} +
Grand Total
diff --git a/src/lib/variant/components/VariantGroupCard.jsx b/src/lib/variant/components/VariantGroupCard.jsx index e5f5c7fc..8cb1eec4 100644 --- a/src/lib/variant/components/VariantGroupCard.jsx +++ b/src/lib/variant/components/VariantGroupCard.jsx @@ -8,11 +8,7 @@ const VariantGroupCard = ({ variants, ...props }) => { return ( <> {variantsToShow?.map((variant, index) => ( - + ))} {variants.length > 2 && (