Skip to content

Commit

Permalink
Remove custom 'old' client
Browse files Browse the repository at this point in the history
  • Loading branch information
CNanninga committed Feb 1, 2024
1 parent fec53de commit 42faf83
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 122 deletions.
13 changes: 7 additions & 6 deletions apps/core/client/management/createCustomer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import client from "..";

const isObject = (obj: unknown): obj is Record<string, unknown> => {
return typeof obj === 'object' && obj !== null;
};
Expand Down Expand Up @@ -31,11 +33,10 @@ const isCreateCustomerResponse = (resp: unknown): resp is CreateCustomerResponse
}

export const createCustomer = async (
customerData: { email: string, first_name: string, last_name: string },
storeHash: string,
xAuthToken: string,
channelId?: string
customerData: { email: string, first_name: string, last_name: string }
) => {
const channelId = client.config.channelId;

const createCustomerBody = [
{
...customerData,
Expand All @@ -47,13 +48,13 @@ export const createCustomer = async (
];

const response = await fetch(
`https://api.bigcommerce.com/stores/${storeHash}/v3/customers`,
`https://api.bigcommerce.com/stores/${client.config.storeHash}/v3/customers`,
{
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'X-Auth-Token': xAuthToken,
'X-Auth-Token': client.config.xAuthToken,
},
cache: 'no-store',
body: JSON.stringify(createCustomerBody),
Expand Down
4 changes: 2 additions & 2 deletions apps/core/components/Forms/_actions/submitRegisterAccount.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use server';

import { z } from 'zod';
import { customOldClient } from '~/client';
import { createCustomer } from '~/client/management/createCustomer';

const CustomerAccountSchema = z.object({
email: z.string().email(),
Expand All @@ -24,7 +24,7 @@ export default async function submitRegisterAccount(
}
});

await customOldClient.createCustomer(customerData);
await createCustomer(customerData);

return {status: 'ok'};
}
114 changes: 0 additions & 114 deletions apps/core/lib/bc-custom-old-client/client.ts

This file was deleted.

0 comments on commit 42faf83

Please sign in to comment.