Browse Source

feat: update site URL in environment config, adjust routing for shop visits, and modify shop validation schema

master
sina_sajjadi 2 weeks ago
parent
commit
92f12436bf
  1. 2
      .env
  2. 5
      src/components/shop/shop-form.tsx
  3. 4
      src/components/shop/shop-validation-schema.ts
  4. 2
      src/config/routes.ts
  5. 3
      src/data/client/curd-factory.ts
  6. 5
      src/pages/shop/index.tsx
  7. 408
      src/settings/site.settings.ts

2
.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

5
src/components/shop/shop-form.tsx

@ -250,6 +250,7 @@ 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!)}
/>
<Input
{/* <Input
label={t('form:input-label-website')}
{...register('website')}
variant="outline"
className="mb-5"
error={t(errors.website?.message!)}
required
/>
/> */}
</Card>
</div>

4
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', {

2
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'),
},

3
src/data/client/curd-factory.ts

@ -20,7 +20,10 @@ export function crudFactory<Type, QueryParams extends LanguageParam, InputType>(
return HttpClient.get<Type>(`${endpoint}/${slug}`, { language });
},
create(data: InputType) {
console.log(endpoint , "out if");
if (endpoint === API_ENDPOINTS.SHOPS) {
console.log(endpoint , "in if");
return HttpClient.post<Type>(API_ENDPOINTS.SHOPS, data);
}

5
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() {
</div>
);
}
ShopPage.Layout = ShopLayout;
ShopPage.Layout = Layout;
// ShopPage.authenticate = {
// permissions: adminOwnerAndStaffOnly,
// };

408
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: '',

Loading…
Cancel
Save