import { Announcement } from '../api/announcement/types' import { FiltersType } from '../utils/filters' const userCategories = ['givingOut', 'booked', 'history'] as const type UserCategory = typeof userCategories[number] const UserCategoriesNames: Record = { givingOut: 'Раздача', booked: 'Бронь', history: 'История', } const userCategoriesInfos: Record 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 FiltersType> = { givingOut: () => { const userId = -1 return ({ userId }) }, booked: () => { const userId = -1 return ({ bookedBy: userId }) }, history: () => { const userId = -1 return ({ userId, status: 'taken' }) } } export type { UserCategory } export { userCategories, UserCategoriesNames, userCategoriesInfos, composeUserCategoriesFilters }