Skip to content

feat: channel data now localized#340

Merged
hmbanan666 merged 2 commits into
mainfrom
locales
Mar 11, 2025
Merged

feat: channel data now localized#340
hmbanan666 merged 2 commits into
mainfrom
locales

Conversation

@hmbanan666

@hmbanan666 hmbanan666 commented Mar 10, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Enhanced channel management with locale-specific input fields and dynamic placeholders in forms.
    • Improved display of channel information across pages, ensuring content reflects the user’s current locale.
    • Introduced a new delivery method selection interface with tabs for better user experience.
    • Added localized handling for payment method names and product variant names across various components.
    • New computed properties for localized payment method and variant retrieval.
  • Style

    • Updated navigation design with adaptive background styling for a consistent look on various screen sizes.
    • Enhanced visual styling of components with new background colors and layout adjustments.

@coderabbitai

coderabbitai Bot commented Mar 10, 2025

Copy link
Copy Markdown

Walkthrough

This pull request updates both the UI components and backend logic to enhance localization support for channel data. Several Vue components now use the getLocaleValue function and the useI18n hook to dynamically render locale-specific content. In addition, the channel store and type definitions have been modified to use arrays of LocaleValue objects instead of simple strings. The API endpoints have also been updated to retrieve existing channels and apply localized updates, and a minor package downgrade was applied in the workspace configuration.

Changes

File(s) Change Summary
apps/web-app/.../Form/UpdateChannel.vue Updated input fields with locale-specific placeholders wrapped in a button group with UDropdownMenu; state management now retrieves values from localeState with new variables (localeState, defaultName, defaultDescription, defaultConditions) and updates resetState.
apps/web-app/.../Modal/DeliveryInfo.vue, apps/web-app/.../Navigation/Main.vue, apps/web-app/.../pages/command-center/system/index.vue, apps/web-app/.../pages/index.vue Replaced direct interpolation of channel properties with calls to getLocaleValue and integrated useI18n for obtaining the current locale, enabling dynamic, localized content display.
apps/web-app/.../Navigation/index.vue Adjusted background color classes to apply responsive design (fully opaque on large screens, semi-transparent on smaller screens).
apps/web-app/.../stores/channel.ts, packages/core/types/index.d.ts Updated channel property types (name, description, conditions) from strings to arrays of LocaleValue objects.
packages/core/server/api/channel/index.patch.ts, packages/core/server/api/channel/index.put.ts Enhanced API endpoints to handle localized updates: added a call to getChannel, implemented error handling, and used updateLocaleValues for channel fields during patching and creation.
packages/core/shared/services/channel.ts Added a locale field to the channelPaymentMethodCreateSchema and channelPaymentMethodUpdateSchema for validating locale data.
pnpm-workspace.yaml Downgraded @nuxt/ui package version from 3.0.0-beta.3 to 3.0.0-beta.2.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI_Component
    participant API_Server
    participant DB_Service

    User->>UI_Component: Select locale and update channel details
    UI_Component->>API_Server: Send PATCH/PUT request with localized data
    API_Server->>DB_Service: getChannel(channelId)
    DB_Service-->>API_Server: Return existing channel (or error)
    API_Server->>API_Server: Process data with updateLocaleValues()
    API_Server->>DB_Service: patchChannel/createChannel(updatedData)
    DB_Service-->>API_Server: Acknowledge update
    API_Server-->>UI_Component: Respond with updated channel info
Loading

Possibly related PRs

Poem

I'm a bunny on a coding spree,
Hopping through components with glee.
Locales now dance in every view,
Channel data fresh and true.
With tweaked APIs and schema so neat,
My rabbit code can't be beat! 🐰

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

 ERR_PNPM_OPTIONAL_DEPS_REQUIRE_PROD_DEPS  Optional dependencies cannot be installed without production dependencies

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (1)
apps/web-app/stores/channel.ts (1)

113-116: 💡 Verification agent

❓ Verification inconclusive

Verify locale fallback in search functionality

The getProductsByQuery function correctly handles the new localized product names, but consider adding a fallback mechanism for when a translation doesn't exist in the current locale.


🏁 Script executed:

