Skip to content

Commit

Permalink
fix: use suggested functions over deprecated ones
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemoya committed Nov 19, 2024
1 parent 2fd6ada commit d693ac4
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use server';

import { revalidatePath } from 'next/cache';
import { expirePath } from 'next/cache';
import { getTranslations } from 'next-intl/server';

import { getSessionCustomerAccessToken } from '~/auth';
Expand Down Expand Up @@ -50,7 +50,7 @@ export const deleteAddress = async (addressId: number): Promise<State> => {

const result = response.data.customer.deleteCustomerAddress;

revalidatePath('/account/addresses', 'page');
expirePath('/account/addresses', 'page');

if (result.errors.length === 0) {
return { status: 'success', message: t('success') };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use server';

import { revalidatePath } from 'next/cache';
import { expirePath } from 'next/cache';
import { getTranslations } from 'next-intl/server';

import { getSessionCustomerAccessToken } from '~/auth';
Expand Down Expand Up @@ -80,7 +80,7 @@ export const addAddress = async ({

const result = response.data.customer.addCustomerAddress;

revalidatePath('/account/addresses', 'page');
expirePath('/account/addresses', 'page');

if (result.errors.length === 0) {
return { status: 'success', message: t('success') };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use server';

import { revalidatePath } from 'next/cache';
import { expirePath } from 'next/cache';
import { getTranslations } from 'next-intl/server';

import { getSessionCustomerAccessToken } from '~/auth';
Expand Down Expand Up @@ -88,7 +88,7 @@ export const updateAddress = async ({

const result = response.data.customer.updateCustomerAddress;

revalidatePath('/account/addresses', 'page');
expirePath('/account/addresses', 'page');

if (result.errors.length === 0) {
return { status: 'success', message: t('success') };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use server';

import { revalidatePath } from 'next/cache';
import { expirePath } from 'next/cache';
import { getTranslations } from 'next-intl/server';

import { getSessionCustomerAccessToken } from '~/auth';
Expand Down Expand Up @@ -88,7 +88,7 @@ export const updateCustomer = async ({ formData, reCaptchaToken }: UpdateCustome
},
});

revalidatePath('/account/settings', 'page');
expirePath('/account/settings', 'page');

const result = response.data.customer.updateCustomer;

Expand Down
4 changes: 2 additions & 2 deletions core/app/[locale]/(default)/cart/_actions/remove-item.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use server';

import { revalidateTag } from 'next/cache';
import { expireTag } from 'next/cache';
import { cookies } from 'next/headers';

import { getSessionCustomerAccessToken } from '~/auth';
Expand Down Expand Up @@ -61,7 +61,7 @@ export async function removeItem({
cookieStore.delete('cartId');
}

revalidateTag(TAGS.cart);
expireTag(TAGS.cart);

return { status: 'success', data: cart };
} catch (error: unknown) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use server';

import { revalidateTag } from 'next/cache';
import { expireTag } from 'next/cache';
import { z } from 'zod';

import { getSessionCustomerAccessToken } from '~/auth';
Expand Down Expand Up @@ -54,7 +54,7 @@ export const applyCouponCode = async (formData: FormData) => {
return { status: 'error', error: 'Coupon code is invalid.' };
}

revalidateTag(TAGS.checkout);
expireTag(TAGS.checkout);

return { status: 'success', data: checkout };
} catch (error: unknown) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use server';

import { revalidateTag } from 'next/cache';
import { expireTag } from 'next/cache';
import { z } from 'zod';

import { getSessionCustomerAccessToken } from '~/auth';
Expand Down Expand Up @@ -54,7 +54,7 @@ export const removeCouponCode = async (formData: FormData) => {
return { status: 'error', error: 'Error ocurred removing coupon.' };
}

revalidateTag(TAGS.checkout);
expireTag(TAGS.checkout);

return { status: 'success', data: checkout };
} catch (error: unknown) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use server';

import { revalidatePath } from 'next/cache';
import { expirePath } from 'next/cache';
import { cookies } from 'next/headers';

import { getSessionCustomerAccessToken } from '~/auth';
Expand Down Expand Up @@ -83,7 +83,7 @@ export async function updateItemQuantity({
return { status: 'error', error: 'Failed to change product quantity in Cart' };
}

revalidatePath('/cart');
expirePath('/cart');

return { status: 'success', data: cart };
} catch (error: unknown) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use server';

import { revalidateTag } from 'next/cache';
import { expireTag } from 'next/cache';
import { z } from 'zod';

import { getSessionCustomerAccessToken } from '~/auth';
Expand Down Expand Up @@ -119,7 +119,7 @@ export const submitShippingInfo = async (
return { status: 'error', error: 'Failed to submit shipping info.' };
}

revalidateTag(TAGS.checkout);
expireTag(TAGS.checkout);

return { status: 'success', data: result };
} catch (error: unknown) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use server';

import { revalidateTag } from 'next/cache';
import { expireTag } from 'next/cache';
import { z } from 'zod';

import { getSessionCustomerAccessToken } from '~/auth';
Expand Down Expand Up @@ -57,7 +57,7 @@ export const submitShippingCosts = async (
return { status: 'error', error: 'Failed to submit shipping cost.' };
}

revalidateTag(TAGS.checkout);
expireTag(TAGS.checkout);

return { status: 'success', data: shippingCost };
} catch (error: unknown) {
Expand Down
6 changes: 3 additions & 3 deletions core/app/[locale]/(default)/compare/_actions/add-to-cart.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use server';

import { revalidateTag } from 'next/cache';
import { expireTag } from 'next/cache';
import { cookies } from 'next/headers';

import { addCartLineItem } from '~/client/mutations/add-cart-line-item';
Expand Down Expand Up @@ -33,7 +33,7 @@ export const addToCart = async (data: FormData) => {
return { status: 'error', error: 'Failed to add product to cart.' };
}

revalidateTag(TAGS.cart);
expireTag(TAGS.cart);

return { status: 'success', data: cart };
}
Expand All @@ -53,7 +53,7 @@ export const addToCart = async (data: FormData) => {
path: '/',
});

revalidateTag(TAGS.cart);
expireTag(TAGS.cart);

return { status: 'success', data: cart };
} catch (error: unknown) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use server';

