@@ -127,9 +119,7 @@ const DisplayProducts = ({ products }: IDisplayProductsProps) => (
{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