Skip to content

Commit

Permalink
Merge branch 'main' into mutation-customer-change-password
Browse files Browse the repository at this point in the history
  • Loading branch information
bc-alexsaiannyi committed Mar 26, 2024
2 parents d0894e5 + 29afe35 commit bb94f9a
Show file tree
Hide file tree
Showing 49 changed files with 521 additions and 1,899 deletions.
5 changes: 0 additions & 5 deletions .changeset/good-pets-dress.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/gorgeous-bugs-tickle.md

This file was deleted.

7 changes: 2 additions & 5 deletions .github/workflows/basic.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint, Typecheck, GraphQL Codegen
name: Lint, Typecheck, gql.tada

on:
push:
Expand Down Expand Up @@ -38,12 +38,9 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Graphql Tada
- name: Gql Tada
run: pnpm run -r generate

- name: Graphql Codegen
run: pnpm run -r codegen

- name: Lint
run: pnpm run lint -- --max-warnings=0

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div align="center">

[![MIT License](https://img.shields.io/github/license/bigcommerce/catalyst)](LICENSE.md)
[![Lighthouse Report](https://github.com/bigcommerce/catalyst/actions/workflows/lighthouse.yml/badge.svg)](https://github.com/bigcommerce/catalyst/actions/workflows/lighthouse.yml) [![Lint, Typecheck, GraphQL Codegen](https://github.com/bigcommerce/catalyst/actions/workflows/basic.yml/badge.svg)](https://github.com/bigcommerce/catalyst/actions/workflows/basic.yml)
[![Lighthouse Report](https://github.com/bigcommerce/catalyst/actions/workflows/lighthouse.yml/badge.svg)](https://github.com/bigcommerce/catalyst/actions/workflows/lighthouse.yml) [![Lint, Typecheck, gql.tada](https://github.com/bigcommerce/catalyst/actions/workflows/basic.yml/badge.svg)](https://github.com/bigcommerce/catalyst/actions/workflows/basic.yml)

</div>

Expand Down
12 changes: 12 additions & 0 deletions apps/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 0.3.0

### Minor Changes

- [#696](https://github.com/bigcommerce/catalyst/pull/696) [`6deba4a`](https://github.com/bigcommerce/catalyst/commit/6deba4a0713b0d14a76439f0cd01baf35f5185e2) Thanks [@deini](https://github.com/deini)! - removes graphql codegen setup, all graphql calls are done using gql.tada

### Patch Changes

- [#694](https://github.com/bigcommerce/catalyst/pull/694) [`b0c912b`](https://github.com/bigcommerce/catalyst/commit/b0c912bfcefe8c6a9dc46d667f9f96124d1ad132) Thanks [@onurstats](https://github.com/onurstats)! - fix login form translation key mismatch

- [#697](https://github.com/bigcommerce/catalyst/pull/697) [`fbc49e1`](https://github.com/bigcommerce/catalyst/commit/fbc49e144f0eadd7824cae81a46ddff523eb30a3) Thanks [@yurytut1993](https://github.com/yurytut1993)! - add customer & address form fields queries

## 0.2.1

### Patch Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ export const fetchFacetedSearch = cache(
limit,
sort,
filters,
imageHeight: 500,
imageWidth: 500,
});
},
);
4 changes: 2 additions & 2 deletions apps/core/app/[locale]/(default)/blog/[blogId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
} from '@bigcommerce/components/blog-post-card';
import { Tag, TagContent } from '@bigcommerce/components/tag';
import type { Metadata } from 'next';
import Image from 'next/image';
import { notFound } from 'next/navigation';

import { getBlogPost } from '~/client/queries/get-blog-post';
import { BcImage } from '~/components/bc-image';
import { Link } from '~/components/link';
import { SharingLinks } from '~/components/sharing-links';
import { LocaleType } from '~/i18n';
Expand Down Expand Up @@ -52,7 +52,7 @@ export default async function BlogPostPage({ params: { blogId } }: Props) {

{blogPost.thumbnailImage ? (
<BlogPostImage className="mb-6 h-40 sm:h-80 lg:h-96">
<Image
<BcImage
alt={blogPost.thumbnailImage.altText}
className="h-full w-full object-cover object-center"
height={900}
Expand Down
9 changes: 7 additions & 2 deletions apps/core/app/[locale]/(default)/cart/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Button } from '@bigcommerce/components/button';
import { Trash2 as Trash } from 'lucide-react';
import { cookies } from 'next/headers';
import Image from 'next/image';
import { NextIntlClientProvider, useTranslations } from 'next-intl';
import { getMessages, getTranslations } from 'next-intl/server';
import { Suspense } from 'react';

import { getCheckoutUrl } from '~/client/management/get-checkout-url';
import { getCart } from '~/client/queries/get-cart';
import { BcImage } from '~/components/bc-image';
import { LocaleType } from '~/i18n';

import { getShippingCountries } from './_actions/get-shipping-countries';
Expand Down Expand Up @@ -93,7 +93,12 @@ export default async function CartPage({ params: { locale } }: Props) {
<li key={product.entityId}>
<div className="flex items-center gap-6 border-t border-t-gray-200 py-4">
<div>
<Image alt={product.name} height={104} src={product.imageUrl ?? ''} width={104} />
<BcImage
alt={product.name}
height={104}
src={product.imageUrl ?? ''}
width={104}
/>
</div>

<div className="flex-1">
Expand Down
4 changes: 2 additions & 2 deletions apps/core/app/[locale]/(default)/compare/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Button } from '@bigcommerce/components/button';
import { Rating } from '@bigcommerce/components/rating';
import Image from 'next/image';
import { NextIntlClientProvider } from 'next-intl';
import { getMessages, getTranslations } from 'next-intl/server';
import * as z from 'zod';

import { getProducts } from '~/client/queries/get-products';
import { BcImage } from '~/components/bc-image';
import { Link } from '~/components/link';
import { Pricing } from '~/components/pricing';
import { SearchForm } from '~/components/search-form';
Expand Down Expand Up @@ -96,7 +96,7 @@ export default async function Compare({
return (
<td className="px-4" key={product.entityId}>
<Link aria-label={product.name} href={product.path}>
<Image
<BcImage
alt={product.defaultImage.altText}
height={300}
src={product.defaultImage.url}
Expand Down
4 changes: 2 additions & 2 deletions apps/core/app/[locale]/(default)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export default async function Home({ params: { locale } }: Props) {
const t = await getTranslations({ locale, namespace: 'Home' });
const messages = await getMessages({ locale });
const [newestProducts, featuredProducts] = await Promise.all([
getNewestProducts({ imageWidth: 500, imageHeight: 500 }),
getFeaturedProducts({ imageWidth: 500, imageHeight: 500 }),
getNewestProducts(),
getFeaturedProducts(),
]);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
GalleryThumbnailItem,
GalleryThumbnailList,
} from '@bigcommerce/components/gallery';
import Image from 'next/image';

import { getProduct } from '~/client/queries/get-product';
import { BcImage } from '~/components/bc-image';

type Product = Awaited<ReturnType<typeof getProduct>>;

Expand Down Expand Up @@ -52,7 +52,7 @@ export const Gallery = ({
<GalleryImage>
{({ selectedImage }) =>
selectedImage ? (
<Image
<BcImage
alt={selectedImage.altText}
className="h-full w-full object-contain"
fill
Expand All @@ -76,7 +76,7 @@ export const Gallery = ({
return (
<GalleryThumbnailItem imageIndex={index} key={image.url}>
<GalleryThumbnail asChild>
<Image alt={image.altText} priority={true} src={image.url} />
<BcImage alt={image.altText} priority={true} src={image.url} />
</GalleryThumbnail>
</GalleryThumbnailItem>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ export const RelatedProducts = async ({ productId }: { productId: number }) => {

const relatedProducts = await getRelatedProducts({
productId,
imageWidth: 500,
imageHeight: 500,
});

return (
Expand Down
2 changes: 0 additions & 2 deletions apps/core/app/[locale]/not-found.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ export default async function NotFound() {
const messages = await getMessages({ locale });

const featuredProducts = await getFeaturedProducts({
imageHeight: 500,
imageWidth: 500,
first: 4,
});

Expand Down
54 changes: 54 additions & 0 deletions apps/core/client/fragments/form-fields.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { graphql } from '../graphql';

export const FORM_FIELDS_FRAGMENT = graphql(`
fragment FormFields on FormField {
entityId
label
sortOrder
isBuiltIn
isRequired
__typename
... on CheckboxesFormField {
options {
entityId
label
}
}
... on DateFormField {
defaultDate
minDate
maxDate
}
... on MultilineTextFormField {
defaultText
rows
}
... on NumberFormField {
defaultNumber
maxLength
minNumber
maxNumber
}
... on PasswordFormField {
defaultText
maxLength
}
... on PicklistFormField {
choosePrefix
options {
entityId
label
}
}
... on RadioButtonsFormField {
options {
entityId
label
}
}
... on TextFormField {
defaultText
maxLength
}
}
`);
2 changes: 1 addition & 1 deletion apps/core/client/fragments/product-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const PRODUCT_DETAILS_FRAGMENT = graphql(
path
}
defaultImage {
url(width: $imageWidth, height: $imageHeight)
url: urlTemplate
altText
}
availabilityV2 {
Expand Down
46 changes: 46 additions & 0 deletions apps/core/client/queries/get-address-form-fields.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { cache } from 'react';

import { client } from '..';
import { FORM_FIELDS_FRAGMENT } from '../fragments/form-fields';
import { graphql, VariablesOf } from '../graphql';
import { revalidate } from '../revalidate-target';

const GET_ADDRESS_FORM_FIELDS = graphql(
`
query getAddressFormFields($filters: FormFieldFiltersInput, $sortBy: FormFieldSortInput) {
site {
settings {
formFields {
shippingAddress(filters: $filters, sortBy: $sortBy) {
...FormFields
}
}
}
}
}
`,
[FORM_FIELDS_FRAGMENT],
);

type Variables = VariablesOf<typeof GET_ADDRESS_FORM_FIELDS>;

interface AddressFormFields {
filters?: Variables['filters'];
sortBy?: Variables['sortBy'];
}

export const getAddressFormFields = cache(async ({ filters, sortBy }: AddressFormFields) => {
const response = await client.fetch({
document: GET_ADDRESS_FORM_FIELDS,
variables: { filters, sortBy },
fetchOptions: { next: { revalidate } },
});

const { settings } = response.data.site;

if (!settings) {
return null;
}

return settings.formFields.shippingAddress;
});
2 changes: 1 addition & 1 deletion apps/core/client/queries/get-blog-post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const GET_BLOG_POST_QUERY = graphql(`
tags
thumbnailImage {
altText
url(width: 900)
url: urlTemplate
}
seo {
metaKeywords
Expand Down
2 changes: 1 addition & 1 deletion apps/core/client/queries/get-blog-posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const GET_BLOG_POSTS_QUERY = graphql(`
utc
}
thumbnailImage {
url(width: 300)
url: urlTemplate
altText
}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/core/client/queries/get-category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const GET_CATEGORY_QUERY = graphql(`
}
}
defaultImage {
url(width: 300)
url: urlTemplate
altText
}
}
Expand Down
46 changes: 46 additions & 0 deletions apps/core/client/queries/get-customer-form-fields.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { cache } from 'react';

import { client } from '..';
import { FORM_FIELDS_FRAGMENT } from '../fragments/form-fields';
import { graphql, VariablesOf } from '../graphql';
import { revalidate } from '../revalidate-target';

const GET_CUSTOMER_FORM_FIELDS = graphql(
`
query getCustomerFormFields($filters: FormFieldFiltersInput, $sortBy: FormFieldSortInput) {
site {
settings {
formFields {
customer(filters: $filters, sortBy: $sortBy) {
...FormFields
}
}
}
}
}
`,
[FORM_FIELDS_FRAGMENT],
);

type Variables = VariablesOf<typeof GET_CUSTOMER_FORM_FIELDS>;

interface CustomerFormFields {
filters?: Variables['filters'];
sortBy?: Variables['sortBy'];
}

export const getCustomerFormFields = cache(async ({ filters, sortBy }: CustomerFormFields) => {
const response = await client.fetch({
document: GET_CUSTOMER_FORM_FIELDS,
variables: { filters, sortBy },
fetchOptions: { next: { revalidate } },
});

const { settings } = response.data.site;

if (!settings) {
return null;
}

return settings.formFields.customer;
});
Loading

0 comments on commit bb94f9a

Please sign in to comment.