import { removeEdgesAndNodes } from '@bigcommerce/catalyst-client';
import { revalidateTag } from 'next/cache';
import { expireTag } from 'next/cache';
import { cookies } from 'next/headers';

import { FragmentOf, graphql } from '~/client/graphql';
Expand Down Expand Up @@ -152,7 +152,7 @@ export async function handleAddToCart(
return { status: 'error', error: 'Failed to add product to cart.' };
}

revalidateTag(TAGS.cart);
expireTag(TAGS.cart);

return { status: 'success', data: cart };
}
Expand All @@ -179,7 +179,7 @@ export async function handleAddToCart(
path: '/',
});

revalidateTag(TAGS.cart);
expireTag(TAGS.cart);

return { status: 'success', data: cart };
} catch (error: unknown) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use server';

import { revalidateTag } from 'next/cache';
import { expireTag } from 'next/cache';
import { cookies } from 'next/headers';

import { addCartLineItem } from '~/client/mutations/add-cart-line-item';
Expand Down Expand Up @@ -32,7 +32,7 @@ export const addToCart = async (data: FormData) => {
return { status: 'error', error: 'Failed to add product to cart.' };
}

revalidateTag(TAGS.cart);
expireTag(TAGS.cart);

return { status: 'success', data: cart };
}
Expand All @@ -52,7 +52,7 @@ export const addToCart = async (data: FormData) => {
path: '/',
});

revalidateTag(TAGS.cart);
expireTag(TAGS.cart);

return { status: 'success', data: cart };
} catch (error: unknown) {
Expand Down

0 comments on commit d693ac4

Please sign in to comment.