Skip to content

Commit

Permalink
Merge pull request #1 from bigcommerce/main
Browse files Browse the repository at this point in the history
Rebase 1
  • Loading branch information
basslikethefish authored Oct 22, 2024
2 parents 971033f + 53599e6 commit f3789b0
Show file tree
Hide file tree
Showing 160 changed files with 5,438 additions and 4,482 deletions.
6 changes: 0 additions & 6 deletions .changeset/clever-fans-tickle.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/heavy-toes-own.md

This file was deleted.

9 changes: 9 additions & 0 deletions .changeset/silent-rats-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@bigcommerce/catalyst-core": minor
---

Bump `next-intl` which includes [some minor changes and updated APIs]((https://next-intl-docs.vercel.app/blog/next-intl-3-22)):

+ Use new `createNavigation` api.
+ Pass `locale` to redirects.
+ `setRequestLocale` is no longer unstable.
5 changes: 5 additions & 0 deletions .changeset/thick-sloths-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bigcommerce/catalyst-core": patch
---

remove unnecessary fields from create account form
5 changes: 5 additions & 0 deletions .changeset/translations-patch-53688cca.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bigcommerce/catalyst-core": patch
---

Update translations.
4 changes: 0 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
# The control panel URL is of the form `https://store-{hash}.mybigcommerce.com`.
BIGCOMMERCE_STORE_HASH=

# The access token from a store-level API account. The only scope required to run Catalyst is Carts `manage`.
# See https://developer.bigcommerce.com/docs/start/authentication/api-accounts#store-level-api-accounts
BIGCOMMERCE_ACCESS_TOKEN=

# A bearer token that authorizes server-to-server requests to the GraphQL Storefront API
# See https://developer.bigcommerce.com/docs/rest-authentication/tokens/customer-impersonation-token
BIGCOMMERCE_CUSTOMER_IMPERSONATION_TOKEN=
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ env:
TURBO_REMOTE_CACHE_SIGNATURE_KEY: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}
BIGCOMMERCE_STORE_HASH: ${{ secrets.BIGCOMMERCE_STORE_HASH }}
BIGCOMMERCE_CUSTOMER_IMPERSONATION_TOKEN: ${{ secrets.BIGCOMMERCE_CUSTOMER_IMPERSONATION_TOKEN }}
BIGCOMMERCE_CHANNEL_ID: ${{ secrets.BIGCOMMERCE_CHANNEL_ID }}

jobs:
lint-typecheck:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/changesets-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:

- name: Build Packages
run: pnpm --filter "./packages/**" build
env:
CLI_SEGMENT_WRITE_KEY: ${{ secrets.CLI_SEGMENT_WRITE_KEY }}

- name: Create Release Pull Request or Publish to npm
id: changesets
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/translations-changeset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Create translations patch

on:
pull_request:
types:
- opened
branches:
- main

jobs:
create-translations-patch:
if: github.actor == 'bc-svc-local'
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Use commit SHA for filename
id: generate-sha
run: |
short_sha=$(echo "${GITHUB_SHA}" | cut -c1-8)
echo "SHORT_SHA=$short_sha" >> $GITHUB_OUTPUT
- name: Create a translations changeset
env:
SHORT_SHA: ${{ steps.generate-sha.outputs.SHORT_SHA }}
run: |
mkdir -p .changeset
echo "---
\"@bigcommerce/catalyst-core\": patch
---
Update translations." > .changeset/translations-patch-$SHORT_SHA.md
- name: Commit changeset
env:
SHORT_SHA: ${{ steps.generate-sha.outputs.SHORT_SHA }}
run: |
git config --global user.name 'bc-svc-local'
git config --global user.email '[email protected]'
git add .changeset/translations-patch-$SHORT_SHA.md
git commit -m "chore(core): create translations patch"
- name: Push changeset
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} HEAD:${{ github.event.pull_request.head.ref }}
4 changes: 0 additions & 4 deletions core/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
# The control panel URL is of the form `https://store-{hash}.mybigcommerce.com`.
BIGCOMMERCE_STORE_HASH=

# The access token from a store-level API account. The only scope required to run Catalyst is Carts `manage`.
# See https://developer.bigcommerce.com/docs/start/authentication/api-accounts#store-level-api-accounts
BIGCOMMERCE_ACCESS_TOKEN=

# A bearer token that authorizes server-to-server requests to the GraphQL Storefront API
# See https://developer.bigcommerce.com/docs/rest-authentication/tokens/customer-impersonation-token
BIGCOMMERCE_CUSTOMER_IMPERSONATION_TOKEN=
Expand Down
70 changes: 70 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,75 @@
# Changelog

