+
{isEmptyCart ? (
diff --git a/src/checkout/views/Checkout/consts.ts b/src/checkout/views/Checkout/consts.ts
deleted file mode 100644
index 8c90086e5..000000000
--- a/src/checkout/views/Checkout/consts.ts
+++ /dev/null
@@ -1 +0,0 @@
-export const PAGE_ID = "page";
diff --git a/src/ui/components/AuthProvider.tsx b/src/ui/components/AuthProvider.tsx
index aa04d0b31..0f6f3f899 100644
--- a/src/ui/components/AuthProvider.tsx
+++ b/src/ui/components/AuthProvider.tsx
@@ -37,11 +37,9 @@ export function AuthProvider({ children }: { children: ReactNode }) {
useAuthChange({
saleorApiUrl,
onSignedOut: () => {
- console.log("onSignedOut");
setUrqlClient(makeUrqlClient());
},
onSignedIn: () => {
- console.log("onSignedIn");
setUrqlClient(makeUrqlClient());
},
});
From 51be2f0139e4ed9c7fefab192ce0b6850273e751 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bart=C5=82omiej=20Wiaduch?= <2can@users.noreply.github.com>
Date: Mon, 13 Nov 2023 18:01:37 +0100
Subject: [PATCH 09/11] Add update types GA workflow (#1010)
This workflow checks if there is a new release of Saleor with the
attached `schema.graphql` file. If the file is found it runs `pnpm
generate` to update types and issue a PR.
---
.github/workflows/update_types.yml | 76 ++++++++++++++++++++++++++++++
.graphqlrc.ts | 6 ++-
2 files changed, 81 insertions(+), 1 deletion(-)
create mode 100644 .github/workflows/update_types.yml
diff --git a/.github/workflows/update_types.yml b/.github/workflows/update_types.yml
new file mode 100644
index 000000000..869966fd9
--- /dev/null
+++ b/.github/workflows/update_types.yml
@@ -0,0 +1,76 @@
+name: Check Saleor release and update types
+
+on:
+ workflow_dispatch:
+ schedule:
+ - cron: "0 18 * * 1-5" # workdays at 18:00
+
+jobs:
+ check_saleor_release:
+ name: Check Saleor release and update types
+ runs-on: ubuntu-latest
+ steps:
+ - name: Get latest release info
+ id: release
+ run: |
+ echo "Fetching latest release info..."
+ latest_release=$(curl -s https://api.github.com/repos/saleor/saleor/releases/latest)
+ echo "tag=$(echo $latest_release | jq -r '.tag_name')" >> "$GITHUB_OUTPUT"
+ echo "schema_url=$(echo $latest_release | jq -r '.assets[] | select(.name == "schema.graphql") | .url')" >> "$GITHUB_OUTPUT"
+ echo "has_schema=$(echo $latest_release | jq -e '.assets[] | select(.name == "schema.graphql") | length > 0')" >> "$GITHUB_OUTPUT"
+
+ - name: Download schema.graphql
+ run: |
+ if [[ "${{ steps.release.outputs.has_schema }}" == "true" ]]; then
+ echo "schema.graphql is attached to the ${{ steps.release.outputs.tag }} release, updating..."
+
+ curl --output schema.graphql \
+ --url ${{ steps.release.outputs.schema_url }} \
+ --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
+ --header "Accept: application/octet-stream" \
+ --location
+ else
+ echo "schema.graphql is not attached to the ${{ steps.release.outputs.tag }} release, exiting..."
+ exit 1
+ fi
+
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Get PNPM version from package.json
+ id: pnpm-version
+ run: echo "pnpm_version=$(cat package.json | jq '.engines.pnpm' | sed -E 's/[^0-9.]//g')" >> $GITHUB_OUTPUT
+
+ - name: Install PNPM
+ uses: pnpm/action-setup@v2
+ with:
+ version: ${{ steps.pnpm-version.outputs.pnpm_version }}
+
+ - uses: actions/setup-node@v3
+ with:
+ node-version-file: package.json
+ cache: "pnpm"
+
+ - name: Install dependencies
+ run: pnpm --version && pnpm install --frozen-lockfile
+
+ - name: Run `pnpm generate`
+ id: generate-schema-from-file
+ run: pnpm generate
+
+ - name: Remove schema
+ run: rm -f schema.graphql
+
+ - name: Show changed files
+ run: git status
+
+ - name: Create Pull Request
+ uses: peter-evans/create-pull-request@v5
+ with:
+ branch: update-schema
+ commit-message: "Update schema to Saleor ${{ steps.release.outputs.tag }}"
+ title: "Update schema to Saleor ${{ steps.release.outputs.tag }}"
+ body: |
+ Pull request auto-generated by bot
+ labels: |
+ :robot: bot
diff --git a/.graphqlrc.ts b/.graphqlrc.ts
index e056a217d..2aa9d7be3 100644
--- a/.graphqlrc.ts
+++ b/.graphqlrc.ts
@@ -3,7 +3,11 @@ import type { CodegenConfig } from "@graphql-codegen/cli";
loadEnvConfig(process.cwd());
-const schemaUrl = process.env.NEXT_PUBLIC_SALEOR_API_URL;
+let schemaUrl = process.env.NEXT_PUBLIC_SALEOR_API_URL;
+
+if (process.env.GITHUB_ACTION === "generate-schema-from-file") {
+ schemaUrl = "schema.graphql";
+}
if (!schemaUrl) {
console.error(
From 856e9fc40241283edadc010f2f99ec5e25f265cb Mon Sep 17 00:00:00 2001
From: Grzegorz Pokorski
Date: Mon, 13 Nov 2023 18:03:22 +0100
Subject: [PATCH 10/11] feat: add json-ld and individual og image for single
product page (#1019)
- Change the OG image for the product page to the product image instead
of the default OG image.
- Add JSON-LD for product pages.
---
package.json | 1 +
pnpm-lock.yaml | 11 ++++++
src/app/(main)/products/[slug]/page.tsx | 51 ++++++++++++++++++++++++-
3 files changed, 62 insertions(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 5cdd05d15..1b796b03a 100644
--- a/package.json
+++ b/package.json
@@ -70,6 +70,7 @@
"postcss": "8.4.31",
"prettier": "3.0.3",
"prettier-plugin-tailwindcss": "0.5.7",
+ "schema-dts": "1.1.2",
"tailwindcss": "3.3.5",
"typescript": "5.2.2",
"wonka": "6.3.4"
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b0b24ca7b..1f3940042 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -169,6 +169,9 @@ devDependencies:
prettier-plugin-tailwindcss:
specifier: 0.5.7
version: 0.5.7(prettier@3.0.3)
+ schema-dts:
+ specifier: 1.1.2
+ version: 1.1.2(typescript@5.2.2)
tailwindcss:
specifier: 3.3.5
version: 3.3.5
@@ -5476,6 +5479,14 @@ packages:
loose-envify: 1.4.0
dev: false
+ /schema-dts@1.1.2(typescript@5.2.2):
+ resolution: {integrity: sha512-MpNwH0dZJHinVxk9bT8XUdjKTxMYrA5bLtrrGmFA6PTLwlOKnhi67XoRd6/ty+Djt6ZC0slR57qFhZDNMI6DhQ==}
+ peerDependencies:
+ typescript: '>=4.1.0'
+ dependencies:
+ typescript: 5.2.2
+ dev: true
+
/scuid@1.1.0:
resolution: {integrity: sha512-MuCAyrGZcTLfQoH2XoBlQ8C6bzwN88XT/0slOGz0pn8+gIP85BOAfYa44ZXQUTOwRwPU0QvgU+V+OSajl/59Xg==}
dev: true
diff --git a/src/app/(main)/products/[slug]/page.tsx b/src/app/(main)/products/[slug]/page.tsx
index d4b124fe8..ea340558c 100644
--- a/src/app/(main)/products/[slug]/page.tsx
+++ b/src/app/(main)/products/[slug]/page.tsx
@@ -5,6 +5,7 @@ import { notFound } from "next/navigation";
import { type ResolvingMetadata, type Metadata } from "next";
import xss from "xss";
import invariant from "ts-invariant";
+import { type WithContext, type Product } from "schema-dts";
import { AddButton } from "./AddButton";
import { VariantSelector } from "@/ui/components/VariantSelector";
import { ProductImageWrapper } from "@/ui/atoms/ProductImageWrapper";
@@ -39,7 +40,6 @@ export async function generateMetadata(
const productName = product.seoTitle || product.name;
const variantName = product.variants?.find(({ id }) => id === searchParams.variant)?.name;
-
const productNameAndVariant = variantName ? `${productName} - ${variantName}` : productName;
return {
@@ -50,6 +50,16 @@ export async function generateMetadata(
? process.env.NEXT_PUBLIC_STOREFRONT_URL + `/products/${encodeURIComponent(params.slug)}`
: undefined,
},
+ openGraph: product.thumbnail
+ ? {
+ images: [
+ {
+ url: product.thumbnail.url,
+ alt: product.name,
+ },
+ ],
+ }
+ : null,
};
}
@@ -125,8 +135,47 @@ export default async function Page(props: { params: { slug: string }; searchPara
})
: "";
+ const productJsonLd: WithContext = {
+ "@context": "https://schema.org",
+ "@type": "Product",
+ image: product.thumbnail?.url,
+ ...(selectedVariant
+ ? {
+ name: `${product.name} - ${selectedVariant.name}`,
+ description: product.seoDescription || `${product.name} - ${selectedVariant.name}`,
+ offers: {
+ "@type": "Offer",
+ availability: selectedVariant.quantityAvailable
+ ? "https://schema.org/InStock"
+ : "https://schema.org/OutOfStock",
+ priceCurrency: selectedVariant.pricing?.price?.gross.currency,
+ price: selectedVariant.pricing?.price?.gross.amount,
+ },
+ }
+ : {
+ name: product.name,
+
+ description: product.seoDescription || product.name,
+ offers: {
+ "@type": "AggregateOffer",
+ availability: product.variants?.some((variant) => variant.quantityAvailable)
+ ? "https://schema.org/InStock"
+ : "https://schema.org/OutOfStock",
+ priceCurrency: product.pricing?.priceRange?.start?.gross.currency,
+ lowPrice: product.pricing?.priceRange?.start?.gross.amount,
+ highPrice: product.pricing?.priceRange?.stop?.gross.amount,
+ },
+ }),
+ };
+
return (