Skip to content

Commit d6b9c97

Browse files
committed
chore: use globalAttributes
1 parent 86b5b8a commit d6b9c97

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

src/app/[locale]/(main)/(container)/products/[...params]/components/ProductTabs.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Product } from '../../types/common';
99

1010
export interface ProductTabsProps {
1111
content?: string | null;
12-
attributes?: NonNullable<Product['customAttributes']>['nodes'];
12+
attributes?: NonNullable<Product['globalAttributes']>['nodes'];
1313
}
1414

1515
const ProductTabs: FC<ProductTabsProps> = ({ content, attributes }) => {
@@ -30,6 +30,7 @@ const ProductTabs: FC<ProductTabsProps> = ({ content, attributes }) => {
3030
value,
3131
};
3232
}) ?? [];
33+
console.log('🚀 ~ items:', items);
3334

3435
return (
3536
<>

src/app/[locale]/(main)/(container)/products/[...params]/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const getProduct = async ({ id }: { id: number }) => {
4141
variables: {
4242
id,
4343
},
44+
fetchPolicy: 'no-cache',
4445
});
4546
return data.product;
4647
};
@@ -115,7 +116,7 @@ const Page: FC<PageProps> = async ({ params: { params } }) => {
115116

116117
<ProductTabs
117118
content={product.content}
118-
attributes={product.customAttributes?.nodes}
119+
attributes={product.globalAttributes?.nodes}
119120
/>
120121
</ProductProvider>
121122
);

