From 643905adfe8491df3395ea921d6da325b9266698 Mon Sep 17 00:00:00 2001 From: Victor Gerbrands Date: Fri, 22 Nov 2024 13:52:25 +0100 Subject: [PATCH] chore: bring back updateCustomer --- src/lib/data/customer.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/lib/data/customer.ts b/src/lib/data/customer.ts index d3de1d7a..b421d212 100644 --- a/src/lib/data/customer.ts +++ b/src/lib/data/customer.ts @@ -5,7 +5,6 @@ import medusaError from "@lib/util/medusa-error" import { HttpTypes } from "@medusajs/types" import { revalidateTag } from "next/cache" import { redirect } from "next/navigation" -import { cache } from "react" import { getAuthHeaders, getCacheOptions, @@ -37,6 +36,22 @@ export const retrieveCustomer = .catch(() => null) } +export const updateCustomer = async (body: HttpTypes.StoreUpdateCustomer) => { + const headers = { + ...(await getAuthHeaders()), + } + + const updateRes = await sdk.store.customer + .update(body, {}, headers) + .then(({ customer }) => customer) + .catch(medusaError) + + const cacheTag = await getCacheTag("customers") + revalidateTag(cacheTag) + + return updateRes +} + export async function signup(_currentState: unknown, formData: FormData) { const password = formData.get("password") as string const customerForm = {