From 3bbfb0af580a22467517316c154947d9ba6c6cef Mon Sep 17 00:00:00 2001 From: Swadesh Behera Date: Tue, 26 Apr 2022 16:36:32 +0530 Subject: [PATCH] transformed to GraphQL --- .env | 2 +- .eslintrc.cjs | 42 +- .gitignore | 1 - .graphqlrc.yaml | 29 + .prettierrc | 1 + _redirects | 4 +- config/index.ts | 40 - package.json | 110 +- postcss.config.cjs | 25 +- src/actions/svelte-quill.js | 28 + src/app.css | 84 + src/app.html | 17 +- src/global.css | 40 - src/global.d.ts | 2 - src/hooks/index.ts | 133 +- src/lib/Footer.svelte | 101 +- src/lib/Hero.svelte | 31 +- src/lib/HeroBanners.svelte | 69 + src/lib/MobFilter.svelte | 28 +- src/lib/MobNav.svelte | 2 +- src/lib/Nav.svelte | 100 +- src/lib/Pricesummary.svelte | 19 +- src/lib/Product.svelte | 6 +- src/lib/Product1.svelte | 4 +- src/lib/Search.svelte | 8 +- src/lib/WishlistProducts.svelte | 18 +- src/lib/components/Error.svelte | 13 + src/lib/components/HeadingUnderline.svelte | 5 + src/lib/components/Image/Image.svelte | 33 + src/lib/components/Image/ImageLoader.svelte | 24 + .../Image/IntersectionObserver.svelte | 51 + src/lib/components/SEO/SchemaOrg.svelte | 74 +- src/lib/components/SEO/index.svelte | 18 +- src/lib/components/_CategoriesHome.svelte | 218 + src/lib/components/_ProductCard.svelte | 72 + src/lib/config/env.js | 3 + src/lib/config/g.ts | 6 + src/lib/config/index.ts | 47 + src/lib/graphql/_kitql/graphqlStores.ts | 3958 + src/lib/graphql/_kitql/graphqlTypes.ts | 12245 +++ src/lib/graphql/kitQLClient.ts | 8 + .../graphql/operations/address/address.gql | 22 + .../graphql/operations/address/addresses.gql | 40 + .../operations/address/deleteAddress.gql | 3 + .../operations/address/myAddresses.gql | 27 + .../operations/address/saveAddress.gql | 104 + src/lib/graphql/operations/cart/addToCart.gql | 89 + src/lib/graphql/operations/cart/cart.gql | 97 + src/lib/graphql/operations/cart/checkout.gql | 114 + .../operations/category/categories.gql | 56 + .../graphql/operations/category/category.gql | 50 + .../graphql/operations/category/megamenu.gql | 92 + .../graphql/operations/groupQueries/INIT.gql | 416 + .../graphql/operations/groupQueries/home.gql | 266 + .../graphql/operations/order/myOrderItems.gql | 135 + src/lib/graphql/operations/order/myOrders.gql | 149 + .../operations/order/paySuccessPageHit.gql | 116 + .../graphql/operations/product/product.gql | 217 + .../operations/product/productSlug.gql | 52 + .../graphql/operations/product/products.gql | 138 + .../operations/review/productReviews.gql | 30 + src/lib/graphql/operations/review/reviews.gql | 42 + .../operations/search/popularSearches.gql | 32 + .../graphql/operations/settings/settings.gql | 161 + src/lib/graphql/operations/store/store.gql | 144 + src/lib/graphql/operations/store/storeOne.gql | 204 + .../operations/user/changePassword.gql | 7 + .../graphql/operations/user/emailPassword.gql | 3 + src/lib/graphql/operations/user/getOtp.gql | 6 + src/lib/graphql/operations/user/login.gql | 23 + src/lib/graphql/operations/user/me.gql | 19 + src/lib/graphql/operations/user/signOut.gql | 3 + .../graphql/operations/user/topVendors.gql | 9 + .../graphql/operations/user/updateProfile.gql | 51 + src/lib/graphql/operations/user/verifyOtp.gql | 15 + .../operations/vendor/randomVendors.gql | 63 + src/lib/graphql/operations/vendor/vendor.gql | 75 + .../operations/vendor/vendorProfile.gql | 127 + .../operations/wishlist/checkWishlist.gql | 3 + .../operations/wishlist/myWishlist.gql | 48 + .../operations/wishlist/toggleWishlist.gql | 3 + src/lib/graphql/schema.json | 73150 ++++++++++++++++ src/lib/services.js | 204 + src/lib/store.ts | 47 + src/lib/ui/Skeleton.svelte | 11 + src/lib/ui/Textbox.svelte | 2 +- ...{__layout.reset.svelte => __layout.svelte} | 81 +- src/routes/[slug]/index.svelte | 140 +- src/routes/__layout.svelte | 144 +- src/routes/cart/_Cartlist.svelte | 75 +- src/routes/cart/index.svelte | 66 +- src/routes/checkout/_EditAddress.svelte | 16 +- src/routes/checkout/_SelectAddress.svelte | 10 +- src/routes/checkout/address.svelte | 10 +- src/routes/checkout/edit-address.svelte | 10 +- src/routes/checkout/payment-options.svelte | 20 +- src/routes/designs/home.svelte | 16 +- src/routes/designs/search/index.svelte | 18 +- src/routes/index.svelte | 153 +- ...{__layout.reset.svelte => __layout.svelte} | 7 +- src/routes/login/index.svelte | 28 +- src/routes/my/_SidebarDashboard.svelte | 17 +- src/routes/my/_SummaryDashboard.svelte | 68 +- src/routes/my/__layout.svelte | 12 +- src/routes/my/orders/index.svelte | 21 +- src/routes/my/profile/index.svelte | 12 +- src/routes/my/reviews/index.svelte | 180 + src/routes/my/wishlist/index.svelte | 180 + src/routes/p/about.svelte | 277 + src/routes/p/blog/[id].svelte | 60 + src/routes/p/blog/index.svelte | 103 + src/routes/p/contact.svelte | 275 + src/routes/p/deals/index.svelte | 50 + src/routes/p/sitemap.svelte | 104 + src/routes/payment/success.svelte | 13 +- src/routes/search/_HeaderBody.svelte | 19 +- src/routes/search/_Pagination.svelte | 59 +- src/routes/search/_Product.svelte | 2 +- src/routes/search/_ProductCardEs.svelte | 101 + src/routes/search/_ProductSkeleton.svelte | 14 +- src/routes/search/index.svelte | 132 +- src/routes/signup.svelte | 102 +- src/routes/wishlist.svelte | 17 +- src/service-worker.ts | 79 + src/util/api.ts | 94 +- src/util/auth.ts | 56 +- src/util/index.ts | 83 +- static/favicon.ico | Bin 9662 -> 3758 bytes static/icon.png | Bin 166969 -> 13755 bytes static/icons/app-store.png | Bin 0 -> 2527 bytes static/icons/facebook-white.png | Bin 0 -> 2384 bytes static/icons/github-white.png | Bin 0 -> 2265 bytes static/icons/instagram-white.png | Bin 0 -> 2553 bytes static/icons/linkedin-white.png | Bin 0 -> 1490 bytes static/icons/play-store.png | Bin 0 -> 3139 bytes static/icons/twitter-white.png | Bin 0 -> 1937 bytes static/logo.png | Bin 0 -> 9936 bytes static/logo_512.png | Bin 0 -> 13755 bytes static/manifest.json | 43 + static/product/non-veg.png | Bin 0 -> 1415 bytes static/product/other.png | Bin 0 -> 1374 bytes static/product/veg.png | Bin 0 -> 1461 bytes store/auth.ts | 80 - store/cart.ts | 49 - store/index.ts | 23 - svelte.config.js | 49 +- tailwind.config.cjs | 131 +- tsconfig.json | 4 +- vercel.json | 12 + yarn.lock | 5362 +- 150 files changed, 100507 insertions(+), 2554 deletions(-) create mode 100644 .graphqlrc.yaml delete mode 100644 config/index.ts create mode 100644 src/actions/svelte-quill.js create mode 100644 src/app.css delete mode 100644 src/global.css create mode 100644 src/lib/HeroBanners.svelte create mode 100644 src/lib/components/Error.svelte create mode 100644 src/lib/components/HeadingUnderline.svelte create mode 100644 src/lib/components/Image/Image.svelte create mode 100644 src/lib/components/Image/ImageLoader.svelte create mode 100644 src/lib/components/Image/IntersectionObserver.svelte create mode 100644 src/lib/components/_CategoriesHome.svelte create mode 100644 src/lib/components/_ProductCard.svelte create mode 100644 src/lib/config/env.js create mode 100644 src/lib/config/g.ts create mode 100644 src/lib/config/index.ts create mode 100644 src/lib/graphql/_kitql/graphqlStores.ts create mode 100644 src/lib/graphql/_kitql/graphqlTypes.ts create mode 100644 src/lib/graphql/kitQLClient.ts create mode 100644 src/lib/graphql/operations/address/address.gql create mode 100644 src/lib/graphql/operations/address/addresses.gql create mode 100644 src/lib/graphql/operations/address/deleteAddress.gql create mode 100644 src/lib/graphql/operations/address/myAddresses.gql create mode 100644 src/lib/graphql/operations/address/saveAddress.gql create mode 100644 src/lib/graphql/operations/cart/addToCart.gql create mode 100644 src/lib/graphql/operations/cart/cart.gql create mode 100644 src/lib/graphql/operations/cart/checkout.gql create mode 100644 src/lib/graphql/operations/category/categories.gql create mode 100644 src/lib/graphql/operations/category/category.gql create mode 100644 src/lib/graphql/operations/category/megamenu.gql create mode 100644 src/lib/graphql/operations/groupQueries/INIT.gql create mode 100644 src/lib/graphql/operations/groupQueries/home.gql create mode 100644 src/lib/graphql/operations/order/myOrderItems.gql create mode 100644 src/lib/graphql/operations/order/myOrders.gql create mode 100644 src/lib/graphql/operations/order/paySuccessPageHit.gql create mode 100644 src/lib/graphql/operations/product/product.gql create mode 100644 src/lib/graphql/operations/product/productSlug.gql create mode 100644 src/lib/graphql/operations/product/products.gql create mode 100644 src/lib/graphql/operations/review/productReviews.gql create mode 100644 src/lib/graphql/operations/review/reviews.gql create mode 100644 src/lib/graphql/operations/search/popularSearches.gql create mode 100644 src/lib/graphql/operations/settings/settings.gql create mode 100644 src/lib/graphql/operations/store/store.gql create mode 100644 src/lib/graphql/operations/store/storeOne.gql create mode 100644 src/lib/graphql/operations/user/changePassword.gql create mode 100644 src/lib/graphql/operations/user/emailPassword.gql create mode 100644 src/lib/graphql/operations/user/getOtp.gql create mode 100644 src/lib/graphql/operations/user/login.gql create mode 100644 src/lib/graphql/operations/user/me.gql create mode 100644 src/lib/graphql/operations/user/signOut.gql create mode 100644 src/lib/graphql/operations/user/topVendors.gql create mode 100644 src/lib/graphql/operations/user/updateProfile.gql create mode 100644 src/lib/graphql/operations/user/verifyOtp.gql create mode 100644 src/lib/graphql/operations/vendor/randomVendors.gql create mode 100644 src/lib/graphql/operations/vendor/vendor.gql create mode 100644 src/lib/graphql/operations/vendor/vendorProfile.gql create mode 100644 src/lib/graphql/operations/wishlist/checkWishlist.gql create mode 100644 src/lib/graphql/operations/wishlist/myWishlist.gql create mode 100644 src/lib/graphql/operations/wishlist/toggleWishlist.gql create mode 100644 src/lib/graphql/schema.json create mode 100644 src/lib/services.js create mode 100644 src/lib/store.ts create mode 100644 src/lib/ui/Skeleton.svelte rename src/routes/[slug]/{__layout.reset.svelte => __layout.svelte} (90%) rename src/routes/login/{__layout.reset.svelte => __layout.svelte} (79%) create mode 100644 src/routes/my/reviews/index.svelte create mode 100644 src/routes/my/wishlist/index.svelte create mode 100644 src/routes/p/about.svelte create mode 100644 src/routes/p/blog/[id].svelte create mode 100644 src/routes/p/blog/index.svelte create mode 100644 src/routes/p/contact.svelte create mode 100644 src/routes/p/deals/index.svelte create mode 100644 src/routes/p/sitemap.svelte create mode 100644 src/routes/search/_ProductCardEs.svelte create mode 100644 static/icons/app-store.png create mode 100644 static/icons/facebook-white.png create mode 100644 static/icons/github-white.png create mode 100644 static/icons/instagram-white.png create mode 100644 static/icons/linkedin-white.png create mode 100644 static/icons/play-store.png create mode 100644 static/icons/twitter-white.png create mode 100644 static/logo.png create mode 100644 static/logo_512.png create mode 100644 static/manifest.json create mode 100644 static/product/non-veg.png create mode 100644 static/product/other.png create mode 100644 static/product/veg.png delete mode 100644 store/auth.ts delete mode 100644 store/cart.ts delete mode 100644 store/index.ts create mode 100644 vercel.json diff --git a/.env b/.env index 34b693dd..8ce6dfef 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ WWW_URL=http://localhost:3000 -LIVE_KEY=D:/ssh/node-server.pem +VITE_DOMAIN=food.misiki.in diff --git a/.eslintrc.cjs b/.eslintrc.cjs index b6e501da..d0119d62 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -3,18 +3,50 @@ module.exports = { parser: '@typescript-eslint/parser', extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'], plugins: ['svelte3', '@typescript-eslint'], + // Some preference rules by KitQL + rules: { + '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], + 'no-console': ['error', { allow: ['info', 'warn', 'error', 'time', 'timeEnd'] }] + }, ignorePatterns: ['*.cjs'], - overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }], + overrides: [ + { files: ['*.svelte'], processor: 'svelte3/svelte3' }, + { + files: ['*.graphql', '*.gql'], + parserOptions: { + operations: '**/*.gql', + schema: '**/*.graphql' + }, + // Enable all rules + extends: ['plugin:@graphql-eslint/schema-all', 'plugin:@graphql-eslint/operations-all'], + // Some preference rules by KitQL + rules: { + '@graphql-eslint/alphabetize': 'off', + '@graphql-eslint/match-document-filename': [ + 'error', + { + query: { style: 'PascalCase', suffix: '_QUERY' }, + mutation: { style: 'PascalCase', suffix: '_MUTATION' }, + subscription: { style: 'PascalCase', suffix: '_SUB' }, + fragment: { style: 'PascalCase', suffix: '_FRAG' } + } + ], + '@graphql-eslint/no-unused-fields': 'error', + '@graphql-eslint/unique-enum-value-names': 'error', + '@graphql-eslint/require-id-when-available': 'error' + } + } + ], settings: { - 'svelte3/typescript': () => require('typescript'), + 'svelte3/typescript': () => require('typescript') }, parserOptions: { sourceType: 'module', - ecmaVersion: 2019, + ecmaVersion: 2020 }, env: { browser: true, es2017: true, - node: true, - }, + node: true + } } diff --git a/.gitignore b/.gitignore index 870a2006..b9b6b954 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -.env .DS_Store node_modules /.svelte diff --git a/.graphqlrc.yaml b/.graphqlrc.yaml new file mode 100644 index 00000000..831353f0 --- /dev/null +++ b/.graphqlrc.yaml @@ -0,0 +1,29 @@ +# Typical File for extension: vscode-graphql & CodeGen! +projects: + default: + schema: + - ./src/lib/graphql/schema.json # or https://localhost:3777/graphql + documents: + - '**/*.gql' + extensions: + endpoints: + default: + url: https://localhost:3000/graphql + codegen: + generates: + ./src/lib/graphql/_kitql/graphqlTypes.ts: + plugins: + - typescript + - typescript-operations + - typed-document-node + - typescript-document-nodes + + ./src/lib/graphql/_kitql/graphqlStores.ts: + plugins: + - '@kitql/graphql-codegen' + config: + importBaseTypesFrom: $lib/graphql/_kitql/graphqlTypes + operationPrefix: 'KQL_' + + config: + useTypeImports: true diff --git a/.prettierrc b/.prettierrc index 5288da04..1a2e311d 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,6 +1,7 @@ { "semi": false, "singleQuote": true, + "trailingComma": "none", "svelteSortOrder": "options-styles-scripts-markup", "svelteStrictMode": true, "svelteBracketNewLine": false, diff --git a/_redirects b/_redirects index bfd6bdda..0f18adcb 100644 --- a/_redirects +++ b/_redirects @@ -1,2 +1,2 @@ -/api/* https://api.litekart.in/api/:splat 200 -/images/* https://api.litekart.in/images/:splat 200 \ No newline at end of file +/api/_ https://api.misiki.in/api/:splat 200 +/images/_ https://api.misiki.in/images/:splat 200 diff --git a/config/index.ts b/config/index.ts deleted file mode 100644 index 1d256668..00000000 --- a/config/index.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { amp, browser, dev } from '$app/env' -const HTTP_ENDPOINT = 'https://api.litekart.in' -const WWW_URL = dev ? 'http://localhost:3000' : 'https://svelte-commerce.litekart.in' -const CDN_URL = 'https://ik.imagekit.io/3wzatecz51w3i/images' -export const typingTimeout = 0 // After this delay the search api will be fired -const currency = { symbol: '₹', code: 'INR' } -const tokenExpiry = 60 * 60 * 24 * 365 // Login validity in seconds -const ANALYTICS_TRACKING_ID = 'UA-49421899-5' -const sorts = [ - { name: 'Relevance', val: null }, - { name: 'Whats New', val: '-createdAt' }, - { name: 'Price low to high', val: 'localPrice' }, - { name: 'Price high to low', val: '-localPrice' }, -] -const authorInfo = { - author: 'Swadesh Behera', - entity: 'Misiki', - ogLanguage: 'en_US', - siteLanguage: 'en-US', - siteTitle: 'SvelteKit based ecommerce store front', - siteShortTitle: 'SvelteKit Storefront', // used as SchemaOrg siteTitleAlt - contactEmail: 'swadesh@litekart.in', - facebookAuthorPage: `https://www.facebook.com/codenx`, - facebookPage: `https://www.facebook.com/codenx`, - facebookPageName: 'codenx', - githubPage: 'itswadesh', - linkedinProfile: 'itswadesh', - telegramUsername: 'itswadesh', - twitterUsername: 'itswadesh', -} -export { - sorts, - CDN_URL, - currency, - tokenExpiry, - HTTP_ENDPOINT, - WWW_URL, - ANALYTICS_TRACKING_ID, - authorInfo, -} diff --git a/package.json b/package.json index d112758d..3ecddb9d 100644 --- a/package.json +++ b/package.json @@ -2,80 +2,80 @@ "name": "svelte-commerce", "version": "0.0.2", "scripts": { - "dev": "svelte-kit dev --host", - "build": "set NODE_ENV=production && svelte-kit build", + "dev": "svelte-kit dev", + "gen": "graphql-codegen --config ./.graphqlrc.yaml", + "build": "svelte-kit build", + "package": "svelte-kit package", "preview": "svelte-kit preview", - "lint": "prettier --check . && eslint --ignore-path .gitignore .", - "format": "prettier --write .", - "start": "cross-env NODE_ENV=production node .", - "copy": "node devops/copy.js", - "live": "run-s build copy liveS", - "liveS": "node devops/live.js", - "format:check": "prettier --check './**/*.{js,ts,css,html,svelte}'" + "quality": "npm run quality:eslint && npm run quality:prettier && npm run quality:ts", + "quality:fix": "prettier --ignore-path .gitignore --write --plugin-search-dir=. . && npm run quality:eslint --fix", + "quality:eslint": "eslint --ignore-path .gitignore .", + "quality:prettier": "prettier --ignore-path .gitignore --check --plugin-search-dir=. .", + "quality:ts": "svelte-check --tsconfig ./tsconfig.json", + "quality:ts:w": "npm run quality:ts --watch", + "update": "npm exec -- npx ncu -u -p yarn" }, "devDependencies": { - "@apollo/client": "^3.4.10", - "@sveltejs/adapter-begin": "^1.0.0-next.11", - "@sveltejs/adapter-netlify": "^1.0.0-next.25", - "@sveltejs/adapter-node": "^1.0.0-next.35", - "@sveltejs/adapter-static": "^1.0.0-next.13", - "@sveltejs/adapter-vercel": "^1.0.0-next.26", - "@sveltejs/kit": "1.0.0-next.159", - "@tailwindcss/forms": "^0.3.3", + "@sveltejs/adapter-auto": "next", + "@sveltejs/kit": "next", + "@tailwindcss/forms": "^0.5.0", "@tailwindcss/jit": "^0.1.1", - "@tailwindcss/line-clamp": "^0.2.1", - "@tailwindcss/typography": "^0.4.1", - "@typescript-eslint/eslint-plugin": "^4.29.3", - "@typescript-eslint/parser": "^4.29.3", - "autoprefixer": "^10.3.3", - "concurrently": "^6.2.1", + "@tailwindcss/line-clamp": "^0.3.1", + "@tailwindcss/typography": "^0.5.2", + "@typescript-eslint/eslint-plugin": "^5.21.0", + "@typescript-eslint/parser": "^5.21.0", + "autoprefixer": "^10.4.5", + "concurrently": "^7.1.0", "cookie-universal": "^2.1.5", - "cssnano": "^5.0.8", - "eslint": "^7.32.0", - "eslint-config-prettier": "^8.1.0", - "eslint-plugin-import": "^2.24.2", - "eslint-plugin-jest": "^24.4.0", + "cssnano": "^5.1.7", + "eslint": "^8.14.0", + "eslint-config-prettier": "^8.5.0", + "eslint-plugin-import": "^2.26.0", + "eslint-plugin-jest": "^26.1.5", "eslint-plugin-node": "^11.0.0", - "eslint-plugin-prettier": "^3.4.1", - "eslint-plugin-promise": "^5.1.0", - "eslint-plugin-svelte3": "^3.2.0", - "graphql": "^15.5.1", + "eslint-plugin-prettier": "^4.0.0", + "eslint-plugin-promise": "^6.0.0", + "eslint-plugin-svelte3": "^3.4.1", + "graphql": "^16.4.0", + "graphql-tag": "^2.12.6", "npm-run-all": "^4.1.5", - "postcss": "^8.3.6", - "postcss-cli": "^8.3.1", - "postcss-load-config": "^3.1.0", - "prettier": "^2.3.2", - "prettier-plugin-svelte": "^2.4.0", - "shelljs": "^0.8.4", + "postcss": "^8.4.12", + "postcss-cli": "^9.1.0", + "postcss-load-config": "^3.1.4", + "prettier": "^2.6.2", + "prettier-plugin-svelte": "^2.7.0", + "shelljs": "^0.8.5", "siema": "^1.5.1", - "ssh2shell": "^1.9.5", - "svelte": "^3.42.4", - "svelte-apollo": "^0.4.0", + "ssh2shell": "^1.9.10", + "svelte": "^3.47.0", "svelte-debugger": "^1.0.5", - "svelte-hero-icons": "^2.4.0", - "svelte-preprocess": "^4.8.0", - "svelte-swipe": "^1.8.1", + "svelte-hero-icons": "^4.1.1", + "svelte-preprocess": "^4.10.6", + "svelte-swipe": "^1.8.2", "svelte-toasts": "^1.1.2", - "tailwindcss": "^2.2.8", - "tailwindcss-rtl": "^0.7.3", - "tslib": "^2.3.1", - "typescript": "^4.4.2", - "vite": "^2.5.1" + "tailwind-scrollbar": "^1.3.1", + "tailwindcss": "^3.0.24", + "tailwindcss-rtl": "^0.9.0", + "tslib": "^2.4.0", + "typescript": "^4.6.3" }, "type": "module", "engines": { "node": ">= 12.0.0" }, "dependencies": { - "@fontsource/fira-mono": "^4.5.0", + "@beyonk/async-script-loader": "^2.0.0", + "@fontsource/fira-mono": "^4.5.8", + "@kitql/all-in": "0.6.3", "@lukeed/uuid": "^2.0.0", - "cookie": "^0.4.1", + "graphql": "16.3.0", + "graphql-tag": "^2.12.6", + "cookie": "^0.5.0", "cross-env": "^7.0.3", - "dayjs": "^1.10.6", - "dotenv": "^10.0.0", - "fathom-client": "^3.1.0", + "dayjs": "^1.11.1", + "fathom-client": "^3.4.1", "hash-it": "^5.0.2", - "node-fetch": "^2.6.1", + "node-fetch": "^3.2.3", "universal-cookie": "^4.0.4" } } \ No newline at end of file diff --git a/postcss.config.cjs b/postcss.config.cjs index a9e71406..c05df502 100644 --- a/postcss.config.cjs +++ b/postcss.config.cjs @@ -1,6 +1,21 @@ -module.exports = { - plugins: { - autoprefixer: {}, - tailwindcss: {}, - }, +const tailwindcss = require('tailwindcss') +const autoprefixer = require('autoprefixer') +const cssnano = require('cssnano') + +const mode = process.env.NODE_ENV +const dev = mode === 'development' + +const config = { + plugins: [ + //Some plugins, like tailwindcss/nesting, need to run before Tailwind, + tailwindcss(), + //But others, like autoprefixer, need to run after, + autoprefixer(), + !dev && + cssnano({ + preset: 'default', + }), + ], } + +module.exports = config diff --git a/src/actions/svelte-quill.js b/src/actions/svelte-quill.js new file mode 100644 index 00000000..ac548dcd --- /dev/null +++ b/src/actions/svelte-quill.js @@ -0,0 +1,28 @@ +import Quill from 'quill' + +export function quill(node, options) { + const quill = new Quill(node, { + modules: { + toolbar: [ + [{ header: [1, 2, 3, false] }], + ['bold', 'italic', 'underline', 'strike'], + ['link', 'code-block'], + ], + }, + placeholder: 'Type something...', + theme: 'snow', // or 'bubble' + ...options, + }) + const container = node.getElementsByClassName('ql-editor')[0] + + quill.on('text-change', function (delta, oldDelta, source) { + node.dispatchEvent( + new CustomEvent('text-change', { + detail: { + html: container.innerHTML, + text: quill.getText(), + }, + }) + ) + }) +} diff --git a/src/app.css b/src/app.css new file mode 100644 index 00000000..61e5dded --- /dev/null +++ b/src/app.css @@ -0,0 +1,84 @@ +/* Write your global styles here, in PostCSS syntax */ +@tailwind base; +@tailwind components; +@tailwind utilities; + +@layer base { + html { + --scrollbarBG: #cfd8dc; + --thumbBG: #90a4ae; + } + body::-webkit-scrollbar { + width: 11px; + } + body { + scrollbar-width: thin; + scrollbar-color: var(--thumbBG) var(--scrollbarBG); + } + body::-webkit-scrollbar-track { + background: var(--scrollbarBG); + } + body::-webkit-scrollbar-thumb { + background-color: var(--thumbBG); + border-radius: 6px; + border: 3px solid var(--scrollbarBG); + } + .scrollbar::-webkit-scrollbar { + width: 11px; + } + .scrollbar { + scrollbar-width: thin; + scrollbar-color: var(--thumbBG) var(--scrollbarBG); + } + .scrollbar::-webkit-scrollbar-track { + background: var(--scrollbarBG); + } + .scrollbar::-webkit-scrollbar-thumb { + background-color: var(--thumbBG); + border-radius: 6px; + border: 3px solid var(--scrollbarBG); + } + + /* Demonstrate a "mostly customized" scrollbar + * (won't be visible otherwise if width/height is specified) */ + .mostly-customized-scrollbar::-webkit-scrollbar { + width: 5px; + height: 8px; + background-color: #cfd8dc; /* or add it to the track */ + } + + /* Add a thumb */ + .mostly-customized-scrollbar::-webkit-scrollbar-thumb { + background: #90a4ae; + } +} + +@layer components { + .link { + @apply text-indigo-500 hover:text-indigo-700; + } + .link-primary { + @apply text-primary-500 hover:text-primary-700; + } + .zoom-in { + overflow: hidden; + } + .zoom-in img { + width: 100%; + transition: 0.4s all ease-in-out; + } + .zoom-in:hover img { + transform: scale(1.05); + } + .zoom-out { + overflow: hidden; + } + .zoom-out img { + width: 100%; + transform: scale(1.05); + transition: 0.4s all ease-in-out; + } + .zoom-out:hover img { + transform: scale(1); + } +} diff --git a/src/app.html b/src/app.html index 9be7a10a..2492b076 100644 --- a/src/app.html +++ b/src/app.html @@ -1,15 +1,28 @@ - + + + %svelte.head%
%svelte.body%
+ + + diff --git a/src/global.css b/src/global.css deleted file mode 100644 index 72c86257..00000000 --- a/src/global.css +++ /dev/null @@ -1,40 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; - -@layer base { - html { - --scrollbarBG: #cfd8dc; - --thumbBG: #90a4ae; - } - body::-webkit-scrollbar { - width: 11px; - } - body { - scrollbar-width: thin; - scrollbar-color: var(--thumbBG) var(--scrollbarBG); - } - body::-webkit-scrollbar-track { - background: var(--scrollbarBG); - } - body::-webkit-scrollbar-thumb { - background-color: var(--thumbBG); - border-radius: 6px; - border: 3px solid var(--scrollbarBG); - } - .scrollbar::-webkit-scrollbar { - width: 11px; - } - .scrollbar { - scrollbar-width: thin; - scrollbar-color: var(--thumbBG) var(--scrollbarBG); - } - .scrollbar::-webkit-scrollbar-track { - background: var(--scrollbarBG); - } - .scrollbar::-webkit-scrollbar-thumb { - background-color: var(--thumbBG); - border-radius: 6px; - border: 3px solid var(--scrollbarBG); - } -} diff --git a/src/global.d.ts b/src/global.d.ts index 79d7d7fa..63908c66 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -1,3 +1 @@ /// -/// -/// diff --git a/src/hooks/index.ts b/src/hooks/index.ts index 5d7945f3..96f70002 100644 --- a/src/hooks/index.ts +++ b/src/hooks/index.ts @@ -1,70 +1,89 @@ import cookie from 'cookie' -import { v4 as uuid } from '@lukeed/uuid' import type { Handle } from '@sveltejs/kit' -import { get } from '../util/api' -import { addToCart, fetchCart, cart } from './../../store/cart' -import { me } from './../../store/auth' -import { authorInfo } from './../../config' -export const handle: Handle = async ({ request, resolve }) => { - const cookies = cookie.parse(request.headers.cookie || '') - const token = cookies.token - request.locals.token = `${token}` - if (request.query.has('_method')) { - request.method = request.query.get('_method').toUpperCase() - } - // me(token) - try { - const settings = (await get('settings')).data || {} - request.locals.settings = settings - } catch (e) { - request.locals.settings = {} - } - try { - let categories = (await get('categories/megamenu')).data || [] - request.locals.categories = categories - } catch (err) { - request.locals.categories = {} - } - try { - const user = (await get('users/me', null, token)) || { guest: true } - request.locals.user = user - } catch (e) { - request.locals.user = null - } - // console.log('kkkkkkkkkkkkkkkkkkkkkkkkkk', token) - fetchCart(token) // Me will not throw error +import { DOMAIN } from '$lib/config' +import { KQL_Init } from '$lib/graphql/_kitql/graphqlStores' - const response = await resolve(request) +export const handle: Handle = async ({ event, resolve }) => { + let store, + headers, + serializedCookie, + settings = {}, + megamenu = [], + sid, + token + // me.gql and cart.gql can not be called here because of unabailability of session cookie. Hence there are executed at __layout.reset.svelte or $lib/Nav.svelte + const request = event.request + const cookies = cookie.parse(request.headers.get('cookie') || '') || {} + const domain = DOMAIN || request.headers.get('host') + if (cookies.store) store = cookies.store && JSON.parse(cookies.store) + const INIT = ( + await KQL_Init.query({ + fetch, + variables: { domain } + }) + ).data + store = store = INIT?.storeOne + settings = INIT?.settings + megamenu = INIT?.megamenu + if (cookies.me) { + sid = cookies.sid + token = cookies.token + } - // if (!cookies.cookie) { - // // if this is the first time the user has visited this app, - // // set a cookie so that we recognise them when they return - // response.headers['set-cookie'] = `cookie=${request.locals.cookie}; Path=/; HttpOnly` + const geo = cookies.geo && JSON.parse(cookies.geo) + // if (event.url.searchParams.has('_method')) { + // event.method = event.url.searchParams.get('_method').toUpperCase() // } - - response.headers['Authorization'] = `${token}; Path=/; HttpOnly` + event.locals = { + store, + headers, + serializedCookie, + settings, + megamenu, + sid, + token, + domain, + loginUrl: settings?.otpLogin ? '/auth/otp-login' : '/auth/login', + geo + } + const response = await resolve(event) + if (store) { + // const COOKIE_NAME = 'store' + // const secure = process.env.NODE_ENV === 'production' + // const maxAge = 7200 // (3600 seconds / hour) * 2 hours + // const sameSite = 'Strict' + const { id, email, address, phone, websiteName, websiteLegalName, stripePublishableKey } = store + const stringifiedData = + JSON.stringify({ + id, + domain, + address, + phone, + email, + websiteName, + websiteLegalName, + stripePublishableKey + }) || '' + // const setCookieValue = `${COOKIE_NAME}=${stringifiedData}; Max-Age=${maxAge}; Path=/; ${ + // secure ? 'Secure;' : '' + // } HttpOnly; SameSite=${sameSite}` + serializedCookie = cookie.serialize('store', stringifiedData, { path: '/' }) + } + response.headers.set('Set-Cookie', serializedCookie) return response } export const getSession = ({ locals }) => { - const { user, token, categories, settings } = locals + const { token, geo, store, loginUrl, domain, sid, categories, settings, megamenu } = locals return { - user, - token, - categories, + loginUrl, + megamenu, settings, - DEBUG_MODE: import.meta.env.VITE_DEBUG_MODE, + domain, + store, + geo, + sid, + token, + DEBUG_MODE: import.meta.env.VITE_DEBUG_MODE } } - -// export const serverFetch = async (request) => { -// if (request.url.startsWith('https://api.yourapp.com/')) { -// // clone the original request, but change the URL -// request = new Request( -// request.url.replace('https://api.yourapp.com/', 'http://localhost:9999/'), -// request -// ) -// } - -// return fetch(request) -// } diff --git a/src/lib/Footer.svelte b/src/lib/Footer.svelte index e36f7f71..cd5cce88 100644 --- a/src/lib/Footer.svelte +++ b/src/lib/Footer.svelte @@ -1 +1,100 @@ -Footer + + + + +
+
+

{store?.domain}

+ +

{store?.websiteLegalName}

+ + +
+ +
+
+

©{year} {store?.websiteLegalName}

+
+ + +
+
diff --git a/src/lib/Hero.svelte b/src/lib/Hero.svelte index 53bc15f9..74d3b76a 100644 --- a/src/lib/Hero.svelte +++ b/src/lib/Hero.svelte @@ -1,15 +1,13 @@
- {#each banners as b, i} + {#each heroBanners as b, i} - - + {/each} diff --git a/src/lib/HeroBanners.svelte b/src/lib/HeroBanners.svelte new file mode 100644 index 00000000..1ff3d36f --- /dev/null +++ b/src/lib/HeroBanners.svelte @@ -0,0 +1,69 @@ + + + + +{#if localHeroBanners} + +{/if} diff --git a/src/lib/MobFilter.svelte b/src/lib/MobFilter.svelte index 8c2b7553..7d506604 100644 --- a/src/lib/MobFilter.svelte +++ b/src/lib/MobFilter.svelte @@ -23,7 +23,7 @@ let menuItem = [ stroke-width="3" d="M9 5l7 7-7 7" /> - `, + ` }, { name: 'Men', @@ -41,7 +41,7 @@ let menuItem = [ stroke-width="3" d="M9 5l7 7-7 7" /> - `, + ` }, { name: 'Kids', @@ -59,7 +59,7 @@ let menuItem = [ stroke-width="3" d="M9 5l7 7-7 7" /> - `, + ` }, { name: 'Home and Kitchen', @@ -77,33 +77,33 @@ let menuItem = [ stroke-width="3" d="M9 5l7 7-7 7" /> - `, + ` }, { name: 'Stores', img: '/sidebar/furniture-store.png', - svg: '', + svg: '' }, { name: 'Precious Jewellery', img: '/sidebar/acrobatic-rings.png', - svg: '', + svg: '' }, { name: 'Sneakerhood', img: '/sidebar/sneakers.png', - svg: '', + svg: '' }, { name: 'Collections', img: '/sidebar/group-objects.png', - svg: '', + svg: '' }, { name: 'New Arrivals', img: '/sidebar/new.png', - svg: '', - }, + svg: '' + } ] let subMenu = [ @@ -123,8 +123,8 @@ let subMenu = [ `, - name: 'Kurtas & Kurtis', - }, + name: 'Kurtas & Kurtis' + } ] @@ -146,7 +146,7 @@ let subMenu = [
+ >

Litekart

@@ -164,7 +164,7 @@ let subMenu = [ class="block w-full px-4 ">
- + {item.name}
diff --git a/src/lib/MobNav.svelte b/src/lib/MobNav.svelte index fbb6b025..93bc4f6a 100644 --- a/src/lib/MobNav.svelte +++ b/src/lib/MobNav.svelte @@ -37,7 +37,7 @@ function toggle() {
- logo + logo
diff --git a/src/lib/Nav.svelte b/src/lib/Nav.svelte index 2a887aeb..f6aaf77e 100644 --- a/src/lib/Nav.svelte +++ b/src/lib/Nav.svelte @@ -17,74 +17,46 @@ import { page, session } from '$app/stores' import Cookies from 'universal-cookie' const cookies = new Cookies() import { spring } from 'svelte/motion' -import { cart } from '../../store/cart' import Search from '$lib/Search.svelte' -export let section +import { Categories } from './graphql/_kitql/graphqlTypes' +import { KQL_Cart, KQL_Init, KQL_Me } from './graphql/_kitql/graphqlStores' +import { signOut } from './services' +import { onMount } from 'svelte' +import { store } from './../util' -const cart_qty = spring() -$: cart_qty.set($cart.qty) -$: offset = modulo($cart_qty, 1) +onMount(async () => { + await KQL_Me.query({}) + await KQL_Cart.query({}) +}) +export let section -function modulo(n, m) { - // handle negative numbers - return ((n % m) + m) % m -} -async function logout() { - try { - // const res = await post('auth/logout') - cookies.remove('token') - $session.user = null - $session.token = null - goto('/login') - } catch (e) {} +async function handleSignout() { + await signOut() }