diff --git a/package.json b/package.json index bdfdb70..bdc9fa4 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "dependencies": { "@deskpro/app-sdk": "^3.0.12", "@deskpro/deskpro-ui": "^7.1.0", + "@deskpro/app-builder": "^0.0.1", "@fortawesome/free-solid-svg-icons": "^6.4.2", "@heroicons/react": "1.0.6", "@tanstack/react-query": "^4.36.1", diff --git a/src/components/ErrorFallback/ErrorFallback.tsx b/src/components/ErrorFallback/ErrorFallback.tsx index f7750c1..4dd29bc 100644 --- a/src/components/ErrorFallback/ErrorFallback.tsx +++ b/src/components/ErrorFallback/ErrorFallback.tsx @@ -1,5 +1,4 @@ -import get from "lodash/get"; -import { Stack } from "@deskpro/deskpro-ui"; +import { get, map } from "lodash"; import { DEFAULT_ERROR } from "../../constants"; import { ShopifyError } from "../../services/shopify"; import { Container, ErrorBlock } from "../common"; @@ -11,24 +10,20 @@ type Props = Omit & { }; const ErrorFallback: FC = ({ error }) => { - let message = DEFAULT_ERROR; + let message: string|string[] = DEFAULT_ERROR; // eslint-disable-next-line no-console console.error(error); if (error instanceof ShopifyError) { - message = get(error, ["data", "errors"]) + message = map(get(error, ["data", "errors"], []), "message") || DEFAULT_ERROR; } return ( - {message} - - )} + text={message} /> ); diff --git a/src/components/Home/Home.tsx b/src/components/Home/Home.tsx index ff1b3b2..1d1f3ee 100644 --- a/src/components/Home/Home.tsx +++ b/src/components/Home/Home.tsx @@ -1,7 +1,7 @@ import get from "lodash/get"; import { HorizontalDivider } from "@deskpro/app-sdk"; import { Container } from "../common"; -import { CustomerInfo, Orders, Comments } from "./block"; +import { Orders, Comments } from "./block"; import type { FC } from "react"; import type { Maybe } from "../../types"; import type { CustomerType, Order } from "../../services/shopify/types"; @@ -20,25 +20,13 @@ type Props = { const Home: FC = ({ orders, customer, - onNavigateToCustomer, onNavigateToOrders, onNavigateToOrder, getOrderLink, getOrdersLink, - getCustomerLink, }) => { return ( <> - - - - - - , -}; - -const ViewCustomer: FC = ({ customer, theme }) => { - return ( - - - - - {customer?.tags.map((tag) => ( - - ))} - - )} - /> - - )} - /> - - - ); -}; - -export { ViewCustomer }; diff --git a/src/components/ViewCustomer/index.ts b/src/components/ViewCustomer/index.ts deleted file mode 100644 index 96145f7..0000000 --- a/src/components/ViewCustomer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { ViewCustomer } from "./ViewCustomer"; diff --git a/src/components/common/Error/ErrorBlock.tsx b/src/components/common/Error/ErrorBlock.tsx index f042d91..9d3b17b 100644 --- a/src/components/common/Error/ErrorBlock.tsx +++ b/src/components/common/Error/ErrorBlock.tsx @@ -1,9 +1,10 @@ import styled from "styled-components"; import { P5 } from "@deskpro/deskpro-ui"; +import { DEFAULT_ERROR } from "../../../constants"; import type { FC, JSX } from "react"; import type { Maybe } from "../../../types"; -type Props = { +export type Props = { text?: Maybe>, } @@ -15,7 +16,7 @@ const StyledErrorBlock = styled(P5)` background-color: ${({ theme }) => theme.colors.red100}; `; -const ErrorBlock: FC = ({ text = "An error occurred" }) => ( +const ErrorBlock: FC = ({ text = DEFAULT_ERROR }) => ( <> {Array.isArray(text) ? text.map((msg, idx) => ({msg})) diff --git a/src/components/index.ts b/src/components/index.ts index 41ec81e..bc56618 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -2,4 +2,3 @@ export { Home } from "./Home"; export { LinkCustomer } from "./LinkCustomer"; export { ListOrders } from "./ListOrders"; export { ViewOrder } from "./ViewOrder"; -export { ViewCustomer } from "./ViewCustomer"; diff --git a/src/pages/HomePage/HomePage.tsx b/src/pages/HomePage/HomePage.tsx index 66f959f..187416c 100644 --- a/src/pages/HomePage/HomePage.tsx +++ b/src/pages/HomePage/HomePage.tsx @@ -1,6 +1,7 @@ import { FC, useCallback } from "react"; import { useNavigate } from "react-router-dom"; import { LoadingSpinner } from "@deskpro/app-sdk"; +import { PageBuilder } from "@deskpro/app-builder"; import { useSetTitle, useExternalLink, @@ -51,18 +52,108 @@ const HomePage: FC = () => { ); } + // return ( + // <>HomePage + // ); return ( - + ); + /*return ( + <> + + + );*/ }; export { HomePage }; diff --git a/src/pages/ViewCustomerPage/ViewCustomerPage.tsx b/src/pages/ViewCustomerPage/ViewCustomerPage.tsx index bfb163c..26f7f28 100644 --- a/src/pages/ViewCustomerPage/ViewCustomerPage.tsx +++ b/src/pages/ViewCustomerPage/ViewCustomerPage.tsx @@ -1,23 +1,18 @@ import { useMemo } from "react"; import { useSearchParams } from "react-router-dom"; -import { - LoadingSpinner, - useDeskproAppTheme, - useDeskproAppClient, -} from "@deskpro/app-sdk"; +import { LoadingSpinner, useDeskproAppClient } from "@deskpro/app-sdk"; +import { PageBuilder } from "@deskpro/app-builder"; import { useSetTitle, useExternalLink, useRegisterElements, } from "../../hooks"; import { useCustomer } from "../../hooks"; -import { ViewCustomer } from "../../components"; import type { FC } from "react"; const ViewCustomerPage: FC = () => { const [searchParams] = useSearchParams(); const customerId = searchParams.get("customerId"); - const { theme } = useDeskproAppTheme(); const { client } = useDeskproAppClient(); const { getCustomerLink } = useExternalLink(); const { isLoading, customer } = useCustomer(customerId); @@ -25,7 +20,7 @@ const ViewCustomerPage: FC = () => { return getCustomerLink(customer?.legacyResourceId); }, [getCustomerLink, customer?.legacyResourceId]); - useSetTitle(customer?.displayName || "Shopify"); + useSetTitle("Shopify"); useRegisterElements(({ registerElement }) => { registerElement("refresh", { type: "refresh_button" }); @@ -43,14 +38,6 @@ const ViewCustomerPage: FC = () => { } }, }); - - if (customerLink) { - registerElement("external", { - type: "cta_external_link", - url: customerLink, - hasIcon: true, - }); - } }, [client, customer]); @@ -59,11 +46,64 @@ const ViewCustomerPage: FC = () => { } return ( - + <>ViewCustomerPage ); + // return ( + // + // ); }; export { ViewCustomerPage }; diff --git a/src/services/shopify/getCustomer.ts b/src/services/shopify/getCustomer.ts index 3b47e4e..95e8061 100644 --- a/src/services/shopify/getCustomer.ts +++ b/src/services/shopify/getCustomer.ts @@ -1,9 +1,10 @@ /* eslint-disable */ -import get from "lodash/get"; +import { get, random } from "lodash"; import { IDeskproClient } from "@deskpro/app-sdk"; import { baseGraphQLRequest } from "./baseGraphQLRequest"; import { gql } from "../../utils"; import type { CustomerType } from "./types"; +import { mockCustomer } from "../../../testing"; const getCustomer = ( client: IDeskproClient, diff --git a/src/utils/__tests__/formatPrice.test.ts b/src/utils/__tests__/formatPrice.test.ts new file mode 100644 index 0000000..335c67d --- /dev/null +++ b/src/utils/__tests__/formatPrice.test.ts @@ -0,0 +1,9 @@ +import { formatPrice } from "../formatPrice"; + +describe("formatPrice", () => { + test("should return formatted price", () => { + expect(formatPrice(0, { currency: "UAH" })).toBe("₴0.00"); + expect(formatPrice(10, { currency: "GBP" })).toBe("£10.00"); + expect(formatPrice(23.5, { style: "decimal" })).toBe("23.50"); + }); +}); diff --git a/src/utils/formatPrice.ts b/src/utils/formatPrice.ts new file mode 100644 index 0000000..f389cd7 --- /dev/null +++ b/src/utils/formatPrice.ts @@ -0,0 +1,21 @@ +type Options = { + currency?: string, + style?: + | "decimal" // for plain number formatting + | "currency" // for currency formatting + | "percent" // for percent formatting + | "unit" // for unit formatting +}; + +const formatPrice = (price?: string|number, options?: Options): string => { + const formatter = new Intl.NumberFormat("en-GB", { + style: options?.style || "currency", + currency: options?.currency || "GBP", + currencyDisplay: "narrowSymbol", + minimumFractionDigits: 2, + }); + + return formatter.format(Number(price || 0)); +}; + +export { formatPrice }; diff --git a/src/utils/index.ts b/src/utils/index.ts index c417550..b6eea34 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -17,3 +17,4 @@ export { isLast } from "./isLast"; export { isForm } from "./isForm"; export { getQueryParams } from "./getQueryParams"; export { gql } from "./gql"; +export { formatPrice } from "./formatPrice"; diff --git a/testing/mocks/index.ts b/testing/mocks/index.ts index 9f7f2ed..64f3843 100644 --- a/testing/mocks/index.ts +++ b/testing/mocks/index.ts @@ -1 +1,4 @@ export { default as mockContext } from "./mockContext.json"; +export { default as mockCustomer } from "./mockCustomer.json"; +export { default as mockCustomersSearch } from "./mockCustomersSearch.json"; +export { default as mockGetCustomersNotExist } from "./mockGetCustomersNotExist.json"; diff --git a/testing/mocks/mockCustomer.json b/testing/mocks/mockCustomer.json new file mode 100644 index 0000000..c1401ee --- /dev/null +++ b/testing/mocks/mockCustomer.json @@ -0,0 +1,669 @@ +{ + "data": { + "customer": { + "id": "gid://shopify/Customer/7982046085440", + "legacyResourceId": "7982046085440", + "displayName": "Christian Hatfield", + "createdAt": "2024-01-18T17:31:36Z", + "email": "egnition_sample_60@egnition.com", + "hasTimelineComment": false, + "locale": "en", + "note": null, + "phone": "+12423337689", + "firstName": "Christian", + "lastName": "Hatfield", + "numberOfOrders": "20", + "tags": [ + "egnition-sample-data", + "VIP" + ], + "amountSpent": { + "amount": "2.3", + "currencyCode": "UAH" + }, + "emailMarketingConsent": { + "marketingState": "NOT_SUBSCRIBED", + "consentUpdatedAt": null, + "marketingOptInLevel": "SINGLE_OPT_IN" + }, + "orders": { + "edges": [ + { + "node": { + "id": "gid://shopify/Order/5661348102464", + "legacyResourceId": "5661348102464", + "createdAt": "2024-01-18T17:31:51Z", + "displayFinancialStatus": "PENDING", + "displayFulfillmentStatus": "UNFULFILLED", + "name": "#1021", + "customer": { + "lastName": "Hatfield", + "firstName": "Christian", + "displayName": "Christian Hatfield" + }, + "lineItems": { + "edges": [ + { + "node": { + "id": "gid://shopify/LineItem/14438955745600", + "title": "THE CREATION OF ADAM | MICHELANGELO" + } + }, + { + "node": { + "id": "gid://shopify/LineItem/14438955778368", + "title": "THE NIGHT WATCH | REMBRANDT VAN RIJN" + } + } + ] + } + } + }, + { + "node": { + "id": "gid://shopify/Order/5661348233536", + "legacyResourceId": "5661348233536", + "createdAt": "2024-01-18T17:31:57Z", + "displayFinancialStatus": "PAID", + "displayFulfillmentStatus": "UNFULFILLED", + "name": "#1022", + "customer": { + "lastName": "Hatfield", + "firstName": "Christian", + "displayName": "Christian Hatfield" + }, + "lineItems": { + "edges": [ + { + "node": { + "id": "gid://shopify/LineItem/14438955876672", + "title": "GIRL WITH A PEARL EARRING | JOHANNES VERMEER" + } + } + ] + } + } + }, + { + "node": { + "id": "gid://shopify/Order/5661348528448", + "legacyResourceId": "5661348528448", + "createdAt": "2024-01-18T17:32:03Z", + "displayFinancialStatus": "PAID", + "displayFulfillmentStatus": "UNFULFILLED", + "name": "#1023", + "customer": { + "lastName": "Hatfield", + "firstName": "Christian", + "displayName": "Christian Hatfield" + }, + "lineItems": { + "edges": [ + { + "node": { + "id": "gid://shopify/LineItem/14438956433728", + "title": "GUERNICA | PABLO PICASSO" + } + } + ] + } + } + }, + { + "node": { + "id": "gid://shopify/Order/5661348692288", + "legacyResourceId": "5661348692288", + "createdAt": "2024-01-18T17:32:09Z", + "displayFinancialStatus": "REFUNDED", + "displayFulfillmentStatus": "UNFULFILLED", + "name": "#1024", + "customer": { + "lastName": "Hatfield", + "firstName": "Christian", + "displayName": "Christian Hatfield" + }, + "lineItems": { + "edges": [ + { + "node": { + "id": "gid://shopify/LineItem/14438956663104", + "title": "GIRL WITH A PEARL EARRING | JOHANNES VERMEER" + } + }, + { + "node": { + "id": "gid://shopify/LineItem/14438956695872", + "title": "THE PERSISTENCE OF MEMORY | SALVADOR DALI" + } + }, + { + "node": { + "id": "gid://shopify/LineItem/14438956728640", + "title": "THE CREATION OF ADAM | MICHELANGELO" + } + } + ] + } + } + }, + { + "node": { + "id": "gid://shopify/Order/5661349904704", + "legacyResourceId": "5661349904704", + "createdAt": "2024-01-18T17:32:55Z", + "displayFinancialStatus": "PAID", + "displayFulfillmentStatus": "UNFULFILLED", + "name": "#1025", + "customer": { + "lastName": "Hatfield", + "firstName": "Christian", + "displayName": "Christian Hatfield" + }, + "lineItems": { + "edges": [ + { + "node": { + "id": "gid://shopify/LineItem/14438959481152", + "title": "THE NIGHT WATCH | REMBRANDT VAN RIJN" + } + } + ] + } + } + }, + { + "node": { + "id": "gid://shopify/Order/5661350199616", + "legacyResourceId": "5661350199616", + "createdAt": "2024-01-18T17:33:01Z", + "displayFinancialStatus": "PAID", + "displayFulfillmentStatus": "UNFULFILLED", + "name": "#1026", + "customer": { + "lastName": "Hatfield", + "firstName": "Christian", + "displayName": "Christian Hatfield" + }, + "lineItems": { + "edges": [ + { + "node": { + "id": "gid://shopify/LineItem/14438960234816", + "title": "STARRY NIGHT | VINCENT VAN GOGH" + } + } + ] + } + } + }, + { + "node": { + "id": "gid://shopify/Order/5661350396224", + "legacyResourceId": "5661350396224", + "createdAt": "2024-01-18T17:33:07Z", + "displayFinancialStatus": "PAID", + "displayFulfillmentStatus": "UNFULFILLED", + "name": "#1027", + "customer": { + "lastName": "Hatfield", + "firstName": "Christian", + "displayName": "Christian Hatfield" + }, + "lineItems": { + "edges": [ + { + "node": { + "id": "gid://shopify/LineItem/14438960496960", + "title": "THE CREATION OF ADAM | MICHELANGELO" + } + } + ] + } + } + }, + { + "node": { + "id": "gid://shopify/Order/5661350527296", + "legacyResourceId": "5661350527296", + "createdAt": "2024-01-18T17:33:13Z", + "displayFinancialStatus": "REFUNDED", + "displayFulfillmentStatus": "UNFULFILLED", + "name": "#1028", + "customer": { + "lastName": "Hatfield", + "firstName": "Christian", + "displayName": "Christian Hatfield" + }, + "lineItems": { + "edges": [ + { + "node": { + "id": "gid://shopify/LineItem/14438960660800", + "title": "THE LAST SUPPER | LEONARDO DA VINCI" + } + }, + { + "node": { + "id": "gid://shopify/LineItem/14438960693568", + "title": "MONA LISA | LEONARDO DA VINCI" + } + }, + { + "node": { + "id": "gid://shopify/LineItem/14438960726336", + "title": "THE PERSISTENCE OF MEMORY | SALVADOR DALI" + } + } + ] + } + } + }, + { + "node": { + "id": "gid://shopify/Order/5661351575872", + "legacyResourceId": "5661351575872", + "createdAt": "2024-01-18T17:33:59Z", + "displayFinancialStatus": "REFUNDED", + "displayFulfillmentStatus": "UNFULFILLED", + "name": "#1029", + "customer": { + "lastName": "Hatfield", + "firstName": "Christian", + "displayName": "Christian Hatfield" + }, + "lineItems": { + "edges": [ + { + "node": { + "id": "gid://shopify/LineItem/14438961938752", + "title": "GIRL WITH A PEARL EARRING | JOHANNES VERMEER" + } + }, + { + "node": { + "id": "gid://shopify/LineItem/14438961971520", + "title": "THE SCREAM | EDVARD MUNCH" + } + } + ] + } + } + }, + { + "node": { + "id": "gid://shopify/Order/5661351641408", + "legacyResourceId": "5661351641408", + "createdAt": "2024-01-18T17:34:05Z", + "displayFinancialStatus": "PENDING", + "displayFulfillmentStatus": "UNFULFILLED", + "name": "#1030", + "customer": { + "lastName": "Hatfield", + "firstName": "Christian", + "displayName": "Christian Hatfield" + }, + "lineItems": { + "edges": [ + { + "node": { + "id": "gid://shopify/LineItem/14438962069824", + "title": "THE NIGHT WATCH | REMBRANDT VAN RIJN" + } + }, + { + "node": { + "id": "gid://shopify/LineItem/14438962102592", + "title": "THE PERSISTENCE OF MEMORY | SALVADOR DALI" + } + }, + { + "node": { + "id": "gid://shopify/LineItem/14438962135360", + "title": "GIRL WITH A PEARL EARRING | JOHANNES VERMEER" + } + } + ] + } + } + }, + { + "node": { + "id": "gid://shopify/Order/5661351903552", + "legacyResourceId": "5661351903552", + "createdAt": "2024-01-18T17:34:10Z", + "displayFinancialStatus": "PENDING", + "displayFulfillmentStatus": "UNFULFILLED", + "name": "#1031", + "customer": { + "lastName": "Hatfield", + "firstName": "Christian", + "displayName": "Christian Hatfield" + }, + "lineItems": { + "edges": [ + { + "node": { + "id": "gid://shopify/LineItem/14438962397504", + "title": "SELF-PORTRAIT WITHOUT BEARD | VINCENT VAN GOGH" + } + }, + { + "node": { + "id": "gid://shopify/LineItem/14438962430272", + "title": "GUERNICA | PABLO PICASSO" + } + }, + { + "node": { + "id": "gid://shopify/LineItem/14438962463040", + "title": "STARRY NIGHT | VINCENT VAN GOGH" + } + } + ] + } + } + }, + { + "node": { + "id": "gid://shopify/Order/5661352067392", + "legacyResourceId": "5661352067392", + "createdAt": "2024-01-18T17:34:16Z", + "displayFinancialStatus": "PAID", + "displayFulfillmentStatus": "UNFULFILLED", + "name": "#1032", + "customer": { + "lastName": "Hatfield", + "firstName": "Christian", + "displayName": "Christian Hatfield" + }, + "lineItems": { + "edges": [ + { + "node": { + "id": "gid://shopify/LineItem/14438962692416", + "title": "SELF-PORTRAIT WITHOUT BEARD | VINCENT VAN GOGH" + } + } + ] + } + } + }, + { + "node": { + "id": "gid://shopify/Order/5661352952128", + "legacyResourceId": "5661352952128", + "createdAt": "2024-01-18T17:35:02Z", + "displayFinancialStatus": "REFUNDED", + "displayFulfillmentStatus": "UNFULFILLED", + "name": "#1033", + "customer": { + "lastName": "Hatfield", + "firstName": "Christian", + "displayName": "Christian Hatfield" + }, + "lineItems": { + "edges": [ + { + "node": { + "id": "gid://shopify/LineItem/14438963970368", + "title": "MONA LISA | LEONARDO DA VINCI" + } + }, + { + "node": { + "id": "gid://shopify/LineItem/14438964003136", + "title": "THE LAST SUPPER | LEONARDO DA VINCI" + } + }, + { + "node": { + "id": "gid://shopify/LineItem/14438964035904", + "title": "THE SCREAM | EDVARD MUNCH" + } + } + ] + } + } + }, + { + "node": { + "id": "gid://shopify/Order/5661353115968", + "legacyResourceId": "5661353115968", + "createdAt": "2024-01-18T17:35:08Z", + "displayFinancialStatus": "PENDING", + "displayFulfillmentStatus": "UNFULFILLED", + "name": "#1034", + "customer": { + "lastName": "Hatfield", + "firstName": "Christian", + "displayName": "Christian Hatfield" + }, + "lineItems": { + "edges": [ + { + "node": { + "id": "gid://shopify/LineItem/14438964232512", + "title": "MONA LISA | LEONARDO DA VINCI" + } + } + ] + } + } + }, + { + "node": { + "id": "gid://shopify/Order/5661353345344", + "legacyResourceId": "5661353345344", + "createdAt": "2024-01-18T17:35:14Z", + "displayFinancialStatus": "REFUNDED", + "displayFulfillmentStatus": "UNFULFILLED", + "name": "#1035", + "customer": { + "lastName": "Hatfield", + "firstName": "Christian", + "displayName": "Christian Hatfield" + }, + "lineItems": { + "edges": [ + { + "node": { + "id": "gid://shopify/LineItem/14438964527424", + "title": "THE NIGHT WATCH | REMBRANDT VAN RIJN" + } + }, + { + "node": { + "id": "gid://shopify/LineItem/14438964560192", + "title": "GIRL WITH A PEARL EARRING | JOHANNES VERMEER" + } + }, + { + "node": { + "id": "gid://shopify/LineItem/14438964592960", + "title": "SELF-PORTRAIT WITHOUT BEARD | VINCENT VAN GOGH" + } + } + ] + } + } + }, + { + "node": { + "id": "gid://shopify/Order/5661353443648", + "legacyResourceId": "5661353443648", + "createdAt": "2024-01-18T17:35:19Z", + "displayFinancialStatus": "PENDING", + "displayFulfillmentStatus": "UNFULFILLED", + "name": "#1036", + "customer": { + "lastName": "Hatfield", + "firstName": "Christian", + "displayName": "Christian Hatfield" + }, + "lineItems": { + "edges": [ + { + "node": { + "id": "gid://shopify/LineItem/14438964756800", + "title": "STARRY NIGHT | VINCENT VAN GOGH" + } + } + ] + } + } + }, + { + "node": { + "id": "gid://shopify/Order/5661354066240", + "legacyResourceId": "5661354066240", + "createdAt": "2024-01-18T17:36:06Z", + "displayFinancialStatus": "REFUNDED", + "displayFulfillmentStatus": "UNFULFILLED", + "name": "#1037", + "customer": { + "lastName": "Hatfield", + "firstName": "Christian", + "displayName": "Christian Hatfield" + }, + "lineItems": { + "edges": [ + { + "node": { + "id": "gid://shopify/LineItem/14438966001984", + "title": "THE SCREAM | EDVARD MUNCH" + } + }, + { + "node": { + "id": "gid://shopify/LineItem/14438966034752", + "title": "STARRY NIGHT | VINCENT VAN GOGH" + } + }, + { + "node": { + "id": "gid://shopify/LineItem/14438966067520", + "title": "MONA LISA | LEONARDO DA VINCI" + } + } + ] + } + } + }, + { + "node": { + "id": "gid://shopify/Order/5661354164544", + "legacyResourceId": "5661354164544", + "createdAt": "2024-01-18T17:36:12Z", + "displayFinancialStatus": "PAID", + "displayFulfillmentStatus": "UNFULFILLED", + "name": "#1038", + "customer": { + "lastName": "Hatfield", + "firstName": "Christian", + "displayName": "Christian Hatfield" + }, + "lineItems": { + "edges": [ + { + "node": { + "id": "gid://shopify/LineItem/14438966198592", + "title": "STARRY NIGHT | VINCENT VAN GOGH" + } + }, + { + "node": { + "id": "gid://shopify/LineItem/14438966231360", + "title": "GUERNICA | PABLO PICASSO" + } + }, + { + "node": { + "id": "gid://shopify/LineItem/14438966264128", + "title": "THE LAST SUPPER | LEONARDO DA VINCI" + } + } + ] + } + } + }, + { + "node": { + "id": "gid://shopify/Order/5661354197312", + "legacyResourceId": "5661354197312", + "createdAt": "2024-01-18T17:36:17Z", + "displayFinancialStatus": "PENDING", + "displayFulfillmentStatus": "UNFULFILLED", + "name": "#1039", + "customer": { + "lastName": "Hatfield", + "firstName": "Christian", + "displayName": "Christian Hatfield" + }, + "lineItems": { + "edges": [ + { + "node": { + "id": "gid://shopify/LineItem/14438966296896", + "title": "GIRL WITH A PEARL EARRING | JOHANNES VERMEER" + } + } + ] + } + } + }, + { + "node": { + "id": "gid://shopify/Order/5661354361152", + "legacyResourceId": "5661354361152", + "createdAt": "2024-01-18T17:36:23Z", + "displayFinancialStatus": "PAID", + "displayFulfillmentStatus": "UNFULFILLED", + "name": "#1040", + "customer": { + "lastName": "Hatfield", + "firstName": "Christian", + "displayName": "Christian Hatfield" + }, + "lineItems": { + "edges": [ + { + "node": { + "id": "gid://shopify/LineItem/14438966526272", + "title": "STARRY NIGHT | VINCENT VAN GOGH" + } + }, + { + "node": { + "id": "gid://shopify/LineItem/14438966559040", + "title": "STARRY NIGHT | VINCENT VAN GOGH" + } + }, + { + "node": { + "id": "gid://shopify/LineItem/14438966591808", + "title": "GUERNICA | PABLO PICASSO" + } + } + ] + } + } + } + ] + }, + "events": { + "edges": [] + } + } + }, + "extensions": { + "cost": { + "requestedQueryCost": 606, + "actualQueryCost": 126, + "throttleStatus": { + "maximumAvailable": 1000.0, + "currentlyAvailable": 874, + "restoreRate": 50.0 + } + } + } +} diff --git a/testing/mocks/mockCustomersSearch.json b/testing/mocks/mockCustomersSearch.json new file mode 100644 index 0000000..89ec009 --- /dev/null +++ b/testing/mocks/mockCustomersSearch.json @@ -0,0 +1,55 @@ +{ + "data": { + "customers": { + "edges": [ + { + "node": { + "id": "gid://shopify/Customer/7982046085440", + "createdAt": "2024-01-18T17:31:36Z", + "displayName": "Christian Hatfield", + "email": "egnition_sample_60@egnition.com", + "hasTimelineComment": false, + "locale": "en", + "note": null, + "phone": "+12423337689" + } + }, + { + "node": { + "id": "gid://shopify/Customer/7982046183744", + "createdAt": "2024-01-18T17:31:37Z", + "displayName": "Hamish Orr", + "email": "egnition_sample_96@egnition.com", + "hasTimelineComment": false, + "locale": "en", + "note": null, + "phone": "+38614296549" + } + }, + { + "node": { + "id": "gid://shopify/Customer/7982046347584", + "createdAt": "2024-01-18T17:31:38Z", + "displayName": "Ulric Lynch", + "email": "egnition_sample_98@egnition.com", + "hasTimelineComment": false, + "locale": "en", + "note": null, + "phone": "+262269600412" + } + } + ] + } + }, + "extensions": { + "cost": { + "requestedQueryCost": 102, + "actualQueryCost": 5, + "throttleStatus": { + "maximumAvailable": 1000.0, + "currentlyAvailable": 995, + "restoreRate": 50.0 + } + } + } +} diff --git a/testing/mocks/mockGetCustomersNotExist.json b/testing/mocks/mockGetCustomersNotExist.json new file mode 100644 index 0000000..3e4aab4 --- /dev/null +++ b/testing/mocks/mockGetCustomersNotExist.json @@ -0,0 +1,18 @@ +{ + "data": { + "customers": { + "edges": [] + } + }, + "extensions": { + "cost": { + "requestedQueryCost": 102, + "actualQueryCost": 2, + "throttleStatus": { + "maximumAvailable": 1000.0, + "currentlyAvailable": 998, + "restoreRate": 50.0 + } + } + } +}