add quantity to combobox
This commit is contained in:
@@ -90,15 +90,23 @@ export default function Route({ loaderData: { seats } }: Route.ComponentProps) {
|
||||
() =>
|
||||
Promise.resolve({
|
||||
hits: Array.from(
|
||||
new Map(
|
||||
seats.map(({ course }) => [
|
||||
course.id,
|
||||
{
|
||||
...course,
|
||||
metadata__unit_price: 1
|
||||
seats
|
||||
.reduce((map, { course }) => {
|
||||
const existing = map.get(course.id)
|
||||
|
||||
if (existing) {
|
||||
existing.quantity += 1
|
||||
} else {
|
||||
map.set(course.id, {
|
||||
...course,
|
||||
metadata__unit_price: 1,
|
||||
quantity: 1
|
||||
})
|
||||
}
|
||||
]) ?? []
|
||||
).values()
|
||||
|
||||
return map
|
||||
}, new Map())
|
||||
.values()
|
||||
)
|
||||
}),
|
||||
[seats]
|
||||
|
||||
Reference in New Issue
Block a user