From 7f02987f344764517f691bdaaa24e353ac559cc8 Mon Sep 17 00:00:00 2001 From: Bayram Muhiyev Date: Thu, 22 Jul 2021 13:51:53 +0500 Subject: [PATCH] Theming @compoents folder components in purpose of future merging with updates, prepared to deploy on heroku --- commerce.config.json | 2 +- .../utils/queries/get-collections-query.ts | 7 + package.json | 2 +- pages/index.tsx | 40 ++- pages/search.tsx | 2 +- pages/search/[category].tsx | 2 +- pages/search/designers/[name].tsx | 2 +- pages/search/designers/[name]/[category].tsx | 2 +- tailwind.config.js | 1 + theme/dap/search.tsx | 336 ++++++++++++++++++ tsconfig.json | 4 +- yarn.lock | 18 + 12 files changed, 395 insertions(+), 23 deletions(-) create mode 100644 theme/dap/search.tsx diff --git a/commerce.config.json b/commerce.config.json index ad63a93d3..d769d23a0 100644 --- a/commerce.config.json +++ b/commerce.config.json @@ -5,6 +5,6 @@ "search": true, "wishlist": false, "customerAuth": false, - "customCheckout": false + "customCheckout": true } } diff --git a/framework/vendure/utils/queries/get-collections-query.ts b/framework/vendure/utils/queries/get-collections-query.ts index ed0919652..06c7cfd7d 100644 --- a/framework/vendure/utils/queries/get-collections-query.ts +++ b/framework/vendure/utils/queries/get-collections-query.ts @@ -15,6 +15,13 @@ export const getCollectionsQuery = /* GraphQL */ ` children { id } + assets { + id + name + source + width + height + } } } } diff --git a/package.json b/package.json index 60b7f2496..f2f23a40e 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "scripts": { "dev": "NODE_OPTIONS='--inspect' next dev -p 8000", "build": "next build", - "start": "next start", + "start": "next start -p $PORT", "analyze": "BUNDLE_ANALYZE=both yarn build", "prettier-fix": "prettier --write .", "find:unused": "npx next-unused", diff --git a/pages/index.tsx b/pages/index.tsx index b399923f7..24956a869 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -4,6 +4,8 @@ import { ProductCard } from '@components/product' import { Grid, Marquee, Hero } from '@components/ui' // import HomeAllProductsGrid from '@components/common/HomeAllProductsGrid' import type { GetStaticPropsContext, InferGetStaticPropsType } from 'next' +import Image from 'next/image' +import Link from 'next/link' export async function getStaticProps({ preview, @@ -36,23 +38,29 @@ export async function getStaticProps({ } export default function Home({ - products, + products, categories }: InferGetStaticPropsType) { return ( <> - - {products.slice(0, 3).map((product: any, i: number) => ( - - ))} - - +
+ {categories.slice(0, 3).map((category: any, i: number) => ( + + + + + + ))} +
+ {products.slice(0, 3).map((product: any, i: number) => ( ))} @@ -61,7 +69,7 @@ export default function Home({ headline=" Dessert dragée halvah croissant." description="Cupcake ipsum dolor sit amet lemon drops pastry cotton candy. Sweet carrot cake macaroon bonbon croissant fruitcake jujubes macaroon oat cake. Soufflé bonbon caramels jelly beans. Tiramisu sweet roll cheesecake pie carrot cake. " /> - + {/* {products.slice(0, 3).map((product: any, i: number) => ( ( ))} - +
*/} {/* cat.slug === category) + const activeBrand = brands.find( + (b: any) => getSlug(b.node.path) === `brands/${brand}` + )?.node + + const { data } = useSearch({ + search: typeof q === 'string' ? q : '', + categoryId: activeCategory?.id, + brandId: (activeBrand as any)?.entityId, + sort: typeof sort === 'string' ? sort : '', + locale, + }) + + const handleClick = (event: any, filter: string) => { + if (filter !== activeFilter) { + setToggleFilter(true) + } else { + setToggleFilter(!toggleFilter) + } + setActiveFilter(filter) + } + + return ( + +
+
+ {/* Categories */} +
+
+ + + +
+ +
+
+ {/* Products */} +
+ {(q || activeCategory || activeBrand) && ( +
+ {data ? ( + <> + + Showing {data.products.length} results{' '} + {q && ( + <> + for "{q}" + + )} + + + {q ? ( + <> + There are no products that match "{q}" + + ) : ( + <> + There are no products that match the selected category. + + )} + + + ) : q ? ( + <> + Searching for: "{q}" + + ) : ( + <>Searching... + )} +
+ )} + {data ? ( +
+ {data.products.map((product: Product) => ( + + ))} +
+ ) : ( +
+ {rangeMap(12, (i) => ( + +
+ + ))} +
+ )}{' '} +
+ + {/* Sort */} +
+
+
+ + + +
+ +
+
+
+ + ) +} + +Search.Layout = Layout diff --git a/tsconfig.json b/tsconfig.json index 72608f830..343b07e63 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -24,7 +24,9 @@ "@commerce": ["framework/commerce"], "@commerce/*": ["framework/commerce/*"], "@framework": ["framework/vendure"], - "@framework/*": ["framework/vendure/*"] + "@framework/*": ["framework/vendure/*"], + "@theme": ["theme/dap"], + "@theme/*": ["theme/dap/*"] } }, "include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"], diff --git a/yarn.lock b/yarn.lock index 8d1a534a5..62b7698cd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1140,6 +1140,11 @@ resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.1.tgz#18845205e86ff0038517aab7a18a62a6b9f71275" integrity sha512-EaCxbanVeyxDRTQBkdLb3Bvl/HK7PBK6UJjsSixB0iHKoWxE5uu2Q/DgtpOhPIojN0Zl1whvOd7PoHs2P0s5eA== +"@types/uuid@8.3.1": + version "8.3.1" + resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.3.1.tgz#1a32969cf8f0364b3d8c8af9cc3555b7805df14f" + integrity sha512-Y2mHTRAbqfFkpjldbkHGY8JIzRN6XqYRliG8/24FcHm2D2PwW24fl5xMRTVGdrb7iMrwCaIEbLWerGIkXuFWVg== + "@types/websocket@1.0.2": version "1.0.2" resolved "https://registry.yarnpkg.com/@types/websocket/-/websocket-1.0.2.tgz#d2855c6a312b7da73ed16ba6781815bf30c6187a" @@ -6044,6 +6049,19 @@ util@^0.12.0: safe-buffer "^5.1.2" which-typed-array "^1.1.2" +uuid@8.3.2: + version "8.3.2" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" + integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== + +uuidv4@^6.2.10: + version "6.2.11" + resolved "https://registry.yarnpkg.com/uuidv4/-/uuidv4-6.2.11.tgz#34d5a03324eb38296b87ae523a64233b5286cc27" + integrity sha512-OTS4waH9KplrXNADKo+Q1kT9AHWr8DaC0S5F54RQzEwcUaEzBEWQQlJyDUw/u1bkRhJyqkqhLD4M4lbFbV+89g== + dependencies: + "@types/uuid" "8.3.1" + uuid "8.3.2" + valid-url@1.0.9, valid-url@^1.0.9: version "1.0.9" resolved "https://registry.yarnpkg.com/valid-url/-/valid-url-1.0.9.tgz#1c14479b40f1397a75782f115e4086447433a200"