Adjust ticket filters visibility and add date range
This commit is contained in:
parent
5f7ef3fd03
commit
cc68c85246
3 changed files with 110 additions and 91 deletions
|
|
@ -21,6 +21,7 @@ function getParamValue(value: string | string[] | undefined): string | undefined
|
|||
|
||||
function deriveInitialFilters(params: Record<string, string | string[] | undefined>): Partial<TicketFiltersState> {
|
||||
const initial: Partial<TicketFiltersState> = {}
|
||||
const isValidDateParam = (value?: string) => Boolean(value && /^\d{4}-\d{2}-\d{2}$/.test(value))
|
||||
const view = getParamValue(params.view)
|
||||
if (view === "completed" || view === "active") {
|
||||
initial.view = view
|
||||
|
|
@ -41,10 +42,10 @@ function deriveInitialFilters(params: Record<string, string | string[] | undefin
|
|||
if (assigneeId) initial.assigneeId = assigneeId
|
||||
const categoryId = getParamValue(params.category)
|
||||
if (categoryId) initial.categoryId = categoryId
|
||||
const dateFrom = getParamValue(params.from)
|
||||
if (dateFrom) initial.dateFrom = dateFrom
|
||||
const dateTo = getParamValue(params.to)
|
||||
if (dateTo) initial.dateTo = dateTo
|
||||
const from = getParamValue(params.from ?? params.dateFrom)
|
||||
if (isValidDateParam(from)) initial.dateFrom = from
|
||||
const to = getParamValue(params.to ?? params.dateTo)
|
||||
if (isValidDateParam(to)) initial.dateTo = to
|
||||
const sort = getParamValue(params.sort)
|
||||
if (sort === "recent" || sort === "oldest") {
|
||||
initial.sort = sort as TicketFiltersState["sort"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue