diff --git a/src/components/AlgoliaSearch/AlgoliaSearchBox.component.tsx b/src/components/AlgoliaSearch/AlgoliaSearchBox.component.tsx index 0254677c3..4f1bea8b0 100644 --- a/src/components/AlgoliaSearch/AlgoliaSearchBox.component.tsx +++ b/src/components/AlgoliaSearch/AlgoliaSearchBox.component.tsx @@ -51,7 +51,7 @@ const AlgoliaSearchBox = () => { }} /> {search && ( -
+
)} diff --git a/src/components/AlgoliaSearch/SearchResults.component.tsx b/src/components/AlgoliaSearch/SearchResults.component.tsx index 0176403c0..968b0458c 100644 --- a/src/components/AlgoliaSearch/SearchResults.component.tsx +++ b/src/components/AlgoliaSearch/SearchResults.component.tsx @@ -1,5 +1,4 @@ import Link from 'next/link'; - import { trimmedStringToLength } from '@/utils/functions/functions'; interface ISearchResultProps { @@ -10,7 +9,7 @@ interface ISearchResultProps { sale_price: string; on_sale: boolean; short_description: string; - objectID: number; + slug: string; }; } @@ -23,7 +22,6 @@ interface ISearchResultProps { * @param {string} sale_price Price when on sale * @param {boolean} on_sale Is the product on sale? True or false * @param {string} short_description Short description of product - * @param {number} objectID ID of product } */ const SearchResults = ({ @@ -34,17 +32,12 @@ const SearchResults = ({ sale_price, on_sale, short_description, - objectID, }, }: ISearchResultProps) => { - // Replace empty spaces with dash (-) - const trimmedProductName = product_name.replace(/ /g, '-'); - return (
diff --git a/src/components/Product/DisplayProducts.component.tsx b/src/components/Product/DisplayProducts.component.tsx index d6b75eef1..cb2aa13ce 100644 --- a/src/components/Product/DisplayProducts.component.tsx +++ b/src/components/Product/DisplayProducts.component.tsx @@ -23,7 +23,6 @@ interface Variations { interface RootObject { __typename: string; - databaseId: number; name: string; onSale: boolean; slug: string; @@ -55,7 +54,6 @@ const DisplayProducts = ({ products }: IDisplayProductsProps) => ( {products ? ( products.map( ({ - databaseId, name, price, regularPrice, @@ -78,11 +76,7 @@ const DisplayProducts = ({ products }: IDisplayProductsProps) => ( return (
- +
{image ? ( ( id="product-image" className="w-full h-full object-cover object-center transition duration-300 group-hover:scale-105" alt={name} - src={process.env.NEXT_PUBLIC_PLACEHOLDER_SMALL_IMAGE_URL} + src={ + process.env.NEXT_PUBLIC_PLACEHOLDER_SMALL_IMAGE_URL + } /> )}
- +

@@ -127,9 +119,7 @@ const DisplayProducts = ({ products }: IDisplayProductsProps) => (

) : ( - - {price} - + {price} )}
diff --git a/src/components/Product/ProductCard.component.tsx b/src/components/Product/ProductCard.component.tsx index 77f535b57..a29a78a06 100644 --- a/src/components/Product/ProductCard.component.tsx +++ b/src/components/Product/ProductCard.component.tsx @@ -33,7 +33,7 @@ const ProductCard = ({ return (
- + {image?.sourceUrl ? (
- +

{name} diff --git a/src/components/User/UserRegistration.component.tsx b/src/components/User/UserRegistration.component.tsx index 9f0aeed44..7c1f67ff4 100644 --- a/src/components/User/UserRegistration.component.tsx +++ b/src/components/User/UserRegistration.component.tsx @@ -36,8 +36,8 @@ const UserRegistration = () => { } else { throw new Error('Failed to register customer'); } - } catch (err: unknown) { - console.error('Registration error'); + } catch (error: unknown) { + console.error('Registration error:', error); } }; diff --git a/src/pages/produkt/[slug].tsx b/src/pages/produkt/[slug].tsx index 711da637c..395ef2c70 100644 --- a/src/pages/produkt/[slug].tsx +++ b/src/pages/produkt/[slug].tsx @@ -48,11 +48,21 @@ const Produkt: NextPage = ({ export default withRouter(Produkt); export const getServerSideProps: GetServerSideProps = async ({ - query: { id }, + params, + query, + res, }) => { + // Handle legacy URLs with ID parameter by removing it + if (query.id) { + res.setHeader('Location', `/produkt/${params?.slug}`); + res.statusCode = 301; + res.end(); + return { props: {} }; + } + const { data, loading, networkStatus } = await client.query({ query: GET_SINGLE_PRODUCT, - variables: { id }, + variables: { slug: params?.slug }, }); return { diff --git a/src/utils/gql/GQL_QUERIES.ts b/src/utils/gql/GQL_QUERIES.ts index b3edca9dd..e39955232 100644 --- a/src/utils/gql/GQL_QUERIES.ts +++ b/src/utils/gql/GQL_QUERIES.ts @@ -1,8 +1,8 @@ import { gql } from '@apollo/client'; export const GET_SINGLE_PRODUCT = gql` - query Product($id: ID!) { - product(id: $id, idType: DATABASE_ID) { + query Product($slug: ID!) { + product(id: $slug, idType: SLUG) { id databaseId averageRating