#!/bin/bash
# Check if fallback mechanisms exist elsewhere in the codebase
rg -A 3 -B 3 "getLocaleValue|locale.value" --type ts --type vue

Length of output: 93


Ensure fallback mechanism for missing locale translations in search
The current implementation in getProductsByQuery relies solely on the product name for the active locale:

function getProductsByQuery(query: string): ProductWithCategory[] {
  const { locale } = useI18n()
  const productList = products.value.filter((product) =>
    product.name.find((name) => name.locale === locale.value)
      ?.value.toLowerCase().includes(query.toLowerCase())
  )
  // ...
}

If no translation exists for the current locale, the optional chaining returns undefined, causing .toLowerCase() to fail. There isn’t any fallback in place to handle this scenario. Please consider one of the following approaches to resolve the issue:

  • Fallback to a default translation (e.g., use a default locale or the first available translation):
    function getProductsByQuery(query: string): ProductWithCategory[] {
      const { locale } = useI18n()
      return products.value.filter((product) => {
        const localizedName = product.name.find((name) => name.locale === locale.value)?.value ||
                              product.name[0].value; // fallback to first available translation
        return localizedName.toLowerCase().includes(query.toLowerCase());
      });
    }
  • Implement a more robust locale resolution by abstracting the translation lookup into a helper (for instance, a getLocaleValue function) that internally returns a fallback when required.

Please verify the chosen approach across the related modules to ensure consistency in handling locales.

🧹 Nitpick comments (2)
apps/web-app/app/components/Form/UpdateChannel.vue (2)

31-31: Consider extending locale selection to all fields

While placeholders for localized content are added to all fields, the locale selector is only implemented for the name field. Consider adding similar locale selection functionality to the description and conditions fields.

 <UFormField :label="$t('common.description')" name="description">
+  <UButtonGroup class="w-full">
+    <UDropdownMenu :items="localeState.items">
+      <UButton
+        color="neutral"
+        variant="outline"
+        :icon="localeState.icon.value"
+        class="w-12 items-center justify-center"
+      />
+    </UDropdownMenu>
+
   <UTextarea
     v-model="state.description"
     :placeholder="defaultDescription"
     size="xl"
     class="w-full items-center justify-center"
   />
+  </UButtonGroup>
 </UFormField>

Similar changes could be applied to the conditions field (lines 98-106).

Also applies to: 101-101


139-144: Add validation for required locale values

Consider adding validation to ensure that at least the default locale values are provided for required fields like name.

You could extend the channelUpdateSchema to include validation for locale-specific required fields, ensuring that at minimum the default locale has values set for essential fields.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e573461 and bbb37e7.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (12)
  • apps/web-app/app/components/Form/UpdateChannel.vue (4 hunks)
  • apps/web-app/app/components/Modal/DeliveryInfo.vue (2 hunks)
  • apps/web-app/app/components/Navigation/Main.vue (1 hunks)
  • apps/web-app/app/components/Navigation/index.vue (1 hunks)
  • apps/web-app/app/pages/command-center/system/index.vue (4 hunks)
  • apps/web-app/app/pages/index.vue (2 hunks)
  • apps/web-app/stores/channel.ts (1 hunks)
  • packages/core/server/api/channel/index.patch.ts (2 hunks)
  • packages/core/server/api/channel/index.put.ts (1 hunks)
  • packages/core/shared/services/channel.ts (2 hunks)
  • packages/core/types/index.d.ts (1 hunks)
  • pnpm-workspace.yaml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (23)
apps/web-app/app/pages/index.vue (2)

6-6: LGTM! Proper implementation of channel data localization

The changes correctly utilize the getLocaleValue function with appropriate parameters to display localized channel name and description based on the user's current locale.

Also applies to: 9-9, 21-21


26-26: LGTM! Localized page metadata

Good implementation of localization for the page title and meta description. Using locale.value is correct since this is a reactive value from the Composition API.

Also applies to: 30-30

apps/web-app/app/components/Modal/DeliveryInfo.vue (2)

5-5: Successfully implemented localization for channel conditions.

The change from displaying raw conditions to using getLocaleValue ensures that content is properly localized based on the user's current locale setting.


35-35: Added locale support properly.

Adding the locale constant from useI18n() provides the necessary information for localization functions. This aligns with other components in the application.

