porridger/front/src/assets/userCategories.ts

36 lines
1.0 KiB
TypeScript

import { Announcement } from '../api/announcement/types'
import { getId } from '../utils/auth'
import { FiltersType } from '../utils/filters'
const userCategories = ['givingOut', 'needDispose'] as const
type UserCategory = typeof userCategories[number]
const UserCategoriesNames: Record<UserCategory, string> = {
givingOut: 'Раздача',
needDispose: 'Нужно утилизировать',
}
const userCategoriesInfos: Record<UserCategory, (ann: Announcement) => string> = {
givingOut: (ann: Announcement) => (
`Годен до ${ann.bestBy}`
),
needDispose: (ann: Announcement) => (
`Было заинтересно ${ann.bookedBy} чел.`
),
}
const composeUserCategoriesFilters: Record<UserCategory, () => FiltersType> = {
givingOut: () => ({
userId: getId(),
obsolete: false,
}),
needDispose: () => ({
userId: getId(),
obsolete: true,
}),
}
export type { UserCategory }
export { userCategories, UserCategoriesNames, userCategoriesInfos, composeUserCategoriesFilters }