## 0.17.1

### Patch Changes

- Updated dependencies [[`d4120d3`](https://github.com/bigcommerce/catalyst/commit/d4120d39c10398e842a7ebe14ada685ec8aae3a8)]:
- @bigcommerce/catalyst-client@0.11.0

## 0.17.0

### Minor Changes

- [#1401](https://github.com/bigcommerce/catalyst/pull/1401) [`3095002`](https://github.com/bigcommerce/catalyst/commit/3095002d7a10b9c4058016076deb7a45fc8ae7bb) Thanks [@bookernath](https://github.com/bookernath)! - Add dynamic robots.txt from control panel settings

### Patch Changes

- [#1477](https://github.com/bigcommerce/catalyst/pull/1477) [`79e705f`](https://github.com/bigcommerce/catalyst/commit/79e705f151a733a811effed40757030aba6b6300) Thanks [@deini](https://github.com/deini)! - Breadcrumbs for top level category pages are no longer rendered

- [#1467](https://github.com/bigcommerce/catalyst/pull/1467) [`e763a83`](https://github.com/bigcommerce/catalyst/commit/e763a83bcd4b8b5311586247291338eb65fbc476) Thanks [@deini](https://github.com/deini)! - Fixes an issue when a numeric product option set to a minimum <= 0 breaks the counter component.

- [#1459](https://github.com/bigcommerce/catalyst/pull/1459) [`b4485c7`](https://github.com/bigcommerce/catalyst/commit/b4485c76de8c83546c68a7b50fcb7991603dbf6e) Thanks [@chanceaclark](https://github.com/chanceaclark)! - Updates the with-routes middleware to fallback on locale based rewrite logic if the redirect is a dynamic entity redirect.

- [#1469](https://github.com/bigcommerce/catalyst/pull/1469) [`8e9e7f3`](https://github.com/bigcommerce/catalyst/commit/8e9e7f3d40545004b080146b4dbb42f4ac7cf17c) Thanks [@chanceaclark](https://github.com/chanceaclark)! - Fixes the product quantity reseting back to the previous value when adjusting the quantity fails.

- [#1476](https://github.com/bigcommerce/catalyst/pull/1476) [`d47e3ac`](https://github.com/bigcommerce/catalyst/commit/d47e3aceb244713bc996287319357e6af3d865ed) Thanks [@deini](https://github.com/deini)! - adds an empty state to category pages

- [#1458](https://github.com/bigcommerce/catalyst/pull/1458) [`3d67f8d`](https://github.com/bigcommerce/catalyst/commit/3d67f8d0d1776d747e9aa485b0b29a738eeacf3c) Thanks [@chanceaclark](https://github.com/chanceaclark)! - Add no-store to mutations that are rate limited.

- [#1453](https://github.com/bigcommerce/catalyst/pull/1453) [`1c8b042`](https://github.com/bigcommerce/catalyst/commit/1c8b04278074eb55358a5515f330a011de9561b5) Thanks [@bc-svc-local](https://github.com/bc-svc-local)! - Update translations.

- Updated dependencies [[`2d1526a`](https://github.com/bigcommerce/catalyst/commit/2d1526a50402b2eb677abd55f19fb904234d1a84)]:
- @bigcommerce/catalyst-client@0.10.0

## 0.16.0

### Minor Changes

- [#1410](https://github.com/bigcommerce/catalyst/pull/1410) [`53cca82`](https://github.com/bigcommerce/catalyst/commit/53cca82611272fc3be24505b7c6d5866f10c87fd) Thanks [@bookernath](https://github.com/bookernath)! - Move /reset page to /login/forgot-password in order to reduce top-level routes.

- [#1384](https://github.com/bigcommerce/catalyst/pull/1384) [`17692ca`](https://github.com/bigcommerce/catalyst/commit/17692caa3ff9b25180359d8a020470ece3e589f6) Thanks [@chanceaclark](https://github.com/chanceaclark)! - Pass customer ip address into requests that don't rely on cached values.

- [#1388](https://github.com/bigcommerce/catalyst/pull/1388) [`a309a4d`](https://github.com/bigcommerce/catalyst/commit/a309a4dd47083a58c998a4f6d169185177cca571) Thanks [@deini](https://github.com/deini)! - wraps header and footer in suspense boundaries

### Patch Changes

- [#1374](https://github.com/bigcommerce/catalyst/pull/1374) [`1f76f61`](https://github.com/bigcommerce/catalyst/commit/1f76f615b38bb41db770653bd8e7947cd6361b18) Thanks [@jorgemoya](https://github.com/jorgemoya)! - Prepend locale for redirected urls in tests.
More info: https://github.com/amannn/next-intl/issues/1335

- [#1373](https://github.com/bigcommerce/catalyst/pull/1373) [`971033f`](https://github.com/bigcommerce/catalyst/commit/971033fc63181bad15aa46abb65b0d44501922c9) Thanks [@jorgemoya](https://github.com/jorgemoya)! - Add missing metadata in account settings page.

- [#1370](https://github.com/bigcommerce/catalyst/pull/1370) [`655d518`](https://github.com/bigcommerce/catalyst/commit/655d518b2fd662614539467fff940b2b5ff78567) Thanks [@bc-svc-local](https://github.com/bc-svc-local)! - Update translations.

- [#1446](https://github.com/bigcommerce/catalyst/pull/1446) [`ba4820b`](https://github.com/bigcommerce/catalyst/commit/ba4820bf6dd36d0155028ad3db094bd9745d5d94) Thanks [@deini](https://github.com/deini)! - Fixes a bug where product variant was not reliably being selected on PDP when using pre-selected options.

- [#1391](https://github.com/bigcommerce/catalyst/pull/1391) [`4d64c31`](https://github.com/bigcommerce/catalyst/commit/4d64c31d4765dd72c81c1836b66aa1d7cb34b5f5) Thanks [@bookernath](https://github.com/bookernath)! - Get lossy image from API instead of setting param in code

- [#1389](https://github.com/bigcommerce/catalyst/pull/1389) [`a4eaff6`](https://github.com/bigcommerce/catalyst/commit/a4eaff6bb2520f748630e24a6a28ca31cd2eb2c3) Thanks [@bookernath](https://github.com/bookernath)! - Add additional IP address header

- [#1402](https://github.com/bigcommerce/catalyst/pull/1402) [`6e75ef5`](https://github.com/bigcommerce/catalyst/commit/6e75ef5097e0f3227c04ac0d9d7bbc484513bcce) Thanks [@bc-yevhenii-buliuk](https://github.com/bc-yevhenii-buliuk)! - fixing the problem with submitting the password change form

- [#1407](https://github.com/bigcommerce/catalyst/pull/1407) [`ac9832f`](https://github.com/bigcommerce/catalyst/commit/ac9832fcc61f01413a5b8f101f5f27c53ca1fce5) Thanks [@bc-svc-local](https://github.com/bc-svc-local)! - Update translations.

- [#1392](https://github.com/bigcommerce/catalyst/pull/1392) [`76227ac`](https://github.com/bigcommerce/catalyst/commit/76227ac06bb349f604f1d2d4a9b68e7d0869eba4) Thanks [@bc-svc-local](https://github.com/bc-svc-local)! - Update translations.

- [#1424](https://github.com/bigcommerce/catalyst/pull/1424) [`4874add`](https://github.com/bigcommerce/catalyst/commit/4874addfbdde90ac45aa57c10767587ba4c50735) Thanks [@bc-svc-local](https://github.com/bc-svc-local)! - Update translations.

- [#1445](https://github.com/bigcommerce/catalyst/pull/1445) [`ba3f513`](https://github.com/bigcommerce/catalyst/commit/ba3f513ac4242ce6883ad6ab635d38156a271ca9) Thanks [@deini](https://github.com/deini)! - Adds optimistic updates to all "Add to cart" buttons. This change makes the UI feel snappier and give quick feedback on user interaction.

- Updated dependencies [[`17692ca`](https://github.com/bigcommerce/catalyst/commit/17692caa3ff9b25180359d8a020470ece3e589f6)]:
- @bigcommerce/catalyst-client@0.9.0

## 0.15.0

### Minor Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export const changePassword = async (_previousState: unknown, formData: FormData
newPassword: parsedData.newPassword,
},
},
fetchOptions: {
cache: 'no-store',
},
});

const result = response.data.customer.resetPassword;
Expand Down
5 changes: 3 additions & 2 deletions core/app/[locale]/(default)/(auth)/change-password/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useTranslations } from 'next-intl';
import { useLocale, useTranslations } from 'next-intl';
import { getTranslations } from 'next-intl/server';

import { redirect } from '~/i18n/routing';
Expand All @@ -22,12 +22,13 @@ interface Props {

export default function ChangePassword({ searchParams }: Props) {
const t = useTranslations('ChangePassword');
const locale = useLocale();

const customerId = searchParams.c;
const customerToken = searchParams.t;

if (!customerId || !customerToken) {
redirect('/login');
redirect({ href: '/login', locale });
}

if (customerId && customerToken) {
Expand Down
5 changes: 4 additions & 1 deletion core/app/[locale]/(default)/(auth)/login/_actions/login.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
'use server';

import { isRedirectError } from 'next/dist/client/components/redirect';
import { getLocale } from 'next-intl/server';

import { Credentials, signIn } from '~/auth';
import { redirect } from '~/i18n/routing';

export const login = async (_previousState: unknown, formData: FormData) => {
try {
const locale = await getLocale();

const credentials = Credentials.parse({
email: formData.get('email'),
password: formData.get('password'),
Expand All @@ -19,7 +22,7 @@ export const login = async (_previousState: unknown, formData: FormData) => {
redirect: false,
});

redirect('/account');
redirect({ href: '/account', locale });
} catch (error: unknown) {
// We need to throw this error to trigger the redirect as Next.js uses error boundaries to redirect.
if (isRedirectError(error)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ export const LoginForm = () => {
</FormSubmit>
<Link
className="my-5 inline-flex items-center justify-start font-semibold text-primary hover:text-secondary md:my-0"
href="/reset"
href="/login/forgot-password"
>
{t('Form.resetPassword')}
{t('Form.forgotPassword')}
</Link>
</div>
</Form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const resetPassword = async ({
path,
reCaptchaToken,
}: SubmitResetPasswordForm) => {
const t = await getTranslations('Reset');
const t = await getTranslations('Login.ForgotPassword');

try {
const parsedData = ResetPasswordSchema.parse({
Expand All @@ -53,6 +53,9 @@ export const resetPassword = async ({
},
...(reCaptchaToken && { reCaptchaV2: { token: reCaptchaToken } }),
},
fetchOptions: {
cache: 'no-store',
},
});

const result = response.data.customer.requestResetPassword;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface FormStatus {
}

const SubmitButton = () => {
const t = useTranslations('Reset.Form');
const t = useTranslations('Login.ForgotPassword.Form');

const { pending } = useFormStatus();

Expand All @@ -52,7 +52,7 @@ const SubmitButton = () => {
};

export const ResetPasswordForm = ({ reCaptchaSettings }: Props) => {
const t = useTranslations('Reset.Form');
const t = useTranslations('Login.ForgotPassword.Form');

const form = useRef<HTMLFormElement>(null);
const [formStatus, setFormStatus] = useState<FormStatus | null>(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ const ResetPageQuery = graphql(
);

export async function generateMetadata() {
const t = await getTranslations('Reset');
const t = await getTranslations('Login.ForgotPassword');

return {
title: t('title'),
};
}

export default async function Reset() {
const t = await getTranslations('Reset');
const t = await getTranslations('Login.ForgotPassword');

const { data } = await client.fetch({
document: ResetPageQuery,
Expand Down
4 changes: 2 additions & 2 deletions core/app/[locale]/(default)/(auth)/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useTranslations } from 'next-intl';
import { getTranslations, unstable_setRequestLocale } from 'next-intl/server';
import { getTranslations, setRequestLocale } from 'next-intl/server';

import { Link } from '~/components/link';
import { Button } from '~/components/ui/button';
Expand All @@ -20,7 +20,7 @@ interface Props {
}

export default function Login({ params: { locale } }: Props) {
unstable_setRequestLocale(locale);
setRequestLocale(locale);

const t = useTranslations('Login');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
'use server';

import { isRedirectError } from 'next/dist/client/components/redirect';
import { getLocale } from 'next-intl/server';

import { Credentials, signIn } from '~/auth';
import { redirect } from '~/i18n/routing';

export const login = async (formData: FormData) => {
const locale = await getLocale();

try {
const credentials = Credentials.parse({
email: formData.get('customer-email'),
Expand All @@ -19,7 +22,7 @@ export const login = async (formData: FormData) => {
redirect: false,
});

redirect('/account');
redirect({ href: '/account', locale });
} catch (error: unknown) {
if (isRedirectError(error)) {
throw error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ interface RegisterCustomerForm {
}

const isRegisterCustomerInput = (data: unknown): data is RegisterCustomerInput => {
if (typeof data === 'object' && data !== null && 'email' in data && 'address' in data) {
if (typeof data === 'object' && data !== null && 'email' in data) {
return true;
}

Expand Down Expand Up @@ -71,6 +71,9 @@ export const registerCustomer = async ({ formData, reCaptchaToken }: RegisterCus
input: parsedData,
...(reCaptchaToken && { reCaptchaV2: { token: reCaptchaToken } }),
},
fetchOptions: {
cache: 'no-store',
},
});

const result = response.data.customer.registerCustomer;
Expand Down
Loading

0 comments on commit f3789b0

Please sign in to comment.