packages/core/server/api/channel/index.put.ts (2)

21-22: Properly localized channel name during creation.

Implementing the updateLocaleValues function for the channel name ensures proper localization support from the initial creation of a channel.

Also applies to: 26-26


31-32: Initialized description and conditions as arrays for localization.

Changed from null to empty arrays to support the LocaleValue[] structure needed for localization. This change is necessary to maintain consistency with the updated data model.

packages/core/server/api/channel/index.patch.ts (4)

1-1: Added necessary import for enhanced error handling.

Adding the getChannel import supports the new error handling logic that verifies the channel exists before attempting updates.


11-17: Improved error handling for channel updates.

Adding a check to verify the channel exists before attempting updates provides better error handling and a more specific error message.


19-22: Added proper locale-aware updates for channel data.

The code now correctly handles localized updates for name, description, and conditions by using the updateLocaleValues function, which preserves existing translations while updating the specified locale.


23-28:

Details

❓ Verification inconclusive

Potential redundancy in merged object properties.

There might be an issue with the spread operator in ...data if data already contains name, description, and conditions fields.

The current implementation first spreads all properties from data and then overwrites specific fields. Verify if data could contain the same properties that are being explicitly set afterward. If it does, consider removing those properties from data before spreading:


🏁 Script executed:

#!/bin/bash
# Check if channelUpdateSchema includes name, description, or conditions fields
rg -A 20 "channelUpdateSchema" --include="*.ts"

Length of output: 489


Action Required: Confirm Schema Overlap in Patch Object

The current implementation spreads data before explicitly setting name, description, and conditions. We need to verify whether the underlying schema (i.e. the definition linked to channelUpdateSchema) already contains these properties. If so, there is a potential for redundancy, and you might need to remove these keys from data before spreading to avoid unintended overrides.

  • Verify Schema: Please check if channelUpdateSchema includes the fields name, description, and conditions.
  • Adjust Object Construction: If these properties exist in data due to the schema, consider removing them from data prior to the spread to ensure the patch object is constructed as intended.
apps/web-app/app/components/Navigation/Main.vue (1)

9-9: Successfully implemented localization for channel name and description.

Changed from directly displaying static content to using the getLocaleValue function for proper localization of the channel name and description in the navigation component. This change is consistent with the localization approach used throughout the application.

Also applies to: 12-12

apps/web-app/app/pages/command-center/system/index.vue (4)

23-24: Improved consistency with CSS variables and localization

The switch to CSS variables with bg-(--ui-bg-muted) rather than hardcoded background classes enhances theming consistency, while the introduction of getLocaleValue properly displays localized channel names.


26-28: Good conditional rendering and localization for description

The conditional check on description.length prevents displaying empty sections, and the use of getLocaleValue ensures proper localization of content.


48-53: Properly handling localized delivery conditions

The conditional rendering and localization implementation for delivery conditions is well-implemented, ensuring content is only shown when available and is properly localized.


131-131: Updated useI18n() to include locale

The locale is now properly extracted from useI18n() to support the localization features throughout the component.

packages/core/types/index.d.ts (1)

7-9: Appropriate type changes for localization support

The Channel interface now correctly uses LocaleValue[] arrays for name, description, and conditions, enabling multi-language support throughout the application.

apps/web-app/stores/channel.ts (1)

15-16: State types aligned with updated interface

The store's state variables have been properly updated to match the Channel interface changes, using arrays of LocaleValue objects instead of simple strings.

Also applies to: 24-24

apps/web-app/app/components/Form/UpdateChannel.vue (2)

9-25: Well-implemented locale selection UI

The addition of a locale selector dropdown alongside the name input provides an intuitive UI for managing translations. The button group implementation is clean and follows UI component patterns.


133-137: Good state management for localization

The implementation of useLocalizedState along with computed properties for default values ensures a proper foundation for managing localized content.

pnpm-workspace.yaml (1)

19-19:

Details

❓ Verification inconclusive

Verify reason for package downgrade

The version of @nuxt/ui has been downgraded from 3.0.0-beta.3 to 3.0.0-beta.2. While this might be intentional to address compatibility issues with localization features, package downgrades should be documented.


🏁 Script executed:

