From c9807bd6d479c4852b1643476db8e28858a08297 Mon Sep 17 00:00:00 2001 From: Alexandr SaVBaD Waltz Date: Mon, 6 Oct 2025 18:19:19 +0300 Subject: [PATCH] Features: 1) Add product rating support in types, GraphQL fragments, and UI components; 2) Implement feedback management including GraphQL mutations, composables, and notification handling; 3) Enhance locale switching with improved reactivity, Apollo query clearing, and supported locale validation; 4) Introduce `useOrderBuy` composable for order purchasing workflow. Fixes: 1) Correct mutation name from `setlanguage` to `setLanguage` for consistency; 2) Improve product listing reactivity by addressing missing initialization in `useStore`; 3) Replace generic product queries with parametrized `useProducts` for modularity; 4) Resolve minor typos, missing semicolons, and code formatting inconsistencies. Extra: 1) Refactor feedback-related types, composables, and GraphQL utilities for modularity; 2) Update styles, Vue templates, and related scripts with enhanced formatting; 3) Remove unused methods like `getProducts`, standardizing query reactivity; 4) Cleanup and organize imports across multiple files. --- storefront/app.vue | 33 ++++++--- storefront/components/base/footer/index.vue | 10 +-- storefront/components/base/header/catalog.vue | 20 ++--- storefront/components/forms/contact.vue | 20 ++--- storefront/components/forms/new-password.vue | 22 +++--- .../components/forms/reset-password.vue | 12 +-- storefront/components/home/hero.vue | 8 +- storefront/components/ui/breadcrumbs.vue | 30 ++++---- .../composables/categories/useCategories.ts | 6 ++ .../composables/contact/useContactUs.ts | 36 ++++++--- storefront/composables/feedbacks/index.ts | 1 + .../feedbacks/useFeedbackAction.ts | 74 +++++++++++++++++++ .../languages/useLanguageSwitch.ts | 40 +++++++--- .../languages/useLocaleRedirect.ts | 1 + .../notification/useNotification.ts | 8 +- storefront/composables/orders/index.ts | 3 +- storefront/composables/orders/useOrderBuy.ts | 46 ++++++++++++ .../composables/products/useProducts.ts | 27 ++++--- storefront/composables/store/useStore.ts | 64 ++++++++++------ .../graphql/fragments/feedback.fragment.ts | 7 ++ .../graphql/fragments/products.fragment.ts | 1 + storefront/graphql/mutations/cart.ts | 18 +++++ storefront/graphql/mutations/feedbacks.ts | 22 ++++++ storefront/graphql/mutations/languages.ts | 2 +- storefront/i18n/locales/en-gb.json | 3 +- storefront/nuxt.config.ts | 2 +- storefront/pages/index.vue | 14 +--- storefront/pages/product/[slug].vue | 11 +-- storefront/types/api/feedbacks.ts | 5 ++ storefront/types/api/orders.ts | 12 +++ storefront/types/app/feedbacks.ts | 5 ++ storefront/types/app/orders.ts | 4 + storefront/types/app/products.ts | 1 + storefront/types/index.ts | 4 +- 34 files changed, 418 insertions(+), 154 deletions(-) create mode 100644 storefront/composables/feedbacks/index.ts create mode 100644 storefront/composables/feedbacks/useFeedbackAction.ts create mode 100644 storefront/composables/orders/useOrderBuy.ts create mode 100644 storefront/graphql/fragments/feedback.fragment.ts create mode 100644 storefront/graphql/mutations/feedbacks.ts create mode 100644 storefront/types/api/feedbacks.ts create mode 100644 storefront/types/app/feedbacks.ts diff --git a/storefront/app.vue b/storefront/app.vue index 1e99eeb8..56dd9aef 100644 --- a/storefront/app.vue +++ b/storefront/app.vue @@ -20,7 +20,7 @@ import {useAppConfig} from "~/composables/config"; import { DEFAULT_LOCALE } from '~/config/constants'; import {useRefresh} from "~/composables/auth"; -import {useLanguages} from "~/composables/languages"; +import {useLanguages, useLocaleRedirect} from "~/composables/languages"; import {useCompanyInfo} from "~/composables/company"; import {useCategories} from "~/composables/categories"; @@ -55,6 +55,7 @@ const cookieLocale = useCookie( const { refresh } = useRefresh(); const { getCategories } = await useCategories(); +const { isSupportedLocale } = useLocaleRedirect(); let refreshInterval: NodeJS.Timeout; @@ -83,20 +84,32 @@ watch(locale, () => { let stopWatcher: VoidFunction = () => {}; +if (!cookieLocale.value) { + cookieLocale.value = DEFAULT_LOCALE; + await router.push({path: switchLocalePath(cookieLocale.value)}); +} + +if (locale.value !== cookieLocale.value) { + if (isSupportedLocale(cookieLocale.value)) { + await router.push({ + path: switchLocalePath(cookieLocale.value), + query: route.query + }); + } else { + cookieLocale.value = DEFAULT_LOCALE + + await router.push({ + path: switchLocalePath(DEFAULT_LOCALE), + query: route.query + }); + } +} + onMounted( async () => { refreshInterval = setInterval(async () => { await refresh(); }, 600000); - if (!cookieLocale.value) { - cookieLocale.value = DEFAULT_LOCALE; - await router.push({path: switchLocalePath(cookieLocale.value)}); - } - - if (locale.value !== cookieLocale.value) { - await router.push({path: switchLocalePath(cookieLocale.value)}); - } - stopWatcher = watch( () => appStore.isOverflowHidden, (hidden) => { diff --git a/storefront/components/base/footer/index.vue b/storefront/components/base/footer/index.vue index 340fbbe6..53c917ea 100644 --- a/storefront/components/base/footer/index.vue +++ b/storefront/components/base/footer/index.vue @@ -30,14 +30,14 @@