refactor(api): group public tag filters
This commit is contained in:
@@ -316,7 +316,15 @@ export function useProductCenter() {
|
||||
if (query.countryId) params.countryId = query.countryId;
|
||||
if (query.categoryId) params.categoryId = query.categoryId;
|
||||
if (!options.ignoreTags && query.tagIds.length > 0) {
|
||||
params.tagIds = query.tagIds.join(',');
|
||||
const grouped = new Map<string, string[]>();
|
||||
for (const tagId of query.tagIds) {
|
||||
const groupId = tags.value.find((tag) => tag.id === tagId)?.group?.id;
|
||||
if (!groupId) continue;
|
||||
grouped.set(groupId, [...(grouped.get(groupId) ?? []), tagId]);
|
||||
}
|
||||
params.tags = JSON.stringify(
|
||||
[...grouped].map(([tagGroupId, tagIds]) => ({ tagGroupId, tagIds })),
|
||||
);
|
||||
}
|
||||
if (query.keyword?.trim()) params.keyword = query.keyword.trim();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user