diff --git a/package-lock.json b/package-lock.json index 9c982d7..00151a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -62,6 +62,7 @@ "stripe": "^14.9.0", "stylis": "^4.3.0", "stylis-plugin-rtl": "^2.1.1", + "uuid": "^11.0.3", "yup": "^1.3.2" }, "devDependencies": { @@ -7902,6 +7903,19 @@ "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==", "license": "ISC" }, + "node_modules/uuid": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.0.3.tgz", + "integrity": "sha512-d0z310fCWv5dJwnX1Y/MncBAqGMKEzlBb1AOf7z9K8ALnd0utBX/msg/fA0+sbyN1ihbMsLhrBlnl1ak7Wa0rg==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/esm/bin/uuid" + } + }, "node_modules/vite-compatible-readable-stream": { "version": "3.6.1", "resolved": "https://registry.npmjs.org/vite-compatible-readable-stream/-/vite-compatible-readable-stream-3.6.1.tgz", diff --git a/package.json b/package.json index bf3e03c..e7ace83 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "stripe": "^14.9.0", "stylis": "^4.3.0", "stylis-plugin-rtl": "^2.1.1", + "uuid": "^11.0.3", "yup": "^1.3.2" }, "devDependencies": { diff --git a/src/components/forms/adminShop.jsx b/src/components/forms/adminShop.jsx index 05c325d..196477d 100644 --- a/src/components/forms/adminShop.jsx +++ b/src/components/forms/adminShop.jsx @@ -4,7 +4,7 @@ import { useMutation } from 'react-query'; import axios from 'axios'; import toast from 'react-hot-toast'; import PropTypes from 'prop-types'; - +import { v4 as uuidv4 } from 'uuid'; // mui import { styled } from '@mui/material/styles'; import { LoadingButton } from '@mui/lab'; @@ -107,7 +107,7 @@ export default function AdminShopForm({ data: currentShop, isLoading: shopLoadin initialValues: { title: currentShop?.title || '', // metaTitle: currentShop?.metaTitle || '', - // cover: currentShop?.cover || null, + cover: currentShop?.cover || null, logo: currentShop?.logo || null, description: currentShop?.description || '', metaDescription: currentShop?.metaDescription || '', @@ -153,6 +153,7 @@ export default function AdminShopForm({ data: currentShop, isLoading: shopLoadin } } }); + console.log('formik', formik); const { errors, values, touched, handleSubmit, setFieldValue, getFieldProps } = formik; // handle drop logo const handleDropLogo = async (acceptedFiles) => { @@ -227,9 +228,12 @@ export default function AdminShopForm({ data: currentShop, isLoading: shopLoadin }); }; const handleTitleChange = (event) => { - const title = event.target.value; - const slug = title.toLowerCase().replace(/\s+/g, '-'); // convert to lowercase, remove special characters, and replace spaces with hyphens - formik.setFieldValue('slug', slug); // set the value of slug in the formik state + // const title = event.target.value; + + // UUID 생성 + const uniqueKey = uuidv4().replaceAll('-', ''); + + formik.setFieldValue('slug', uniqueKey); // 유니크 키를 slug로 설정 formik.handleChange(event); // handle the change in formik }; @@ -311,7 +315,7 @@ export default function AdminShopForm({ data: currentShop, isLoading: shopLoadin {shopLoading ? ( ) : ( - + {' '} {'Slug'} @@ -320,6 +324,7 @@ export default function AdminShopForm({ data: currentShop, isLoading: shopLoadin ) : ( ({ ...theme.typography.subtitle2, color: theme.palette.text.secondary, - lineHeight: 2.5 })); @@ -82,25 +81,25 @@ export default function ProductForm({ const NewProductSchema = Yup.object().shape({ name: Yup.string().required('Product name is required'), code: Yup.string().required('Product code is required'), - tags: Yup.array().min(1, 'Tags is required'), + // tags: Yup.array().min(1, 'Tags is required'), status: Yup.string().required('Status is required'), - description: Yup.string().required('Description is required'), + // description: Yup.string().required('Description is required'), category: Yup.string().required('Category is required'), shop: isVendor ? Yup.string().nullable().notRequired() : Yup.string().required('Shop is required'), subCategory: Yup.string().required('Sub Category is required'), slug: Yup.string().required('Slug is required'), - brand: Yup.string().required('brand is required'), - metaTitle: Yup.string().required('Meta title is required'), - metaDescription: Yup.string().required('Meta description is required'), + // brand: Yup.string().required('brand is required'), + // metaTitle: Yup.string().required('Meta title is required'), + // metaDescription: Yup.string().required('Meta description is required'), images: Yup.array().min(1, 'Images is required'), - sku: Yup.string().required('Sku is required'), - available: Yup.number().required('Quantaty is required'), - colors: Yup.array().required('Color is required'), - sizes: Yup.array().required('Size is required'), - price: Yup.number().required('Price is required'), - priceSale: Yup.number() - .required('Sale price is required') - .lessThan(Yup.ref('price'), 'Sale price should be smaller than price') + // sku: Yup.string().required('Sku is required'), + available: Yup.number().required('Quantaty is required') + // colors: Yup.array().required('Color is required'), + // sizes: Yup.array().required('Size is required') + // price: Yup.number().required('Price is required'), + // priceSale: Yup.number() + // .required('Sale price is required') + // .lessThan(Yup.ref('price'), 'Sale price should be smaller than price') }); const formik = useFormik({ @@ -112,7 +111,7 @@ export default function ProductForm({ slug: currentProduct?.slug || '', metaTitle: currentProduct?.metaTitle || '', metaDescription: currentProduct?.metaDescription || '', - brand: currentProduct?.brand || brands[0]?._id || '', + brand: currentProduct?.brand || brands[0]?._id || 'brand', tags: currentProduct?.tags || [], gender: currentProduct?.gender || '', category: currentProduct?.category || (categories.length && categories[0]?._id) || '', @@ -195,7 +194,7 @@ export default function ProductForm({ const title = event.target.value; const slug = title .toLowerCase() - .replace(/[^a-zA-Z0-9\s]+/g, '') + // .replace(/[^a-zA-Z0-9\s]+/g, '') .replace(/\s+/g, '-'); // convert to lowercase, remove special characters, and replace spaces with hyphens formik.setFieldValue('slug', slug); // set the value of slug in the formik state formik.handleChange(event); // handle the change in formik diff --git a/src/components/forms/subCategory.jsx b/src/components/forms/subCategory.jsx index e8192c4..487cfff 100644 --- a/src/components/forms/subCategory.jsx +++ b/src/components/forms/subCategory.jsx @@ -94,9 +94,9 @@ export default function SubCategoryForm({ name: Yup.string().required('Name is required'), cover: Yup.mixed().required('Cover is required'), slug: Yup.string().required('Slug is required'), - description: Yup.string().required('Description is required'), - metaTitle: Yup.string().required('Meta title is required'), - metaDescription: Yup.string().required('Meta description is required'), + // description: Yup.string().required('Description is required'), + // metaTitle: Yup.string().required('Meta title is required'), + // metaDescription: Yup.string().required('Meta description is required'), parentCategory: Yup.string().required('Category is required') }); diff --git a/src/components/table/rows/brand.jsx b/src/components/table/rows/brand.jsx index 6a7097b..ceb5d7d 100644 --- a/src/components/table/rows/brand.jsx +++ b/src/components/table/rows/brand.jsx @@ -68,12 +68,13 @@ export default function BrandsRow({ isLoading, row, handleClickOpen }) { {isLoading ? ( ) : ( - + // + capitalize(row?.status) )} {isLoading ? : <> {fDateShort(row.createdAt)} } diff --git a/src/components/table/rows/category.jsx b/src/components/table/rows/category.jsx index 455f2b6..b269ac9 100644 --- a/src/components/table/rows/category.jsx +++ b/src/components/table/rows/category.jsx @@ -82,12 +82,13 @@ export default function Category({ isLoading, row, handleClickOpen }) { {isLoading ? ( ) : ( - + // + capitalize(row?.status) )} {isLoading ? : <> {fDateShort(row.createdAt)} } diff --git a/src/components/table/rows/product.jsx b/src/components/table/rows/product.jsx index 4462243..177100b 100644 --- a/src/components/table/rows/product.jsx +++ b/src/components/table/rows/product.jsx @@ -80,19 +80,22 @@ export default function ProductRow({ isLoading, row, handleClickOpen, isVendor } {isLoading ? ( ) : ( - + // + (row?.available < 1 && '재고 없음') || + (row?.available < 20 && '재고 부족') || + (row?.available >= 20 && '재고 있음') )} diff --git a/src/components/table/rows/subCategory.jsx b/src/components/table/rows/subCategory.jsx index 10db8fb..dd84743 100644 --- a/src/components/table/rows/subCategory.jsx +++ b/src/components/table/rows/subCategory.jsx @@ -80,12 +80,13 @@ export default function Category({ isLoading, row, handleClickOpen }) { {isLoading ? ( ) : ( - + // + capitalize(row?.status) )} {isLoading ? : <> {fDateShort(row.createdAt)} } diff --git a/src/layout/_admin/sidebar/index.jsx b/src/layout/_admin/sidebar/index.jsx index 3695ddc..04b467a 100644 --- a/src/layout/_admin/sidebar/index.jsx +++ b/src/layout/_admin/sidebar/index.jsx @@ -23,7 +23,7 @@ import MuiDrawer from '@mui/material/Drawer'; // icons import { IoIosArrowBack, IoIosArrowForward } from 'react-icons/io'; import { LuLayoutDashboard } from 'react-icons/lu'; -// import { FaRegBuilding } from 'react-icons/fa'; +import { FaRegBuilding } from 'react-icons/fa'; import { TbCategory2 } from 'react-icons/tb'; import { BsShop } from 'react-icons/bs'; import { BsCart3 } from 'react-icons/bs'; @@ -61,13 +61,13 @@ export const navlinks = [ icon: , isSearch: true }, - // { - // id: 3, - // title: 'Brands', - // slug: 'brands', - // icon: , - // isSearch: true - // }, + { + id: 3, + title: 'Brands', + slug: 'brands', + icon: , + isSearch: true + }, { id: 4, title: 'Products',