mirror of
https://git.meshkee.com/BaloutPastry/dashboards.git
synced 2026-08-11 22:30:59 +04:30
Wire dashboards to the API and add customer portal plus discounts.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
af11d96fd0
commit
b103e330ef
+20
-3
@@ -118,16 +118,33 @@ export function removeCategory(
|
||||
}))
|
||||
}
|
||||
|
||||
export type FlatCategoryOption = {
|
||||
id: string
|
||||
nameFa: string
|
||||
nameEn: string
|
||||
labelFa: string
|
||||
labelEn: string
|
||||
depth: number
|
||||
}
|
||||
|
||||
export function flattenCategories(
|
||||
categories: Category[],
|
||||
prefix = '',
|
||||
): { id: string; labelFa: string; labelEn: string }[] {
|
||||
depth = 0,
|
||||
): FlatCategoryOption[] {
|
||||
return categories.flatMap((category) => {
|
||||
const labelFa = prefix ? `${prefix} / ${category.nameFa}` : category.nameFa
|
||||
const labelEn = prefix ? `${prefix} / ${category.nameEn}` : category.nameEn
|
||||
return [
|
||||
{ id: category.id, labelFa, labelEn },
|
||||
...flattenCategories(category.children, labelFa),
|
||||
{
|
||||
id: category.id,
|
||||
nameFa: category.nameFa,
|
||||
nameEn: category.nameEn,
|
||||
labelFa,
|
||||
labelEn,
|
||||
depth,
|
||||
},
|
||||
...flattenCategories(category.children, labelFa, depth + 1),
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user