From 92f12436bf8519f2c40598a8d74bd852edb40524 Mon Sep 17 00:00:00 2001 From: sina_sajjadi Date: Wed, 22 Jan 2025 13:46:51 +0330 Subject: [PATCH] feat: update site URL in environment config, adjust routing for shop visits, and modify shop validation schema --- .env | 2 +- src/components/shop/shop-form.tsx | 7 +- src/components/shop/shop-validation-schema.ts | 4 - src/config/routes.ts | 2 +- src/data/client/curd-factory.ts | 3 + src/pages/shop/index.tsx | 5 +- src/settings/site.settings.ts | 408 +++++++++--------- 7 files changed, 216 insertions(+), 215 deletions(-) diff --git a/.env b/.env index 517636e..d20c936 100644 --- a/.env +++ b/.env @@ -4,7 +4,7 @@ NEXT_PUBLIC_AVAILABLE_LANGUAGES=en NEXT_PUBLIC_ENABLE_MULTI_LANG=true NODE_ENV=production NEXT_PUBLIC_REST_API_ENDPOINT=https://mesbahi.nwhco.ir/api -NEXT_PUBLIC_SITE_URL=https://mesbahi.nwhco.ir:3000/ +NEXT_PUBLIC_SITE_URL=https://mesbahi.nwhco.ir/ # NEXT_PUBLIC_BASE_PATH: '/dashboard' NEXT_PUBLIC_AUTH_TOKEN_KEY=AUTH_CRED diff --git a/src/components/shop/shop-form.tsx b/src/components/shop/shop-form.tsx index 7c908d9..dcfcec9 100644 --- a/src/components/shop/shop-form.tsx +++ b/src/components/shop/shop-form.tsx @@ -250,7 +250,8 @@ const ShopForm = ({ initialValues }: { initialValues?: Shop }) => { return true; }; - + console.log(errors); + return ( <>
@@ -506,14 +507,14 @@ const ShopForm = ({ initialValues }: { initialValues?: Shop }) => { control={control} error={t(errors.phone_number?.message!)} /> - + /> */} diff --git a/src/components/shop/shop-validation-schema.ts b/src/components/shop/shop-validation-schema.ts index 82c5e1a..ee01b84 100644 --- a/src/components/shop/shop-validation-schema.ts +++ b/src/components/shop/shop-validation-schema.ts @@ -31,10 +31,6 @@ export const shopValidationSchema = yup.object().shape({ .string() .required('form:error-contact-number-required') .matches(phoneRegExp, 'form:error-contact-number-valid-required'), - website: yup - .string() - .required('form:error-website-required') - .matches(URLRegExp, 'form:error-url-valid-required'), shopMaintenance: yup .object() .when('isShopUnderMaintenance', { diff --git a/src/config/routes.ts b/src/config/routes.ts index f937e9c..e06e1c8 100644 --- a/src/config/routes.ts +++ b/src/config/routes.ts @@ -156,7 +156,7 @@ export const Routes = { : `/${language}/products/${slug}/translate`; }, }, - visitStore: (slug: string) => `${process.env.NEXT_PUBLIC_SHOP_URL}/shops/${slug}`, + visitStore: (slug: string) => `${process.env.NEXT_PUBLIC_SITE_URL}/shops/${slug}`, vendorRequestForFlashSale: { ...routesFactory('/flash-sale/vendor-request'), }, diff --git a/src/data/client/curd-factory.ts b/src/data/client/curd-factory.ts index 3c5828f..d02e17a 100644 --- a/src/data/client/curd-factory.ts +++ b/src/data/client/curd-factory.ts @@ -20,7 +20,10 @@ export function crudFactory( return HttpClient.get(`${endpoint}/${slug}`, { language }); }, create(data: InputType) { + console.log(endpoint , "out if"); if (endpoint === API_ENDPOINTS.SHOPS) { + console.log(endpoint , "in if"); + return HttpClient.post(API_ENDPOINTS.SHOPS, data); } diff --git a/src/pages/shop/index.tsx b/src/pages/shop/index.tsx index c0ffecb..dc3d710 100644 --- a/src/pages/shop/index.tsx +++ b/src/pages/shop/index.tsx @@ -1,7 +1,8 @@ import { EditFillIcon } from '@/components/icons/edit'; import { MapPinIconWithPlatform } from '@/components/icons/map-pin'; import { PhoneIconNew } from '@/components/icons/phone'; -import ShopLayout from '@/components/layouts/shop'; +import Layout from '@/components/layouts/admin'; + import ErrorMessage from '@/components/ui/error-message'; import Loader from '@/components/ui/loader/loader'; import { Routes } from '@/config/routes'; @@ -294,7 +295,7 @@ export default function ShopPage() { ); } -ShopPage.Layout = ShopLayout; +ShopPage.Layout = Layout; // ShopPage.authenticate = { // permissions: adminOwnerAndStaffOnly, // }; diff --git a/src/settings/site.settings.ts b/src/settings/site.settings.ts index 767a467..a087a7d 100644 --- a/src/settings/site.settings.ts +++ b/src/settings/site.settings.ts @@ -180,26 +180,26 @@ export const siteSettings = { label: 'text-inventory', icon: 'InventoryIcon', }, - { - href: Routes.type.list, - label: 'text-groups', - icon: 'HomeIcon', - }, + // { + // href: Routes.type.list, + // label: 'text-groups', + // icon: 'HomeIcon', + // }, { href: Routes.category.list, label: 'sidebar-nav-item-categories', icon: 'CategoriesIcon', }, - { - href: Routes.tag.list, - label: 'sidebar-nav-item-tags', - icon: 'TagIcon', - }, - { - href: Routes.attribute.list, - label: 'sidebar-nav-item-attributes', - icon: 'AttributeIcon', - }, + // { + // href: Routes.tag.list, + // label: 'sidebar-nav-item-tags', + // icon: 'TagIcon', + // }, + // { + // href: Routes.attribute.list, + // label: 'sidebar-nav-item-attributes', + // icon: 'AttributeIcon', + // }, // { // href: Routes.manufacturer.list, // label: 'sidebar-nav-item-manufacturers', @@ -223,21 +223,21 @@ export const siteSettings = { label: 'sidebar-subscription', icon: 'TaxesIcon', }, - { - href: Routes.tax.list, - label: 'sidebar-nav-item-taxes', - icon: 'TaxesIcon', - }, + // { + // href: Routes.tax.list, + // label: 'sidebar-nav-item-taxes', + // icon: 'TaxesIcon', + // }, { href: Routes.shipping.list, label: 'sidebar-nav-item-shippings', icon: 'ShippingsIcon', }, - { - href: Routes.withdraw.list, - label: 'sidebar-nav-item-withdraws', - icon: 'WithdrawIcon', - }, + // { + // href: Routes.withdraw.list, + // label: 'sidebar-nav-item-withdraws', + // icon: 'WithdrawIcon', + // }, // { // href: '', // label: 'sidebar-nav-item-refunds', @@ -283,78 +283,6 @@ export const siteSettings = { label: 'sidebar-nav-item-orders', icon: 'OrdersIcon', }, - { - href: Routes.order.create, - label: 'sidebar-nav-item-create-order', - icon: 'CreateOrderIcon', - }, - { - href: Routes.transaction, - label: 'text-transactions', - icon: 'TransactionsIcon', - }, - // { - // href: '', - // label: 'Order tracking', - // icon: 'OrderTrackingIcon', - // }, - // { - // href: '', - // label: 'Delivery policies', - // icon: 'ShippingsIcon', - // }, - // { - // href: '', - // label: 'Cancelation policies', - // icon: 'CancelationIcon', - // }, - ], - }, - - layout: { - href: '', - label: 'text-page-control', - icon: 'SettingsIcon', - childMenu: [ - { - href: '', - label: 'text-faqs', - icon: 'FaqIcon', - childMenu: [ - { - href: Routes.faqs.list, - label: 'text-all-faqs', - icon: 'FaqIcon', - }, - { - href: Routes.faqs.create, - label: 'text-new-faq', - icon: 'TypesIcon', - }, - ], - }, - { - href: '', - label: 'text-terms-conditions', - icon: 'TermsIcon', - childMenu: [ - { - href: Routes.termsAndCondition.list, - label: 'text-all-terms', - icon: 'TermsIcon', - }, - { - href: Routes.termsAndCondition.create, - label: 'text-new-terms', - icon: 'TermsIcon', - }, - ], - }, - { - href: Routes.becomeSeller, - label: 'Become a seller Page', - icon: 'TermsIcon', - }, // { // href: Routes.order.create, // label: 'sidebar-nav-item-create-order', @@ -383,62 +311,134 @@ export const siteSettings = { ], }, - user: { - href: '', - label: 'text-user-control', - icon: 'SettingsIcon', - childMenu: [ - { - href: Routes.user.list, - label: 'text-all-users', - icon: 'UsersIcon', - }, - { - href: Routes.adminList, - label: 'text-admin-list', - icon: 'AdminListIcon', - }, - { - href: '', - label: 'text-vendors', - icon: 'VendorsIcon', - childMenu: [ - { - href: Routes.vendorList, - label: 'text-all-vendors', - icon: 'UsersIcon', - }, - { - href: Routes.pendingVendorList, - label: 'text-pending-vendors', - icon: 'UsersIcon', - }, - ], - }, - { - href: '', - label: 'sidebar-nav-item-staffs', - icon: 'StaffIcon', - childMenu: [ - { - href: Routes.myStaffs, - label: 'sidebar-nav-item-my-staffs', - icon: 'UsersIcon', - }, - { - href: Routes.vendorStaffs, - label: 'sidebar-nav-item-vendor-staffs', - icon: 'UsersIcon', - }, - ], - }, - { - href: Routes.customerList, - label: 'text-customers', - icon: 'CustomersIcon', - }, - ], - }, + // layout: { + // href: '', + // label: 'text-page-control', + // icon: 'SettingsIcon', + // childMenu: [ + // { + // href: '', + // label: 'text-faqs', + // icon: 'FaqIcon', + // childMenu: [ + // { + // href: Routes.faqs.list, + // label: 'text-all-faqs', + // icon: 'FaqIcon', + // }, + // { + // href: Routes.faqs.create, + // label: 'text-new-faq', + // icon: 'TypesIcon', + // }, + // ], + // }, + // { + // href: '', + // label: 'text-terms-conditions', + // icon: 'TermsIcon', + // childMenu: [ + // { + // href: Routes.termsAndCondition.list, + // label: 'text-all-terms', + // icon: 'TermsIcon', + // }, + // { + // href: Routes.termsAndCondition.create, + // label: 'text-new-terms', + // icon: 'TermsIcon', + // }, + // ], + // }, + // { + // href: Routes.becomeSeller, + // label: 'Become a seller Page', + // icon: 'TermsIcon', + // }, + // { + // href: Routes.order.create, + // label: 'sidebar-nav-item-create-order', + // icon: 'CreateOrderIcon', + // }, + // { + // href: Routes.transaction, + // label: 'text-transactions', + // icon: 'TransactionsIcon', + // }, + // { + // href: '', + // label: 'Order tracking', + // icon: 'OrderTrackingIcon', + // }, + // { + // href: '', + // label: 'Delivery policies', + // icon: 'ShippingsIcon', + // }, + // { + // href: '', + // label: 'Cancelation policies', + // icon: 'CancelationIcon', + // }, + // ], + // }, + + // user: { + // href: '', + // label: 'text-user-control', + // icon: 'SettingsIcon', + // childMenu: [ + // { + // href: Routes.user.list, + // label: 'text-all-users', + // icon: 'UsersIcon', + // }, + // { + // href: Routes.adminList, + // label: 'text-admin-list', + // icon: 'AdminListIcon', + // }, + // { + // href: '', + // label: 'text-vendors', + // icon: 'VendorsIcon', + // childMenu: [ + // { + // href: Routes.vendorList, + // label: 'text-all-vendors', + // icon: 'UsersIcon', + // }, + // { + // href: Routes.pendingVendorList, + // label: 'text-pending-vendors', + // icon: 'UsersIcon', + // }, + // ], + // }, + // { + // href: '', + // label: 'sidebar-nav-item-staffs', + // icon: 'StaffIcon', + // childMenu: [ + // { + // href: Routes.myStaffs, + // label: 'sidebar-nav-item-my-staffs', + // icon: 'UsersIcon', + // }, + // { + // href: Routes.vendorStaffs, + // label: 'sidebar-nav-item-vendor-staffs', + // icon: 'UsersIcon', + // }, + // ], + // }, + // { + // href: Routes.customerList, + // label: 'text-customers', + // icon: 'CustomersIcon', + // }, + // ], + // }, // feedback: { // href: '', @@ -458,57 +458,57 @@ export const siteSettings = { // ], // }, - promotional: { - href: '', - label: 'text-promotional-management', - icon: 'SettingsIcon', - childMenu: [ - { - href: '', - label: 'sidebar-nav-item-coupons', - icon: 'CouponsIcon', - childMenu: [ - { - href: Routes.coupon.list, - label: 'text-all-coupons', - icon: 'CouponsIcon', - }, - { - href: Routes.coupon.create, - label: 'text-new-coupon', - icon: 'CouponsIcon', - }, - ], - }, - // { - // href: '', - // label: 'text-flash-sale', - // icon: 'FlashDealsIcon', - // childMenu: [ - // { - // href: Routes.flashSale.list, - // label: 'text-all-campaigns', - // icon: 'FlashDealsIcon', - // }, - // { - // href: Routes.flashSale.create, - // label: 'text-new-campaigns', - // icon: 'FlashDealsIcon', - // }, - // { - // href: Routes.vendorRequestForFlashSale.list, - // label: 'Vendor requests', - // icon: 'CouponsIcon', - // }, - // ], - // }, - // { - // href: '', - // label: 'Newsletter emails', - // icon: 'CouponsIcon', - // }, - ], - }, + // promotional: { + // href: '', + // label: 'text-promotional-management', + // icon: 'SettingsIcon', + // childMenu: [ + // { + // href: '', + // label: 'sidebar-nav-item-coupons', + // icon: 'CouponsIcon', + // childMenu: [ + // { + // href: Routes.coupon.list, + // label: 'text-all-coupons', + // icon: 'CouponsIcon', + // }, + // { + // href: Routes.coupon.create, + // label: 'text-new-coupon', + // icon: 'CouponsIcon', + // }, + // ], + // }, + // // { + // // href: '', + // // label: 'text-flash-sale', + // // icon: 'FlashDealsIcon', + // // childMenu: [ + // // { + // // href: Routes.flashSale.list, + // // label: 'text-all-campaigns', + // // icon: 'FlashDealsIcon', + // // }, + // // { + // // href: Routes.flashSale.create, + // // label: 'text-new-campaigns', + // // icon: 'FlashDealsIcon', + // // }, + // // { + // // href: Routes.vendorRequestForFlashSale.list, + // // label: 'Vendor requests', + // // icon: 'CouponsIcon', + // // }, + // // ], + // // }, + // // { + // // href: '', + // // label: 'Newsletter emails', + // // icon: 'CouponsIcon', + // // }, + // ], + // }, // feature: { // href: '',