Added expiration filter to front

This commit is contained in:
2023-07-31 17:23:24 +03:00
parent 6724a97352
commit 24bd39f689
3 changed files with 29 additions and 14 deletions

View File

@ -2,26 +2,33 @@ import { Announcement } from '../api/announcement/types'
import { getId } from '../utils/auth'
import { FiltersType } from '../utils/filters'
const userCategories = ['givingOut'] as const
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) => (
`Годен до ${new Date(ann.bestBy).toLocaleDateString('ru')}`
),
needDispose: (ann: Announcement) => (
`Были заинтересованы: ${ann.bookedBy} чел.`
),
}
const composeUserCategoriesFilters: Record<UserCategory, () => FiltersType> = {
givingOut: () => {
const userId = getId()
return ({ userId })
},
givingOut: () => ({
userId: getId(),
expired: false,
}),
needDispose: () => ({
userId: getId(),
expired: true,
}),
}
export type { UserCategory }