Skip to content

Commit

Permalink
place count에 따라 brand 정렬
Browse files Browse the repository at this point in the history
  • Loading branch information
siner308 committed Oct 6, 2024
1 parent 49441ae commit 358150a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/api/useBrandList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ export default function useBrandList() {
queryFn: async () =>
await supabaseClient
.from('brand')
.select('*')
.select(
`
*,
place_count:place(count)
`,
)
.then(({ data, error }) => {
if (error) {
postError(error).catch(console.error);
return Promise.reject(error);
}
return data;
}),
})
.then((brands) => brands.sort((a, b) => b.place_count[0].count - a.place_count[0].count)),
});
}
1 change: 1 addition & 0 deletions src/states/brands/brand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export interface Brand {
name: string;
label: string;
description?: string;
place_count: { count: number }[0];

Check failure on line 7 in src/states/brands/brand.ts

View workflow job for this annotation

GitHub Actions / build

Property '0' does not exist on type '{ count: number; }'.

Check failure on line 7 in src/states/brands/brand.ts

View workflow job for this annotation

GitHub Actions / build

Property '0' does not exist on type '{ count: number; }'.
}

0 comments on commit 358150a

Please sign in to comment.