feat: Use tag ids instead of values wherever possible (#8394)

This commit is contained in:
Stevche Radevski
2024-08-02 09:22:03 +02:00
committed by GitHub
parent 71f0d24359
commit 3a068c6b27
26 changed files with 259 additions and 229 deletions

View File

@@ -51,8 +51,8 @@ export const Notifications = () => {
}
}, [])
const handleOnOpen = (isOpen: boolean) => {
if (isOpen) {
const handleOnOpen = (shouldOpen: boolean) => {
if (shouldOpen) {
setHasUnread(false)
setOpen(true)
localStorage.setItem(LAST_READ_NOTIFICATION_KEY, new Date().toISOString())

View File

@@ -95,7 +95,7 @@ export const useProductTableFilters = (
if (product_tags && !isProductTagExcluded) {
const tagFilter: Filter = {
key: "tags",
key: "tag_id",
label: t("fields.tag"),
type: "select",
multiple: true,
@@ -108,21 +108,6 @@ export const useProductTableFilters = (
filters = [...filters, tagFilter]
}
// if (product_tags) {
// const tagFilter: Filter = {
// key: "tags",
// label: t("fields.tag"),
// type: "select",
// multiple: true,
// options: product_tags.map((t) => ({
// label: t.value,
// value: t.id,
// })),
// }
// filters = [...filters, tagFilter]
// }
if (sales_channels) {
const salesChannelFilter: Filter = {
key: "sales_channel_id",

View File

@@ -21,7 +21,7 @@ export const useProductTableQuery = ({
"category_id",
"collection_id",
"is_giftcard",
"tags",
"tag_id",
"type_id",
"status",
"id",
@@ -36,7 +36,7 @@ export const useProductTableQuery = ({
updated_at,
category_id,
collection_id,
tags,
tag_id,
type_id,
is_giftcard,
status,
@@ -54,7 +54,7 @@ export const useProductTableQuery = ({
collection_id: collection_id?.split(","),
is_giftcard: is_giftcard ? is_giftcard === "true" : undefined,
order: order,
tags: tags ? { value: tags.split(",") } : undefined,
tag_id: tag_id ? tag_id.split(",") : undefined,
type_id: type_id?.split(","),
status: status?.split(",") as HttpTypes.AdminProductStatus[],
q,

View File

@@ -27,7 +27,7 @@ export const ProductTagProductSection = ({
const { products, count, isPending, isError, error } = useProducts({
...searchParams,
tags: productTag.id,
tag_id: productTag.id,
})
const filters = useProductTableFilters(["product_tags"])

View File

@@ -17,7 +17,7 @@ export const normalizeProductFormValues = (
status: values.status,
is_giftcard: false,
tags: values?.tags?.length
? values.tags?.map((tag) => ({ value: tag }))
? values.tags?.map((tag) => ({ id: tag }))
: undefined,
sales_channels: values?.sales_channels?.length
? values.sales_channels?.map((sc) => ({ id: sc.id }))

View File

@@ -40,7 +40,7 @@ export const ProductOrganizationSection = ({
product.tags?.length
? product.tags.map((tag) => (
<Badge key={tag.id} className="w-fit" size="2xsmall" asChild>
<Link to={`/products?tags=${tag.id}`}>{tag.value}</Link>
<Link to={`/products?tag_id=${tag.id}`}>{tag.value}</Link>
</Badge>
))
: undefined

View File

@@ -78,9 +78,9 @@ export const ProductOrganizationForm = ({
collection_id: data.collection_id || undefined,
categories: data.category_ids.map((id) => ({ id })) || undefined,
tags:
data.tag_ids?.map((t) => {
t
}) || undefined,
data.tag_ids?.map((t) => ({
id: t,
})) || undefined,
},
{
onSuccess: ({ product }) => {