#!/bin/bash
# Check if there are any issues or discussions related to this downgrade
git log -p -- pnpm-workspace.yaml | grep -B 10 -A 10 "@nuxt/ui" | head -20

Length of output: 0


Action: Verify Documentation for Package Downgrade

It appears that the version change for @nuxt/ui from 3.0.0-beta.3 to 3.0.0-beta.2 isn’t documented in the commit history for the pnpm-workspace.yaml file. Please manually verify that this downgrade is intentional and that the reason (e.g., to address compatibility issues with localization features) is properly documented in the commit message or related project notes.

  • If the downgrade is intentional, add a brief note in the commit or project documentation to explain it.
  • Otherwise, consider reverting or updating the change to maintain clarity.
apps/web-app/app/components/Navigation/index.vue (1)

6-6: Improved responsive background behavior

The background opacity is now responsive - solid on mobile screens and semi-transparent (25%) on larger screens. This change provides better contrast and readability on smaller devices while maintaining the aesthetic on larger screens.

packages/core/shared/services/channel.ts (2)

2-2: Added locale import for localization support

Good addition of the locale import to support the channel data localization feature.


15-15:

Details

✅ Verification successful

Enhanced schema with locale validation

The channelUpdateSchema now includes locale validation through the imported locale schema. This ensures that locale data in channel updates is properly validated, which is essential for the localization feature.


🏁 Script executed:

#!/bin/bash
# Let's examine how the locale schema is defined
cat packages/core/shared/services/locale.ts

Length of output: 113


Locale validation integration verified

  • The locale schema imported from packages/core/shared/services/locale.ts is confirmed to enforce valid locale values ('en' and 'ru').
  • The channelUpdateSchema now correctly incorporates this validation, ensuring that channel updates adhere to expected locale formats for the localization feature.

@hmbanan666 hmbanan666 self-assigned this Mar 11, 2025
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
9.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
apps/web-app/app/components/CommandCenter/Navigation.vue (1)

43-48: Menu item added with hardcoded badge value

The new "checkouts" menu item has been added correctly using the translation function for localization. However, the badge value "4" appears to be hardcoded rather than dynamic, which might not reflect the actual number of checkouts or notifications.

Consider making the badge value dynamic by:

  {
    label: t('center.menu.checkouts'),
    to: '/command-center/checkout',
    icon: 'food:checkouts',
-    badge: '4',
+    badge: checkoutCount.value > 0 ? checkoutCount.value.toString() : undefined,
  },

This would require adding a reactive property like checkoutCount that fetches the actual count from your store or API.

apps/web-app/app/components/Form/UpdateProductVariant.vue (1)

207-216: Consider adding more detailed error information

The error toast is updating with a fixed description of "..." which doesn't provide users with useful information about what went wrong.

     toast.update(operationId, {
       title: t('error.title'),
       icon: 'food:close',
       color: 'error',
-      description: '...',
+      description: error.value?.message || t('error.unknown'),
       duration: 3000,
       ui: {
         icon: '',
       },
     })
apps/web-app/app/components/Form/UpdateChannelPaymentMethod.vue (1)

73-95: Consider enhancing toast notifications

For consistency with UpdateProductVariant.vue, consider implementing the same toast notification pattern with operationId to provide better user feedback during the update process.