src/graphql/queries/products.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const GET_SINGLE_VARIABLE_PRODUCT_QUERY = gql`
6464
sourceUrl(size: WOOCOMMERCE_SINGLE)
6565
altText
6666
}
67-
customAttributes {
67+
globalAttributes {
6868
nodes {
6969
id
7070
label

src/graphql/types/gql.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ const documents = {
4242
"\n query GetIsPayedOrder($id: ID) {\n order(idType: DATABASE_ID, id: $id) {\n transactionId\n datePaid\n }\n }\n": types.GetIsPayedOrderDocument,
4343
"\n query GetPage($slug: String) {\n pages(where: { name: $slug, status: PUBLISH }) {\n edges {\n node {\n title\n content\n }\n }\n }\n }\n": types.GetPageDocument,
4444
"\n query GetPublishedPagesList {\n pages(where: { status: PUBLISH }) {\n edges {\n node {\n title\n slug\n }\n }\n }\n }\n": types.GetPublishedPagesListDocument,
45-
"\n query GetAllProducts(\n $stockStatus: [StockStatusEnum]\n $orderBy: [ProductsOrderbyInput]\n $categoryIdIn: [Int]\n $q: String\n $first: Int\n ) {\n products(\n first: $first\n where: {\n stockStatus: $stockStatus\n orderby: $orderBy\n categoryIdIn: $categoryIdIn\n search: $q\n }\n ) {\n pageInfo {\n total\n hasNextPage\n hasPreviousPage\n }\n nodes {\n __typename\n ... on VariableProduct {\n databaseId\n name\n onSale\n type\n averageRating\n slug\n image {\n sourceUrl\n }\n price\n regularPrice\n salePrice\n stockStatus\n discountAmount\n discountPercentage\n }\n }\n }\n }\n": types.GetAllProductsDocument,
46-
"\n query GetSingleProduct($id: ID!) {\n product(id: $id, idType: DATABASE_ID) {\n description\n content\n commentCount\n image {\n id: databaseId\n sourceUrl\n altText\n }\n customAttributes {\n nodes {\n id\n label\n name\n optionNames\n variation\n }\n }\n productCategories(where: { order: ASC, orderby: TERM_ORDER }) {\n nodes {\n id: databaseId\n name\n slug\n menuOrder\n parentId\n }\n }\n galleryImages {\n nodes {\n id\n sourceUrl\n altText\n }\n }\n ... on VariableProduct {\n id: databaseId\n name\n title\n stockStatus\n slug\n averageRating\n price\n regularPrice\n salePrice\n discountPercentage\n discountAmount\n variations(where: { stockStatus: IN_STOCK }) {\n nodes {\n ...ProductVariationContentSlice\n }\n }\n }\n }\n }\n \n": types.GetSingleProductDocument,
45+
"\n query GetAllProducts(\n $stockStatus: [StockStatusEnum]\n $orderBy: [ProductsOrderbyInput]\n $categoryIdIn: [Int]\n $q: String\n $first: Int\n ) {\n products(\n first: $first\n where: {\n stockStatus: $stockStatus\n orderby: $orderBy\n categoryIdIn: $categoryIdIn\n search: $q\n }\n ) {\n pageInfo {\n total\n hasNextPage\n hasPreviousPage\n }\n nodes {\n __typename\n ... on VariableProduct {\n databaseId\n name\n onSale\n type\n averageRating\n slug\n image {\n sourceUrl(size: WOOCOMMERCE_SINGLE)\n }\n price\n regularPrice\n salePrice\n stockStatus\n discountAmount\n discountPercentage\n }\n }\n }\n }\n": types.GetAllProductsDocument,
46+
"\n query GetSingleProduct($id: ID!) {\n product(id: $id, idType: DATABASE_ID) {\n description\n content\n commentCount\n image {\n id: databaseId\n sourceUrl(size: WOOCOMMERCE_SINGLE)\n altText\n }\n globalAttributes {\n nodes {\n id\n label\n name\n optionNames\n variation\n }\n }\n productCategories(where: { order: ASC, orderby: TERM_ORDER }) {\n nodes {\n id: databaseId\n name\n slug\n menuOrder\n parentId\n }\n }\n galleryImages {\n nodes {\n id\n sourceUrl(size: WOOCOMMERCE_SINGLE)\n altText\n }\n }\n ... on VariableProduct {\n id: databaseId\n name\n title\n stockStatus\n slug\n averageRating\n price\n regularPrice\n salePrice\n discountPercentage\n discountAmount\n variations(where: { stockStatus: IN_STOCK }) {\n nodes {\n ...ProductVariationContentSlice\n }\n }\n }\n }\n }\n \n": types.GetSingleProductDocument,
4747
"\n query GetHomePageSliders {\n sliderCategories(where: { slug: \"MAIN_HOMEPAGE_SLIDERS\" }) {\n nodes {\n sliders {\n edges {\n node {\n id: databaseId\n title\n url\n featuredImage {\n node {\n id: databaseId\n url: sourceUrl\n }\n }\n }\n }\n }\n }\n }\n }\n": types.GetHomePageSlidersDocument,
4848
"\n query GetTopBanner {\n sliderCategories(where: { slug: \"TOP_BANNER\" }) {\n nodes {\n sliders {\n edges {\n node {\n id: databaseId\n title\n url\n featuredImage {\n node {\n id: databaseId\n url: sourceUrl\n }\n }\n }\n }\n }\n }\n }\n }\n": types.GetTopBannerDocument,
4949
};
@@ -181,11 +181,11 @@ export function graphql(source: "\n query GetPublishedPagesList {\n pages(wh
181181
/**
182182
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
183183
*/
184-
export function graphql(source: "\n query GetAllProducts(\n $stockStatus: [StockStatusEnum]\n $orderBy: [ProductsOrderbyInput]\n $categoryIdIn: [Int]\n $q: String\n $first: Int\n ) {\n products(\n first: $first\n where: {\n stockStatus: $stockStatus\n orderby: $orderBy\n categoryIdIn: $categoryIdIn\n search: $q\n }\n ) {\n pageInfo {\n total\n hasNextPage\n hasPreviousPage\n }\n nodes {\n __typename\n ... on VariableProduct {\n databaseId\n name\n onSale\n type\n averageRating\n slug\n image {\n sourceUrl\n }\n price\n regularPrice\n salePrice\n stockStatus\n discountAmount\n discountPercentage\n }\n }\n }\n }\n"): (typeof documents)["\n query GetAllProducts(\n $stockStatus: [StockStatusEnum]\n $orderBy: [ProductsOrderbyInput]\n $categoryIdIn: [Int]\n $q: String\n $first: Int\n ) {\n products(\n first: $first\n where: {\n stockStatus: $stockStatus\n orderby: $orderBy\n categoryIdIn: $categoryIdIn\n search: $q\n }\n ) {\n pageInfo {\n total\n hasNextPage\n hasPreviousPage\n }\n nodes {\n __typename\n ... on VariableProduct {\n databaseId\n name\n onSale\n type\n averageRating\n slug\n image {\n sourceUrl\n }\n price\n regularPrice\n salePrice\n stockStatus\n discountAmount\n discountPercentage\n }\n }\n }\n }\n"];
184+
export function graphql(source: "\n query GetAllProducts(\n $stockStatus: [StockStatusEnum]\n $orderBy: [ProductsOrderbyInput]\n $categoryIdIn: [Int]\n $q: String\n $first: Int\n ) {\n products(\n first: $first\n where: {\n stockStatus: $stockStatus\n orderby: $orderBy\n categoryIdIn: $categoryIdIn\n search: $q\n }\n ) {\n pageInfo {\n total\n hasNextPage\n hasPreviousPage\n }\n nodes {\n __typename\n ... on VariableProduct {\n databaseId\n name\n onSale\n type\n averageRating\n slug\n image {\n sourceUrl(size: WOOCOMMERCE_SINGLE)\n }\n price\n regularPrice\n salePrice\n stockStatus\n discountAmount\n discountPercentage\n }\n }\n }\n }\n"): (typeof documents)["\n query GetAllProducts(\n $stockStatus: [StockStatusEnum]\n $orderBy: [ProductsOrderbyInput]\n $categoryIdIn: [Int]\n $q: String\n $first: Int\n ) {\n products(\n first: $first\n where: {\n stockStatus: $stockStatus\n orderby: $orderBy\n categoryIdIn: $categoryIdIn\n search: $q\n }\n ) {\n pageInfo {\n total\n hasNextPage\n hasPreviousPage\n }\n nodes {\n __typename\n ... on VariableProduct {\n databaseId\n name\n onSale\n type\n averageRating\n slug\n image {\n sourceUrl(size: WOOCOMMERCE_SINGLE)\n }\n price\n regularPrice\n salePrice\n stockStatus\n discountAmount\n discountPercentage\n }\n }\n }\n }\n"];
185185
/**
186186
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
187187
*/
188-
export function graphql(source: "\n query GetSingleProduct($id: ID!) {\n product(id: $id, idType: DATABASE_ID) {\n description\n content\n commentCount\n image {\n id: databaseId\n sourceUrl\n altText\n }\n customAttributes {\n nodes {\n id\n label\n name\n optionNames\n variation\n }\n }\n productCategories(where: { order: ASC, orderby: TERM_ORDER }) {\n nodes {\n id: databaseId\n name\n slug\n menuOrder\n parentId\n }\n }\n galleryImages {\n nodes {\n id\n sourceUrl\n altText\n }\n }\n ... on VariableProduct {\n id: databaseId\n name\n title\n stockStatus\n slug\n averageRating\n price\n regularPrice\n salePrice\n discountPercentage\n discountAmount\n variations(where: { stockStatus: IN_STOCK }) {\n nodes {\n ...ProductVariationContentSlice\n }\n }\n }\n }\n }\n \n"): (typeof documents)["\n query GetSingleProduct($id: ID!) {\n product(id: $id, idType: DATABASE_ID) {\n description\n content\n commentCount\n image {\n id: databaseId\n sourceUrl\n altText\n }\n customAttributes {\n nodes {\n id\n label\n name\n optionNames\n variation\n }\n }\n productCategories(where: { order: ASC, orderby: TERM_ORDER }) {\n nodes {\n id: databaseId\n name\n slug\n menuOrder\n parentId\n }\n }\n galleryImages {\n nodes {\n id\n sourceUrl\n altText\n }\n }\n ... on VariableProduct {\n id: databaseId\n name\n title\n stockStatus\n slug\n averageRating\n price\n regularPrice\n salePrice\n discountPercentage\n discountAmount\n variations(where: { stockStatus: IN_STOCK }) {\n nodes {\n ...ProductVariationContentSlice\n }\n }\n }\n }\n }\n \n"];
188+
export function graphql(source: "\n query GetSingleProduct($id: ID!) {\n product(id: $id, idType: DATABASE_ID) {\n description\n content\n commentCount\n image {\n id: databaseId\n sourceUrl(size: WOOCOMMERCE_SINGLE)\n altText\n }\n globalAttributes {\n nodes {\n id\n label\n name\n optionNames\n variation\n }\n }\n productCategories(where: { order: ASC, orderby: TERM_ORDER }) {\n nodes {\n id: databaseId\n name\n slug\n menuOrder\n parentId\n }\n }\n galleryImages {\n nodes {\n id\n sourceUrl(size: WOOCOMMERCE_SINGLE)\n altText\n }\n }\n ... on VariableProduct {\n id: databaseId\n name\n title\n stockStatus\n slug\n averageRating\n price\n regularPrice\n salePrice\n discountPercentage\n discountAmount\n variations(where: { stockStatus: IN_STOCK }) {\n nodes {\n ...ProductVariationContentSlice\n }\n }\n }\n }\n }\n \n"): (typeof documents)["\n query GetSingleProduct($id: ID!) {\n product(id: $id, idType: DATABASE_ID) {\n description\n content\n commentCount\n image {\n id: databaseId\n sourceUrl(size: WOOCOMMERCE_SINGLE)\n altText\n }\n globalAttributes {\n nodes {\n id\n label\n name\n optionNames\n variation\n }\n }\n productCategories(where: { order: ASC, orderby: TERM_ORDER }) {\n nodes {\n id: databaseId\n name\n slug\n menuOrder\n parentId\n }\n }\n galleryImages {\n nodes {\n id\n sourceUrl(size: WOOCOMMERCE_SINGLE)\n altText\n }\n }\n ... on VariableProduct {\n id: databaseId\n name\n title\n stockStatus\n slug\n averageRating\n price\n regularPrice\n salePrice\n discountPercentage\n discountAmount\n variations(where: { stockStatus: IN_STOCK }) {\n nodes {\n ...ProductVariationContentSlice\n }\n }\n }\n }\n }\n \n"];
189189
/**
190190
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
191191
*/

0 commit comments

Comments
 (0)