forked from polka_billy/porridger
Added expiration filter to front
This commit is contained in:
@ -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 }
|
||||
|
Reference in New Issue
Block a user