Added user points indicator

This commit is contained in:
2023-07-27 12:53:27 +03:00
parent abe3e64883
commit e60d5d6732
6 changed files with 32 additions and 20 deletions

View File

@ -1,26 +1,18 @@
import { Announcement } from '../api/announcement/types'
import { FiltersType } from '../utils/filters'
const userCategories = ['givingOut', 'booked', 'history'] as const
const userCategories = ['givingOut'] as const
type UserCategory = typeof userCategories[number]
const UserCategoriesNames: Record<UserCategory, string> = {
givingOut: 'Раздача',
booked: 'Бронь',
history: 'История',
}
const userCategoriesInfos: Record<UserCategory, (ann: Announcement) => string> = {
givingOut: (ann: Announcement) => (
`Годен до ${new Date(ann.bestBy).toLocaleDateString('ru')}`
),
booked: (ann: Announcement) => (
`Бронь ещё ${(ann as Announcement & { bookedBy: number[] }).bookedBy.length} чел.`
),
history: (ann: Announcement) => (
`Забрал ${new Date((ann as Announcement & { taken: number }).taken).toLocaleDateString('ru')}`
),
}
const composeUserCategoriesFilters: Record<UserCategory, () => FiltersType> = {
@ -29,16 +21,6 @@ const composeUserCategoriesFilters: Record<UserCategory, () => FiltersType> = {
return ({ userId })
},
booked: () => {
const userId = -1
return ({ bookedBy: userId })
},
history: () => {
const userId = -1
return ({ userId, status: 'taken' })
}
}
export type { UserCategory }