+const operationId = useId()
+
 async function onSubmit(event: FormSubmitEvent<ChannelPaymentMethodUpdateSchema>) {
+  toast.add({
+    id: operationId,
+    title: t('toast.in-process'),
+    description: t('toast.updating-data'),
+    icon: 'food:loader',
+    duration: 120000,
+    ui: {
+      icon: 'animate-spin',
+    },
+  })
+
   emit('submitted')

   const { data, error } = await useAsyncData(
     'update-payment-method',
     () => $fetch(`/api/channel/payment-method/${paymentMethodId}`, {
       method: 'PATCH',
       body: event.data,
     }),
   )

   if (error.value) {
     console.error(error.value)
-    toast.add({ title: t('error.title'), description: '...' })
+    toast.update(operationId, {
+      title: t('error.title'),
+      icon: 'food:close',
+      color: 'error',
+      description: error.value?.message || t('error.unknown'),
+      duration: 3000,
+      ui: {
+        icon: '',
+      },
+    })
   }

   if (data.value) {
     await channel.update()
     emit('success')
-    toast.add({ title: t('toast.payment-method-updated'), description: t('toast.updating-data') })
+    toast.update(operationId, {
+      title: t('toast.payment-method-updated'),
+      description: undefined,
+      icon: 'food:check',
+      color: 'success',
+      duration: 3000,
+      ui: {
+        icon: '',
+      },
+    })
     resetState()
   }
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bbb37e7 and 958f9a9.

📒 Files selected for processing (33)
  • packages/core/shared/services/channel.ts (2 hunks)
  • packages/core/types/index.d.ts (1 hunks)
  • apps/web-app/app/app.config.ts (1 hunks)
  • apps/web-app/app/components/Cart/DeliveryMethodSwitch.vue (1 hunks)
  • apps/web-app/app/components/Checkout/Line.vue (1 hunks)
  • apps/web-app/app/components/CommandCenter/CheckoutCard.vue (4 hunks)
  • apps/web-app/app/components/CommandCenter/CheckoutLine.vue (1 hunks)
  • apps/web-app/app/components/CommandCenter/Navigation.vue (1 hunks)
  • apps/web-app/app/components/CommandCenter/PaymentMethodCard.vue (2 hunks)
  • apps/web-app/app/components/Form/AttachProduct.vue (1 hunks)
  • apps/web-app/app/components/Form/CreateChannelPaymentMethod.vue (2 hunks)
  • apps/web-app/app/components/Form/CreateProduct.vue (1 hunks)
  • apps/web-app/app/components/Form/CreateProductVariant.vue (3 hunks)
  • apps/web-app/app/components/Form/DeleteProduct.vue (1 hunks)
  • apps/web-app/app/components/Form/UpdateChannelPaymentMethod.vue (2 hunks)
  • apps/web-app/app/components/Form/UpdateProductAvailability.vue (1 hunks)
  • apps/web-app/app/components/Form/UpdateProductVariant.vue (5 hunks)
  • apps/web-app/app/components/Header.vue (1 hunks)
  • apps/web-app/app/components/SearchBlock.vue (2 hunks)
  • apps/web-app/app/pages/catalog/[categorySlug]/[productSlug]/index.vue (2 hunks)
  • apps/web-app/app/pages/checkout/index.vue (3 hunks)
  • apps/web-app/app/pages/command-center/product/[productId]/variants.vue (1 hunks)
  • apps/web-app/app/pages/command-center/product/index.vue (4 hunks)
  • apps/web-app/app/pages/finish/index.vue (3 hunks)
  • apps/web-app/stores/checkout.ts (2 hunks)
  • packages/core/server/api/channel/payment-method/[id].patch.ts (2 hunks)
  • packages/core/server/api/channel/payment-method/index.post.ts (1 hunks)
  • packages/core/server/api/checkout/index.patch.ts (2 hunks)
  • packages/core/server/api/product/variant/[id].patch.ts (2 hunks)
  • packages/core/server/api/product/variant/index.post.ts (1 hunks)
  • packages/core/shared/services/channel.ts (1 hunks)
  • packages/core/shared/services/product.ts (2 hunks)
  • packages/core/types/index.d.ts (2 hunks)
✅ Files skipped from review due to trivial changes (2)
  • apps/web-app/app/components/Header.vue
  • apps/web-app/app/components/Form/UpdateProductAvailability.vue
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/core/shared/services/channel.ts
  • packages/core/types/index.d.ts
  • packages/core/types/index.d.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (70)
apps/web-app/app/app.config.ts (2)

66-69: CSS variable change in button gradient variant.

The disabled state background has been updated from --ui-bg-accented to --ui-bg-elevated, which provides better visual consistency with the new tab styling. This change aligns with the overall UI improvements for localized content.


70-80: Good addition of gradient tab styling.

The new tabs configuration provides consistent styling with the button gradient variant and creates a cohesive UI experience. The use of calculated border radius values (calc(var(--ui-radius)*2) and calc(var(--ui-radius)*1.5)) ensures proportional styling across different UI scale settings.

packages/core/server/api/product/variant/index.post.ts (1)

15-15: Name field updated to support localization

This change properly transforms the product variant's name from a string to an array of localized values, aligning with the PR objective of localizing channel data.

packages/core/server/api/channel/payment-method/index.post.ts (1)

15-15: Name field updated to support localization

The payment method's name field has been correctly transformed to use the localized structure, consistent with the approach used in other endpoints.

apps/web-app/app/components/Checkout/Line.vue (1)

14-14: Product variant now properly displays localized value

The component now appropriately uses the getLocaleValue function to display the localized variant name, providing consistent localization with the product name rendering on line 10.

apps/web-app/app/components/SearchBlock.vue (2)

2-2: Updated background styling

The background class has been changed from bg-(--ui-bg-accented) to bg-(--ui-bg-elevated), which appears to be a UI styling adjustment.


10-10: Added 'soft' variant to buttons

The variant="soft" property has been added to UButton components, providing a more subtle appearance that likely complements the new styling approach.

Also applies to: 30-30

packages/core/server/api/channel/payment-method/[id].patch.ts (3)

2-2: Import added for enhanced payment method handling

The addition of getPaymentMethod import allows for proper validation of payment method existence before attempting updates.


19-25: Important validation added before update

Good enhancement to verify that the payment method exists before attempting to update it, providing a proper 404 response when not found.


27-32: Improved localization handling for payment method names

This change properly handles the localized name values by:

  1. Using existing name values when no update is provided
  2. Using updateLocaleValues to merge new locale values with existing ones
  3. Passing the complete localized name object in the patch operation

This is a robust implementation that preserves existing translations when updating only one locale.

apps/web-app/app/pages/command-center/product/[productId]/variants.vue (1)

11-11: Properly localized variant name display

The implementation now correctly uses getLocaleValue to display the variant name in the user's preferred locale, with fallback to the channel's default locale.

apps/web-app/app/components/CommandCenter/PaymentMethodCard.vue (3)

2-2: Enhanced card styling with rounded corners

The addition of the rounded-xl class improves the visual consistency of the payment method card.


6-6: Properly localized payment method name display

The implementation now correctly uses getLocaleValue to display the payment method name in the user's preferred locale.


20-20: Added locale from i18n for localization support

Properly imported the locale from useI18n() hook to ensure consistent localization across the component.

apps/web-app/app/components/CommandCenter/CheckoutLine.vue (2)

3-7: Improved layout structure for product details

The layout has been updated from horizontal to vertical arrangement, which provides better organization for product information and likely improves the mobile experience.


8-14: Enhanced localization for product variant details

Both the product name and variant name are now properly localized using getLocaleValue. The weight unit display is also localized appropriately.

packages/core/shared/services/product.ts (2)

23-23: Good addition of locale field to productVariantCreateSchema

Adding the locale field to product variant schemas aligns with the PR objective of enhancing localization support. This change is consistent with the existing product schemas that already had the locale field.


40-40: Good addition of locale field to productVariantUpdateSchema

Adding the locale field to the update schema ensures consistency between create and update operations for product variants. This is a necessary change for proper localization support.

packages/core/server/api/product/variant/[id].patch.ts (5)

2-2: Good import addition for improved data flow

Adding the import for getProductVariant enables the improved data flow in this endpoint.


20-26: Improved error handling with variant existence check

Good addition of a check to verify the product variant exists before attempting updates. This provides better error handling and clearer error messages to clients.


28-28: Enhanced localization support with updateLocaleValues

This line significantly improves how localized content is handled. Using updateLocaleValues ensures that only the specific locale's value is updated while preserving other locale values.


30-33: Proper update with modified name structure

Good approach to include the updated localized name in the patch operation.


39-39: Improved response with updated data

Returning the updated variant in the response provides clients with the most current data after the update operation.

apps/web-app/app/components/Form/DeleteProduct.vue (1)

27-29: Good refactoring of operationId and async function

Moving the operationId declaration outside the onSubmit function prevents unnecessary recreation on each function call. Explicitly marking the function as async improves code clarity.

packages/core/shared/services/channel.ts (4)

2-2: Good addition of locale import

Adding the locale import is necessary for the schema changes in this file.


15-15: Enhanced localization for channel updates

Adding the locale field to channelUpdateSchema aligns with the PR objective of enabling localized channel data.


34-34: Good localization support for payment method creation

Adding locale support to payment method creation is consistent with the overall localization approach in the application.


42-42: Good localization support for payment method updates

Adding locale support to payment method updates ensures consistency between create and update operations.

apps/web-app/app/components/Form/CreateProduct.vue (1)

74-76: Good refactoring: Variable scope changed appropriately

Moving the operationId declaration outside the onSubmit function is a good practice. This improves code organization and maintains a consistent pattern across the codebase, while ensuring the variable can be reused if needed.

apps/web-app/app/components/Form/AttachProduct.vue (1)

67-69: Good refactoring: Improved variable scope

Moving the operationId declaration outside the onSubmit function follows a consistent pattern with other components and improves code organization.

apps/web-app/app/pages/catalog/[categorySlug]/[productSlug]/index.vue (4)

15-15: Styling enhancement looks good

The addition of the text-(--ui-text-highlighted) class improves the visual hierarchy of the page.


18-21: Good localization implementation

The addition of the localized variant name display improves the user experience by ensuring content is properly localized.


26-26: Proper localization of select items

Using getLocaleValue for variant names in the select dropdown ensures consistent localization across the UI.


67-67: UI enhancement with updated background

Changing to bg-(--ui-bg-elevated)/50 provides a more modern, slightly transparent elevated background that enhances the nutrition information section.

apps/web-app/app/pages/checkout/index.vue (3)

9-9: UI enhancement with updated background

Changing to bg-(--ui-bg-elevated)/50 provides a more modern, slightly transparent elevated background for the checkout form section.


119-119: Consistent UI styling

Using the same bg-(--ui-bg-elevated)/50 background maintains visual consistency across checkout sections.


152-152: Proper localization of payment methods

Using getLocaleValue for payment method names ensures they are correctly displayed according to the user's locale preferences.

packages/core/server/api/checkout/index.patch.ts (2)

92-92: Effective localization implementation for payment method name.

The code now properly retrieves the localized payment method name by finding the name entry that matches the current locale. This aligns with the localization strategy implemented across the application.


119-119: Well-implemented localization for product variant name.

Similar to the payment method name localization, this code effectively retrieves the localized variant name based on the current locale. This consistent approach ensures proper internationalization throughout the checkout process.

apps/web-app/app/components/Form/CreateProductVariant.vue (3)

9-24: Good UI enhancement for locale selection.

The button group with dropdown integration provides a clean way for users to select the locale when entering product variant names. This implementation nicely separates the locale selection from the name input field.


145-145: Well-implemented localization state management.

The useLocalizedState composable is a good approach for managing localization state and keeping it in sync with the form's reset functionality.


148-148: Properly initialized locale in state.

The locale is correctly initialized in both the initial state and the reset function, ensuring consistency throughout the component lifecycle.

Also applies to: 164-164

apps/web-app/app/components/Form/CreateChannelPaymentMethod.vue (2)

9-24: Clean implementation of localized input field.

The UI for locale selection is consistent with other components, providing a unified experience across the application. The button group layout is well-structured and provides clear visual feedback about the currently selected locale.


60-60: Proper state management for localization.

The localization state is correctly implemented and initialized with the channel's default locale. The state properties are properly managed in both initial state and reset function to maintain consistency.

Also applies to: 63-63, 70-70

apps/web-app/app/components/CommandCenter/CheckoutCard.vue (4)

2-2: UI enhancement with improved background styling.

The background styling has been updated to use a more elevated appearance with semi-transparency, which should provide better visual hierarchy.


50-50: Simplified payment method display using computed property.

The payment method display now leverages a computed property instead of directly accessing the data in the template, which improves readability and maintainability.


60-60: Improved layout structure for checkout lines.

The updated flex layout with column direction and consistent gap spacing will provide a more uniform appearance for the checkout lines.


84-84: Well-implemented localization for payment method display.

The addition of the locale from useI18n() and the computed property for retrieving the localized payment method name using getLocaleValue is a clean implementation that ensures proper internationalization.

Also applies to: 90-90

apps/web-app/stores/checkout.ts (2)

9-9: Type change improves code consistency

Changing from null to undefined for optional values aligns with TypeScript best practices and helps eliminate null checks. This makes the code more consistent and easier to maintain.


31-31: Good simplification of assignment

Removing the type assertion simplifies the code. The TypeScript compiler can now infer the correct type automatically from the context.

apps/web-app/app/pages/finish/index.vue (3)

6-6: UI enhancement with new background style

The change from bg-(--ui-bg-muted) to bg-(--ui-bg-elevated)/50 provides a more elevated appearance with 50% opacity, which improves visual hierarchy.


45-45: Improved localization for payment method display

Using the computed property for payment method display ensures consistent localization handling.


95-107: Well-implemented localization support

Great implementation of the localization feature! The code now properly:

  1. Imports the locale from useI18n()
  2. Creates a computed property for the payment method that uses getLocaleValue
  3. Handles the default locale fallback appropriately

This ensures the payment method name is correctly displayed in the user's preferred language.

apps/web-app/app/components/Cart/DeliveryMethodSwitch.vue (3)

2-8: UI improvement with tabs component

Excellent UI enhancement! Replacing separate buttons with a tabs component provides a more intuitive and modern interface for delivery method selection. The markup is clean and properly configured.


12-24: Well-structured tab items with localization

Good implementation of the tab items array with:

  • Proper localization using t() function
  • Correct value mapping to delivery methods
  • Appropriate disabled state handling based on availability

25-29: Reactive delivery method handling

Great implementation of the delivery method state with:

  1. Initializing selectedTab with the current checkout.deliveryMethod
  2. Using a watcher to update the checkout store when the selection changes

This creates a clean, reactive connection between the UI and the data store.

apps/web-app/app/pages/command-center/product/index.vue (4)

16-17: Improved input handling with v-model

Good implementation of v-model binding for the filter input. This simplifies the code by using Vue's two-way binding rather than manually handling events.


91-91: Layout improvement with ml-auto

Adding ml-auto class properly aligns the product image to the right of its container, improving the visual layout.


107-107: Enhanced variant display with localization

Good implementation of localized variant display using getLocaleValue. The string interpolation elegantly combines:

  • Localized variant name
  • Weight information with correct unit
  • Price with correct currency formatting based on locale

This ensures users see product variant information in their preferred language and format.


164-165: Improved filtering with localization support

Excellent implementation of the filtering mechanism that now properly handles localized product names:

  1. Added filterValue ref for state management
  2. Updated the data computed property to filter products based on their localized names
  3. Implemented case-insensitive matching using toLowerCase()

This ensures users can search for products in any supported language.

apps/web-app/app/components/Form/UpdateProductVariant.vue (6)

9-25: Good implementation of localized input field

The addition of a locale selector dropdown alongside the input field is a clean approach to handling multi-language content. The placeholder fallback mechanism is also well implemented.


147-150: Well-structured localization setup

Good use of the useLocalizedState hook for managing locales, and smart extraction of the default name for the fallback placeholder.


152-153: LGTM: Proper state initialization with locale

The state properly initializes with the current locale and finds the corresponding name value.


167-168: Consistent state reset implementation

The resetState function properly reinitializes both locale and name properties.


181-193: Good user feedback implementation

Using a unique operationId for toast notifications allows for consistent updating of the same toast, providing a better user experience during asynchronous operations.


222-231: Well-implemented success feedback

The success toast notification appropriately updates the existing toast, showing the completed operation status.

apps/web-app/app/components/Form/UpdateChannelPaymentMethod.vue (4)

9-25: Good implementation of localized input field

The addition of a locale selector dropdown alongside the input field follows the same pattern as in other components, showing a consistent approach to localization.


57-60: Well-structured localization setup

Good use of the useLocalizedState hook and extracting the default name for the placeholder.


62-63: LGTM: Proper state initialization with locale

The state correctly initializes with the current locale and finds the appropriate name value.


68-69: Consistent state reset implementation

The resetState function properly handles locale-specific data, consistent with other components.

@hmbanan666 hmbanan666 merged commit 4a8e653 into main Mar 11, 2025
@hmbanan666 hmbanan666 deleted the locales branch March 11, 2025 14:06
@coderabbitai coderabbitai Bot mentioned this pull request Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant