diff --git a/package.json b/package.json index b5a5f3fc..2b628fef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "version": "0.0.61", + "version": "0.0.62", "license": "MIT", "main": "dist/index.js", "typings": "dist/index.d.ts", diff --git a/src/modules/inventory/index.ts b/src/modules/inventory/index.ts index 2eaeac95..d7a1b8f9 100644 --- a/src/modules/inventory/index.ts +++ b/src/modules/inventory/index.ts @@ -8,6 +8,7 @@ import { GET_VARIANTS, GET_VARIANTS_BY_STATUS, GET_WAREHOUSES, + PRODUCT_ADMIN_DASHBOARD, PRODUCT_DASHBOARD, } from '../../queries/inventory.query'; import { @@ -42,6 +43,8 @@ import { AllCreatedVariants, deleteVariant, AllCreatedVariantsbyStatus, + InputStatusParams, + ProductAdminDashboardInterface, } from '../../types'; export class Inventory { @@ -57,14 +60,11 @@ export class Inventory { return response.data; } - public async createStatus(name: string, is_default?:boolean): Promise { + public async createStatus(data: InputStatusParams): Promise { const response = await this.client.mutate({ mutation: CREATE_STATUS, variables: { - input: { - name: name, - is_default: is_default - }, + input: data, }, }); return response.data; @@ -208,6 +208,17 @@ export class Inventory { return response.data; } + public async productAdminDashboard(): Promise< + ProductAdminDashboardInterface + > { + const response = await this.client.query({ + query: PRODUCT_ADMIN_DASHBOARD, + fetchPolicy: 'network-only', + partialRefetch: true, + }); + + return response.data; + } public async getVariants( options: { @@ -267,7 +278,7 @@ export class Inventory { page, whereCondition, search, - orderByCondition + orderByCondition, } = options; const response = await this.client.query({ @@ -280,7 +291,7 @@ export class Inventory { page, whereCondition, search, - orderByCondition + orderByCondition, }, fetchPolicy: 'network-only', partialRefetch: true, diff --git a/src/mutations/inventory.mutation.ts b/src/mutations/inventory.mutation.ts index 673649aa..7fe2a127 100644 --- a/src/mutations/inventory.mutation.ts +++ b/src/mutations/inventory.mutation.ts @@ -204,6 +204,7 @@ export const CREATE_STATUS = gql` id name is_default + slug } } `; diff --git a/src/queries/inventory.query.ts b/src/queries/inventory.query.ts index e1d9cac2..96272401 100644 --- a/src/queries/inventory.query.ts +++ b/src/queries/inventory.query.ts @@ -229,6 +229,21 @@ export const PRODUCT_DASHBOARD = gql` } `; +export const PRODUCT_ADMIN_DASHBOARD = gql` + query getProductAdminDashboard { + productAdminDashboard { + total_products + total_variants + product_status { + status_id + status_name + status_slug + total_amount + } + } + } +`; + export const GET_VARIANTS = gql` query getVariants( $first: Int diff --git a/src/types/inventory.ts b/src/types/inventory.ts index aa997a5e..afd4da1d 100644 --- a/src/types/inventory.ts +++ b/src/types/inventory.ts @@ -29,7 +29,8 @@ export interface ProductWarehouse { export interface StatusInterface { id: string; name: string; - is_default: boolean; + is_default?: boolean; + slug: string; } export interface OrderBy { @@ -354,3 +355,24 @@ export interface ProductDashboardInterface { export interface deleteVariant { deleteVariant: boolean; } + +export interface InputStatusParams { + name: string; + is_default?: boolean; + company_id?: number | number; +} + +export interface ProductAdminDashboardInterface { + productAdminDashboard: { + total_products: number; + total_variants: number; + product_status: ProductAdminStatusDashboard[]; + }; +} + +export interface ProductAdminStatusDashboard { + status_id: number | string; + status_name: string; + status_slug: string; + total_amount: number; +}