chore(): Remove default_locale from StoreLocale (#14300)

## Summary

**What** — What changes are introduced in this PR?

Remove `default_locale` from Store <> Locale relation

**Why** — Why are these changes relevant or necessary?  

*Please provide answer here*

**How** — How have these changes been implemented?

*Please provide answer here*

**Testing** — How have these changes been tested, or how can the reviewer test the feature?

*Please provide answer here*

---

## Examples

Provide examples or code snippets that demonstrate how this feature works, or how it can be used in practice.  
This helps with documentation and ensures maintainers can quickly understand and verify the change.

```ts
// Example usage
```

---

## Checklist

Please ensure the following before requesting a review:

- [ ] I have added a **changeset** for this PR
    - Every non-breaking change should be marked as a **patch**
    - To add a changeset, run `yarn changeset` and follow the prompts
- [ ] The changes are covered by relevant **tests**
- [ ] I have verified the code works as intended locally
- [ ] I have linked the related issue(s) if applicable

---

## Additional Context

Add any additional context, related issues, or references that might help the reviewer understand this PR.


Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Nicolas Gorga
2025-12-15 06:05:46 -03:00
committed by GitHub
parent dd3eb10b1a
commit 8964a03fa1
23 changed files with 63 additions and 226 deletions

View File

@@ -100,19 +100,10 @@ export const AddLocalesForm = ({ store }: AddLocalesFormProps) => {
new Set([...data.locales, ...preSelectedRows])
) as string[]
let defaultLocale = store.supported_locales?.find(
(l) => l.is_default
)?.locale_code
if (!locales.includes(defaultLocale ?? "")) {
defaultLocale = locales?.[0]
}
await mutateAsync(
{
supported_locales: locales.map((l) => ({
locale_code: l,
is_default: l === defaultLocale,
})),
},
{

View File

@@ -7,7 +7,6 @@ import { Link } from "react-router-dom"
import { ActionMenu } from "../../../../../components/common/action-menu"
import { useSalesChannel, useStockLocation } from "../../../../../hooks/api"
import { useRegion } from "../../../../../hooks/api/regions"
import { useFeatureFlag } from "../../../../../providers/feature-flag-provider"
type StoreGeneralSectionProps = {
store: AdminStore
@@ -15,14 +14,12 @@ type StoreGeneralSectionProps = {
export const StoreGeneralSection = ({ store }: StoreGeneralSectionProps) => {
const { t } = useTranslation()
const isTranslationsEnabled = useFeatureFlag("translation")
const { region } = useRegion(store.default_region_id!, undefined, {
enabled: !!store.default_region_id,
})
const defaultCurrency = store.supported_currencies?.find((c) => c.is_default)
const defaultLocale = store.supported_locales?.find((l) => l.is_default)
const { sales_channel } = useSalesChannel(store.default_sales_channel_id!, {
enabled: !!store.default_sales_channel_id,
@@ -88,27 +85,6 @@ export const StoreGeneralSection = ({ store }: StoreGeneralSectionProps) => {
</Text>
)}
</div>
{isTranslationsEnabled && (
<div className="text-ui-fg-subtle grid grid-cols-2 px-6 py-4">
<Text size="small" leading="compact" weight="plus">
{t("store.defaultLocale")}
</Text>
{defaultLocale ? (
<div className="flex items-center gap-x-2">
<Badge size="2xsmall">
{defaultLocale.locale_code?.toUpperCase()}
</Badge>
<Text size="small" leading="compact">
{defaultLocale.locale?.name}
</Text>
</div>
) : (
<Text size="small" leading="compact">
-
</Text>
)}
</div>
)}
<div className="text-ui-fg-subtle grid grid-cols-2 px-6 py-4">
<Text size="small" leading="compact" weight="plus">
{t("store.defaultRegion")}

View File

@@ -60,8 +60,6 @@ export const StoreLocaleSection = ({ store }: StoreLocaleSectionProps) => {
meta: {
storeId: store.id,
supportedLocales: store.supported_locales,
defaultLocaleCode: store.supported_locales?.find((l) => l.is_default)
?.locale_code,
},
})
@@ -165,12 +163,10 @@ const LocaleActions = ({
storeId,
locale,
supportedLocales,
defaultLocaleCode,
}: {
storeId: string
locale: HttpTypes.AdminLocale
supportedLocales: HttpTypes.AdminStoreLocale[]
defaultLocaleCode: string
}) => {
const { mutateAsync } = useUpdateStore(storeId)
const { t } = useTranslation()
@@ -218,7 +214,6 @@ const LocaleActions = ({
icon: <Trash />,
label: t("actions.remove"),
onClick: handleRemove,
disabled: locale.code === defaultLocaleCode,
},
],
},
@@ -267,9 +262,7 @@ const useColumns = () => {
columnHelper.display({
id: "actions",
cell: ({ row, table }) => {
const { supportedLocales, storeId, defaultLocaleCode } = table.options
.meta as {
defaultLocaleCode: string
const { supportedLocales, storeId } = table.options.meta as {
supportedLocales: HttpTypes.AdminStoreLocale[]
storeId: string
}
@@ -279,7 +272,6 @@ const useColumns = () => {
storeId={storeId}
locale={row.original}
supportedLocales={supportedLocales}
defaultLocaleCode={defaultLocaleCode}
/>
)
},

View File

@@ -13,7 +13,6 @@ import { useUpdateStore } from "../../../../../hooks/api/store"
import { useComboboxData } from "../../../../../hooks/use-combobox-data"
import { sdk } from "../../../../../lib/client"
import { useDocumentDirection } from "../../../../../hooks/use-document-direction"
import { useFeatureFlag } from "../../../../../providers/feature-flag-provider"
type EditStoreFormProps = {
store: HttpTypes.AdminStore
@@ -22,7 +21,6 @@ type EditStoreFormProps = {
const EditStoreSchema = z.object({
name: z.string().min(1),
default_currency_code: z.string().optional(),
default_locale_code: z.string().optional(),
default_region_id: z.string().optional(),
default_sales_channel_id: z.string().optional(),
default_location_id: z.string().optional(),
@@ -30,16 +28,12 @@ const EditStoreSchema = z.object({
export const EditStoreForm = ({ store }: EditStoreFormProps) => {
const { t } = useTranslation()
const isTranslationsEnabled = useFeatureFlag("translation")
const { handleSuccess } = useRouteModal()
const direction = useDocumentDirection()
const form = useForm<z.infer<typeof EditStoreSchema>>({
defaultValues: {
name: store.name,
default_region_id: store.default_region_id || undefined,
default_locale_code:
store.supported_locales?.find((l) => l.is_default)?.locale_code ||
undefined,
default_currency_code:
store.supported_currencies?.find((c) => c.is_default)?.currency_code ||
undefined,
@@ -79,14 +73,10 @@ export const EditStoreForm = ({ store }: EditStoreFormProps) => {
})
const handleSubmit = form.handleSubmit(async (values) => {
const { default_currency_code, default_locale_code, ...rest } = values
const { default_currency_code, ...rest } = values
const normalizedMutation: HttpTypes.AdminUpdateStore = {
...rest,
supported_locales: store.supported_locales?.map((l) => ({
...l,
is_default: l.locale_code === default_locale_code,
})),
supported_currencies: store.supported_currencies?.map((c) => ({
...c,
is_default: c.currency_code === default_currency_code,
@@ -156,40 +146,6 @@ export const EditStoreForm = ({ store }: EditStoreFormProps) => {
)
}}
/>
{isTranslationsEnabled && (
<Form.Field
control={form.control}
name="default_locale_code"
render={({ field: { onChange, ...field } }) => {
return (
<Form.Item>
<Form.Label>{t("store.defaultLocale")}</Form.Label>
<Form.Control>
<Select
dir={direction}
{...field}
onValueChange={onChange}
>
<Select.Trigger ref={field.ref}>
<Select.Value />
</Select.Trigger>
<Select.Content>
{store.supported_locales?.map((locale) => (
<Select.Item
key={locale.locale_code}
value={locale.locale_code}
>
{locale.locale_code}
</Select.Item>
))}
</Select.Content>
</Select>
</Form.Control>
</Form.Item>
)
}}
/>
)}
<Form.Field
control={form.control}
name="default_region_id"