diff --git a/src/pages/[shop]/attributes/[attributeId]/[action].tsx b/src/pages/shop/attributes/[attributeId]/[action].tsx
similarity index 100%
rename from src/pages/[shop]/attributes/[attributeId]/[action].tsx
rename to src/pages/shop/attributes/[attributeId]/[action].tsx
diff --git a/src/pages/[shop]/attributes/create.tsx b/src/pages/shop/attributes/create.tsx
similarity index 100%
rename from src/pages/[shop]/attributes/create.tsx
rename to src/pages/shop/attributes/create.tsx
diff --git a/src/pages/[shop]/attributes/index.tsx b/src/pages/shop/attributes/index.tsx
similarity index 100%
rename from src/pages/[shop]/attributes/index.tsx
rename to src/pages/shop/attributes/index.tsx
diff --git a/src/pages/[shop]/authors/create.tsx b/src/pages/shop/authors/create.tsx
similarity index 100%
rename from src/pages/[shop]/authors/create.tsx
rename to src/pages/shop/authors/create.tsx
diff --git a/src/pages/[shop]/authors/index.tsx b/src/pages/shop/authors/index.tsx
similarity index 100%
rename from src/pages/[shop]/authors/index.tsx
rename to src/pages/shop/authors/index.tsx
diff --git a/src/pages/[shop]/coupons/[couponSlug]/[action].tsx b/src/pages/shop/coupons/[couponSlug]/[action].tsx
similarity index 100%
rename from src/pages/[shop]/coupons/[couponSlug]/[action].tsx
rename to src/pages/shop/coupons/[couponSlug]/[action].tsx
diff --git a/src/pages/[shop]/coupons/create.tsx b/src/pages/shop/coupons/create.tsx
similarity index 100%
rename from src/pages/[shop]/coupons/create.tsx
rename to src/pages/shop/coupons/create.tsx
diff --git a/src/pages/[shop]/coupons/index.tsx b/src/pages/shop/coupons/index.tsx
similarity index 100%
rename from src/pages/[shop]/coupons/index.tsx
rename to src/pages/shop/coupons/index.tsx
diff --git a/src/pages/shops/create.tsx b/src/pages/shop/create.tsx
similarity index 91%
rename from src/pages/shops/create.tsx
rename to src/pages/shop/create.tsx
index d74b3f1..5f2fc70 100644
--- a/src/pages/shops/create.tsx
+++ b/src/pages/shop/create.tsx
@@ -18,9 +18,9 @@ export default function CreateShopPage() {
>
);
}
-CreateShopPage.authenticate = {
- permissions: adminAndOwnerOnly,
-};
+// CreateShopPage.authenticate = {
+// permissions: adminAndOwnerOnly,
+// };
CreateShopPage.Layout = OwnerLayout;
export const getStaticProps: GetStaticProps = async ({ locale }) => ({
diff --git a/src/pages/[shop]/edit.tsx b/src/pages/shop/edit.tsx
similarity index 91%
rename from src/pages/[shop]/edit.tsx
rename to src/pages/shop/edit.tsx
index 931b032..df3e8d6 100644
--- a/src/pages/[shop]/edit.tsx
+++ b/src/pages/shop/edit.tsx
@@ -26,9 +26,7 @@ export default function UpdateShopPage() {
data,
isLoading: loading,
error,
- } = useShopQuery({
- slug: shop as string,
- });
+ } = useShopQuery();
if (loading) return ;
if (error) return ;
if (
@@ -38,6 +36,7 @@ export default function UpdateShopPage() {
) {
router.replace(Routes.dashboard);
}
+
return (
<>
@@ -45,13 +44,13 @@ export default function UpdateShopPage() {
{t('form:form-title-edit-shop')}
-
+
>
);
}
-UpdateShopPage.authenticate = {
- permissions: adminAndOwnerOnly,
-};
+// UpdateShopPage.authenticate = {
+// permissions: adminAndOwnerOnly,
+// };
UpdateShopPage.Layout = ShopLayout;
export const getServerSideProps = async ({ locale }: any) => ({
diff --git a/src/pages/[shop]/faqs/[id]/[action].tsx b/src/pages/shop/faqs/[id]/[action].tsx
similarity index 100%
rename from src/pages/[shop]/faqs/[id]/[action].tsx
rename to src/pages/shop/faqs/[id]/[action].tsx
diff --git a/src/pages/[shop]/faqs/create.tsx b/src/pages/shop/faqs/create.tsx
similarity index 100%
rename from src/pages/[shop]/faqs/create.tsx
rename to src/pages/shop/faqs/create.tsx
diff --git a/src/pages/[shop]/faqs/index.tsx b/src/pages/shop/faqs/index.tsx
similarity index 100%
rename from src/pages/[shop]/faqs/index.tsx
rename to src/pages/shop/faqs/index.tsx
diff --git a/src/pages/[shop]/flash-sale/[slug]/index.tsx b/src/pages/shop/flash-sale/[slug]/index.tsx
similarity index 100%
rename from src/pages/[shop]/flash-sale/[slug]/index.tsx
rename to src/pages/shop/flash-sale/[slug]/index.tsx
diff --git a/src/pages/[shop]/flash-sale/index.tsx b/src/pages/shop/flash-sale/index.tsx
similarity index 100%
rename from src/pages/[shop]/flash-sale/index.tsx
rename to src/pages/shop/flash-sale/index.tsx
diff --git a/src/pages/[shop]/flash-sale/my-products.tsx b/src/pages/shop/flash-sale/my-products.tsx
similarity index 100%
rename from src/pages/[shop]/flash-sale/my-products.tsx
rename to src/pages/shop/flash-sale/my-products.tsx
diff --git a/src/pages/[shop]/flash-sale/vendor-request/[id]/[action].tsx b/src/pages/shop/flash-sale/vendor-request/[id]/[action].tsx
similarity index 100%
rename from src/pages/[shop]/flash-sale/vendor-request/[id]/[action].tsx
rename to src/pages/shop/flash-sale/vendor-request/[id]/[action].tsx
diff --git a/src/pages/[shop]/flash-sale/vendor-request/[id]/index.tsx b/src/pages/shop/flash-sale/vendor-request/[id]/index.tsx
similarity index 100%
rename from src/pages/[shop]/flash-sale/vendor-request/[id]/index.tsx
rename to src/pages/shop/flash-sale/vendor-request/[id]/index.tsx
diff --git a/src/pages/[shop]/flash-sale/vendor-request/create.tsx b/src/pages/shop/flash-sale/vendor-request/create.tsx
similarity index 100%
rename from src/pages/[shop]/flash-sale/vendor-request/create.tsx
rename to src/pages/shop/flash-sale/vendor-request/create.tsx
diff --git a/src/pages/[shop]/flash-sale/vendor-request/index.tsx b/src/pages/shop/flash-sale/vendor-request/index.tsx
similarity index 100%
rename from src/pages/[shop]/flash-sale/vendor-request/index.tsx
rename to src/pages/shop/flash-sale/vendor-request/index.tsx
diff --git a/src/pages/[shop]/index.tsx b/src/pages/shop/index.tsx
similarity index 97%
rename from src/pages/[shop]/index.tsx
rename to src/pages/shop/index.tsx
index e082cad..6ca1d50 100644
--- a/src/pages/[shop]/index.tsx
+++ b/src/pages/shop/index.tsx
@@ -57,10 +57,9 @@ export default function ShopPage() {
data,
isLoading: loading,
error,
- } = useShopQuery({
- slug: shop!.toString(),
- });
-
+ } = useShopQuery();
+ console.log(data);
+
const { price: totalEarnings } = usePrice(
data && {
amount: data?.balance?.total_earnings!,
@@ -204,7 +203,7 @@ export default function ShopPage() {
{t('common:text-edit-shop')}
@@ -215,7 +214,7 @@ export default function ShopPage() {
) ? (
{t('common:text-transfer-shop-ownership')}
@@ -300,15 +299,13 @@ export default function ShopPage() {
);
}
ShopPage.Layout = ShopLayout;
-ShopPage.authenticate = {
- permissions: adminOwnerAndStaffOnly,
-};
+// ShopPage.authenticate = {
+// permissions: adminOwnerAndStaffOnly,
+// };
export const getStaticProps = async ({ locale }: any) => ({
props: {
...(await serverSideTranslations(locale, ['form', 'common', 'table'])),
},
});
-export const getStaticPaths: GetStaticPaths = async () => {
- return { paths: [], fallback: 'blocking' };
-};
+
diff --git a/src/pages/[shop]/manufacturers/create.tsx b/src/pages/shop/manufacturers/create.tsx
similarity index 100%
rename from src/pages/[shop]/manufacturers/create.tsx
rename to src/pages/shop/manufacturers/create.tsx
diff --git a/src/pages/[shop]/manufacturers/index.tsx b/src/pages/shop/manufacturers/index.tsx
similarity index 100%
rename from src/pages/[shop]/manufacturers/index.tsx
rename to src/pages/shop/manufacturers/index.tsx
diff --git a/src/pages/[shop]/orders/[orderId]/index.tsx b/src/pages/shop/orders/[orderId]/index.tsx
similarity index 100%
rename from src/pages/[shop]/orders/[orderId]/index.tsx
rename to src/pages/shop/orders/[orderId]/index.tsx
diff --git a/src/pages/[shop]/orders/index.tsx b/src/pages/shop/orders/index.tsx
similarity index 100%
rename from src/pages/[shop]/orders/index.tsx
rename to src/pages/shop/orders/index.tsx
diff --git a/src/pages/[shop]/orders/transaction.tsx b/src/pages/shop/orders/transaction.tsx
similarity index 100%
rename from src/pages/[shop]/orders/transaction.tsx
rename to src/pages/shop/orders/transaction.tsx
diff --git a/src/pages/[shop]/products/[productSlug]/[action].tsx b/src/pages/shop/products/[productSlug]/[action].tsx
similarity index 100%
rename from src/pages/[shop]/products/[productSlug]/[action].tsx
rename to src/pages/shop/products/[productSlug]/[action].tsx
diff --git a/src/pages/[shop]/products/create.tsx b/src/pages/shop/products/create.tsx
similarity index 100%
rename from src/pages/[shop]/products/create.tsx
rename to src/pages/shop/products/create.tsx
diff --git a/src/pages/[shop]/products/draft.tsx b/src/pages/shop/products/draft.tsx
similarity index 100%
rename from src/pages/[shop]/products/draft.tsx
rename to src/pages/shop/products/draft.tsx
diff --git a/src/pages/[shop]/products/index.tsx b/src/pages/shop/products/index.tsx
similarity index 100%
rename from src/pages/[shop]/products/index.tsx
rename to src/pages/shop/products/index.tsx
diff --git a/src/pages/[shop]/products/inventory.tsx b/src/pages/shop/products/inventory.tsx
similarity index 100%
rename from src/pages/[shop]/products/inventory.tsx
rename to src/pages/shop/products/inventory.tsx
diff --git a/src/pages/[shop]/products/product-stock.tsx b/src/pages/shop/products/product-stock.tsx
similarity index 100%
rename from src/pages/[shop]/products/product-stock.tsx
rename to src/pages/shop/products/product-stock.tsx
diff --git a/src/pages/[shop]/questions/index.tsx b/src/pages/shop/questions/index.tsx
similarity index 100%
rename from src/pages/[shop]/questions/index.tsx
rename to src/pages/shop/questions/index.tsx
diff --git a/src/pages/[shop]/refunds/[refundId]/index.tsx b/src/pages/shop/refunds/[refundId]/index.tsx
similarity index 100%
rename from src/pages/[shop]/refunds/[refundId]/index.tsx
rename to src/pages/shop/refunds/[refundId]/index.tsx
diff --git a/src/pages/[shop]/refunds/index.tsx b/src/pages/shop/refunds/index.tsx
similarity index 100%
rename from src/pages/[shop]/refunds/index.tsx
rename to src/pages/shop/refunds/index.tsx
diff --git a/src/pages/[shop]/reviews/index.tsx b/src/pages/shop/reviews/index.tsx
similarity index 100%
rename from src/pages/[shop]/reviews/index.tsx
rename to src/pages/shop/reviews/index.tsx
diff --git a/src/pages/[shop]/staffs/create.tsx b/src/pages/shop/staffs/create.tsx
similarity index 100%
rename from src/pages/[shop]/staffs/create.tsx
rename to src/pages/shop/staffs/create.tsx
diff --git a/src/pages/[shop]/staffs/index.tsx b/src/pages/shop/staffs/index.tsx
similarity index 100%
rename from src/pages/[shop]/staffs/index.tsx
rename to src/pages/shop/staffs/index.tsx
diff --git a/src/pages/[shop]/store-notices/[id]/[action].tsx b/src/pages/shop/store-notices/[id]/[action].tsx
similarity index 100%
rename from src/pages/[shop]/store-notices/[id]/[action].tsx
rename to src/pages/shop/store-notices/[id]/[action].tsx
diff --git a/src/pages/[shop]/store-notices/[id]/index.tsx b/src/pages/shop/store-notices/[id]/index.tsx
similarity index 100%
rename from src/pages/[shop]/store-notices/[id]/index.tsx
rename to src/pages/shop/store-notices/[id]/index.tsx
diff --git a/src/pages/[shop]/store-notices/create.tsx b/src/pages/shop/store-notices/create.tsx
similarity index 100%
rename from src/pages/[shop]/store-notices/create.tsx
rename to src/pages/shop/store-notices/create.tsx
diff --git a/src/pages/[shop]/store-notices/index.tsx b/src/pages/shop/store-notices/index.tsx
similarity index 100%
rename from src/pages/[shop]/store-notices/index.tsx
rename to src/pages/shop/store-notices/index.tsx
diff --git a/src/pages/[shop]/terms-and-conditions/[termSlug]/[action].tsx b/src/pages/shop/terms-and-conditions/[termSlug]/[action].tsx
similarity index 100%
rename from src/pages/[shop]/terms-and-conditions/[termSlug]/[action].tsx
rename to src/pages/shop/terms-and-conditions/[termSlug]/[action].tsx
diff --git a/src/pages/[shop]/terms-and-conditions/[termSlug]/index.tsx b/src/pages/shop/terms-and-conditions/[termSlug]/index.tsx
similarity index 100%
rename from src/pages/[shop]/terms-and-conditions/[termSlug]/index.tsx
rename to src/pages/shop/terms-and-conditions/[termSlug]/index.tsx
diff --git a/src/pages/[shop]/terms-and-conditions/create.tsx b/src/pages/shop/terms-and-conditions/create.tsx
similarity index 100%
rename from src/pages/[shop]/terms-and-conditions/create.tsx
rename to src/pages/shop/terms-and-conditions/create.tsx
diff --git a/src/pages/[shop]/terms-and-conditions/index.tsx b/src/pages/shop/terms-and-conditions/index.tsx
similarity index 100%
rename from src/pages/[shop]/terms-and-conditions/index.tsx
rename to src/pages/shop/terms-and-conditions/index.tsx
diff --git a/src/pages/[shop]/transfer-ownership.tsx b/src/pages/shop/transfer-ownership.tsx
similarity index 100%
rename from src/pages/[shop]/transfer-ownership.tsx
rename to src/pages/shop/transfer-ownership.tsx
diff --git a/src/pages/[shop]/withdraws/create.tsx b/src/pages/shop/withdraws/create.tsx
similarity index 100%
rename from src/pages/[shop]/withdraws/create.tsx
rename to src/pages/shop/withdraws/create.tsx
diff --git a/src/pages/[shop]/withdraws/index.tsx b/src/pages/shop/withdraws/index.tsx
similarity index 100%
rename from src/pages/[shop]/withdraws/index.tsx
rename to src/pages/shop/withdraws/index.tsx
diff --git a/src/settings/site.settings.ts b/src/settings/site.settings.ts
index 53e2581..c7ecc6b 100644
--- a/src/settings/site.settings.ts
+++ b/src/settings/site.settings.ts
@@ -71,6 +71,12 @@ export const siteSettings = {
label: 'sidebar-nav-item-dashboard',
icon: 'DashboardIcon',
},
+ {
+ href: Routes.shop.list,
+ label: 'sidebar-nav-item-shops',
+ icon: 'ShopIcon',
+
+ },
],
},
@@ -94,11 +100,11 @@ export const siteSettings = {
// label: 'Order',
// icon: 'OrdersIcon',
// },
- // // {
- // // href: '',
- // // label: 'Sale',
- // // icon: 'ShopIcon',
- // // },
+ // {
+ // href: '',
+ // label: 'Sale',
+ // icon: 'ShopIcon',
+ // },
// {
// href: '',
// label: 'User',
@@ -107,46 +113,30 @@ export const siteSettings = {
// ],
// },
- shop: {
- href: '',
- label: 'text-shop-management',
- icon: 'ShopIcon',
- childMenu: [
- {
- href: '',
- label: 'sidebar-nav-item-shops',
- icon: 'ShopIcon',
- childMenu: [
- {
- href: Routes.shop.list,
- label: 'text-all-shops',
- icon: 'MyShopIcon',
- },
- {
- href: Routes.shop.create,
- label: 'text-add-all-shops',
- icon: 'ShopIcon',
- },
- {
- href: Routes.newShops,
- label: 'text-inactive-shops',
- icon: 'MyShopIcon',
- },
- ],
- },
- {
- href: Routes.adminMyShops,
- label: 'sidebar-nav-item-my-shops',
- icon: 'MyShopIcon',
- },
- {
- href: Routes.ownershipTransferRequest.list,
- label: 'Shop Transfer Request',
- icon: 'MyShopIcon',
- permission: adminAndOwnerOnly,
- },
- ],
- },
+ // shop: {
+ // href: '',
+ // label: 'text-shop-management',
+ // icon: 'ShopIcon',
+ // childMenu: [
+ // {
+ // href: Routes.shop.list,
+ // label: 'sidebar-nav-item-shops',
+ // icon: 'ShopIcon',
+
+ // },
+ // {
+ // href: Routes.adminMyShops,
+ // label: 'sidebar-nav-item-my-shops',
+ // icon: 'MyShopIcon',
+ // },
+ // {
+ // href: Routes.ownershipTransferRequest.list,
+ // label: 'Shop Transfer Request',
+ // icon: 'MyShopIcon',
+ // permission: adminAndOwnerOnly,
+ // },
+ // ],
+ // },
product: {
href: '',
@@ -1181,19 +1171,15 @@ export const siteSettings = {
export const socialIcon = [
{
- value: 'FacebookIcon',
- label: 'Facebook',
+ value: 'TelegramIcon',
+ label: 'Telegram',
},
{
value: 'InstagramIcon',
label: 'Instagram',
},
{
- value: 'TwitterIcon',
- label: 'Twitter',
- },
- {
- value: 'YouTubeIcon',
- label: 'Youtube',
+ value: 'WhatsappIcon',
+ label: 'Whatsapp',
},
];
diff --git a/src/types/index.ts b/src/types/index.ts
index ed46a3c..7cea7ec 100644
--- a/src/types/index.ts
+++ b/src/types/index.ts
@@ -193,8 +193,11 @@ export interface PaginatorInfo {
}
export interface LoginInput {
- email: string;
+ phone_number: string;
+ range_phone: string;
password: string;
+ user_type: 'merchant',
+
}
export interface AuthResponse {
@@ -449,20 +452,15 @@ export interface MakeAdminInput {
}
export interface User {
- id: string;
- name: string;
- shops: Shop[];
- managed_shop: Shop;
- is_active: boolean;
- email: string;
- created_at: string;
- updated_at: string;
- profile?: Profile;
- address: Address[];
- orders?: OrderPaginator;
- email_verified: boolean;
+ id: number;
+ fullname: string;
+ token: string;
+ avatar: string;
+ phone_number: string;
+ user_type: "merchant";
}
+
export interface Domain {
id: String;
url: String;
@@ -1523,12 +1521,22 @@ export interface ContactDetailsInput {
}
export interface RegisterInput {
- email: string;
+ phone_number: string;
+ range_phone: string;
password: string;
- name: string;
+ password_confirmation: string;
+ fullname: string;
+ user_type: 'merchant',
shop_id?: number;
+ verification_method: 'whatsapp',
// permission: Permission;
}
+export interface OTPInput {
+ method: "register" | "reset ",
+ phone_number: string,
+ code: string,
+ user_type: "merchant"
+}
export interface ChangePasswordInput {
oldPassword: string;
@@ -1536,7 +1544,10 @@ export interface ChangePasswordInput {
}
export interface ForgetPasswordInput {
- email: string;
+ phone_number: string;
+ range_phone : string;
+ user_type: "merchant"
+
}
export interface VerifyForgetPasswordTokenInput {
diff --git a/src/utils/auth-utils.ts b/src/utils/auth-utils.ts
index a0d1699..a72b90b 100644
--- a/src/utils/auth-utils.ts
+++ b/src/utils/auth-utils.ts
@@ -9,6 +9,7 @@ import {
SUPER_ADMIN,
TOKEN,
} from './constants';
+import { useShopQuery } from '@/data/shop';
export const allowedRoles = [SUPER_ADMIN, STORE_OWNER, STAFF];
export const adminAndOwnerOnly = [SUPER_ADMIN, STORE_OWNER];
@@ -17,8 +18,10 @@ export const adminOnly = [SUPER_ADMIN];
export const ownerOnly = [STORE_OWNER];
export const ownerAndStaffOnly = [STORE_OWNER, STAFF];
-export function setAuthCredentials(token: string, permissions: any, role: any) {
- Cookie.set(AUTH_CRED, JSON.stringify({ token, permissions, role }));
+export function setAuthCredentials(token: string) {
+ console.log("Dfafasd");
+
+ Cookie.set(AUTH_CRED, JSON.stringify(token));
}
export function setEmailVerified(emailVerified: boolean) {
Cookie.set(EMAIL_VERIFIED, JSON.stringify({ emailVerified }));
@@ -32,8 +35,6 @@ export function getEmailVerified(): {
export function getAuthCredentials(context?: any): {
token: string | null;
- permissions: string[] | null;
- role: string | null;
} {
let authCred;
if (context) {
@@ -44,7 +45,7 @@ export function getAuthCredentials(context?: any): {
if (authCred) {
return JSON.parse(authCred);
}
- return { token: null, permissions: null, role: null };
+ return { token: null };
}
export function parseSSRCookie(context: any) {
@@ -55,11 +56,32 @@ export function hasAccess(
_allowedRoles: string[],
_userPermissions: string[] | undefined | null,
) {
- if (_userPermissions) {
- return Boolean(
- _allowedRoles?.find((aRole) => _userPermissions.includes(aRole)),
- );
+ // if (_userPermissions) {
+ // return Boolean(
+ // _allowedRoles?.find((aRole) => _userPermissions.includes(aRole)),
+ // );
+ // }
+ return true;
+}
+export function useHasShop(slug) {
+ const {
+ data,
+ isLoading: loading,
+ error,
+ } = useShopQuery();
+
+ if (slug) {
+ return data?.merchant_info.slug
+ }
+ if (data?.id) {
+ return true
}
+
+ // if (_userPermissions) {
+ // return Boolean(
+ // _allowedRoles?.find((aRole) => _userPermissions.includes(aRole)),
+ // );
+ // }
return false;
}
diff --git a/src/utils/private-route.tsx b/src/utils/private-route.tsx
index e8ec7f8..29d63d8 100644
--- a/src/utils/private-route.tsx
+++ b/src/utils/private-route.tsx
@@ -16,9 +16,9 @@ const PrivateRoute: React.FC<{
Array.isArray(permissions) &&
!!permissions.length &&
hasAccess(authProps.permissions, permissions);
- React.useEffect(() => {
- if (!isUser) router.replace(Routes.login); // If not authenticated, force log in
- }, [isUser]);
+ // React.useEffect(() => {
+ // if (!isUser) router.replace(Routes.login); // If not authenticated, force log in
+ // }, [isUser]);
if (isUser && hasPermission) {
return <>{children}>;
diff --git a/src/utils/use-price.ts b/src/utils/use-price.ts
index c055d99..b7d0473 100644
--- a/src/utils/use-price.ts
+++ b/src/utils/use-price.ts
@@ -54,10 +54,11 @@ type PriceProps = {
currencyCode?: string;
};
export default function usePrice(data?: PriceProps | null) {
- const { currency, currencyOptions } = useSettings();
- const { formation, fractions } = currencyOptions;
+ const { currency, currencyOptions = {} } = useSettings();
+ const { formation = 'en-US', fractions = 2 } = currencyOptions;
const { amount, baseAmount, currencyCode = currency } = data ?? {};
const locale = formation ?? siteSettings.defaultLanguage;
+
const value = useMemo(() => {
if (typeof amount !== 'number' || !currencyCode) return '';