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/core/api/odooApi.js | 11 ++++ src/core/components/elements/Alert/Alert.jsx | 10 ++++ src/core/components/elements/Appbar/Appbar.jsx | 29 +++++------ src/core/components/elements/Divider/Divider.jsx | 8 +++ src/core/components/elements/Image/Image.jsx | 8 +++ src/core/components/elements/Link/Link.jsx | 8 +++ .../components/elements/Navbar/NavbarMobile.jsx | 12 +---- src/core/components/elements/Navbar/Search.jsx | 10 +--- .../components/elements/Pagination/Pagination.js | 5 +- .../components/elements/Skeleton/BrandSkeleton.jsx | 5 +- .../components/elements/Skeleton/ImageSkeleton.jsx | 10 +--- .../elements/Skeleton/ProductCardSkeleton.jsx | 5 +- src/core/hooks/useDevice.js | 1 - src/core/hooks/useSidebar.js | 7 +-- src/core/utils/address.js | 35 +++++++++++-- src/core/utils/auth.js | 20 ++++++-- src/core/utils/cart.js | 41 +++++++++++++-- src/core/utils/currencyFormat.js | 6 +++ src/core/utils/getFileBase64.js | 13 ++++- src/core/utils/greeting.js | 10 ++++ src/core/utils/slug.js | 24 +++++++++ src/core/utils/toTitleCase.js | 9 ++++ 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 +-- src/pages/forgot-password.jsx | 6 ++- src/pages/my/menu.jsx | 20 ++------ src/pages/shop/brands/[slug].jsx | 5 +- src/pages/shop/checkout/[status].jsx | 2 +- src/pages/shop/quotation/finish.jsx | 58 +++++++++++----------- src/pages/shop/search.jsx | 7 +-- src/pages/sitemap/products/[id].xml.js | 2 +- 52 files changed, 359 insertions(+), 319 deletions(-) (limited to 'src') diff --git a/src/core/api/odooApi.js b/src/core/api/odooApi.js index 25ee9adf..fe9fcdd2 100644 --- a/src/core/api/odooApi.js +++ b/src/core/api/odooApi.js @@ -18,6 +18,17 @@ const getToken = async () => { const maxConnectionAttempt = 15 let connectionAttempt = 0 +/** + * The `odooApi` function is used to make API requests to an Odoo backend with customizable parameters such as `method`, `url`, `data`, and `headers`. + * + * @async + * @function + * @param {string} method - HTTP method for the API request (e.g., GET, POST, PUT, DELETE). + * @param {string} url - URL endpoint for the API request. + * @param {Object} data - Data to be sent in the request payload. + * @param {Object} headers - Custom headers to be sent in the request. + * @returns {Promise} - A Promise that resolves to the API response data or an empty array. + */ const odooApi = async (method, url, data = {}, headers = {}) => { connectionAttempt++ try { diff --git a/src/core/components/elements/Alert/Alert.jsx b/src/core/components/elements/Alert/Alert.jsx index 695be8a3..cf84b591 100644 --- a/src/core/components/elements/Alert/Alert.jsx +++ b/src/core/components/elements/Alert/Alert.jsx @@ -1,3 +1,13 @@ +/** + * The Alert component is used to display different types of alerts or notifications + * with different styles based on the provided type prop. + * + * @param {Object} props - Props received by the component. + * @param {ReactNode} props.children - The content to be displayed inside the alert. + * @param {string} props.className - Additional CSS class names for the alert. + * @param {string} props.type - The type of the alert ('info', 'success', or 'warning'). + * @returns {JSX.Element} - Rendered Alert component. + */ const Alert = ({ children, className, type }) => { let typeClass = '' switch (type) { diff --git a/src/core/components/elements/Appbar/Appbar.jsx b/src/core/components/elements/Appbar/Appbar.jsx index 098d0a33..f1456a7c 100644 --- a/src/core/components/elements/Appbar/Appbar.jsx +++ b/src/core/components/elements/Appbar/Appbar.jsx @@ -2,38 +2,33 @@ import { useRouter } from 'next/router' import Link from '../Link/Link' import { HomeIcon, Bars3Icon, ShoppingCartIcon, ChevronLeftIcon } from '@heroicons/react/24/outline' +/** + * The AppBar component is a navigation component used to display a header or toolbar + * in a web application. + * + * @param {Object} props - Props received by the component. + * @param {string} props.title - The title to be displayed on the AppBar. + * @returns {JSX.Element} - Rendered AppBar component. + */ const AppBar = ({ title }) => { const router = useRouter() return (