This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73bde3e
commit 1e28054
Showing
8 changed files
with
168 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
apps/customer-service/src/components/tickets/ticket-list-container.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
'use client'; | ||
|
||
import { Suspense } from 'react'; | ||
import { useSearchParams } from 'next/navigation'; | ||
|
||
import { TicketStatus } from '@cs/database/schema/ticket'; | ||
|
||
import { TicketList } from '~/components/tickets/ticket-list'; | ||
import { TicketListHeader } from '~/components/tickets/ticket-list-header'; | ||
import { TicketListItemSkeleton } from '~/components/tickets/ticket-list-item-skeleton'; | ||
import { | ||
FILTER_QUERY_PARAM, | ||
ORDER_BY_QUERY_PARAM, | ||
STATUS_QUERY_PARAM, | ||
} from '~/utils/search-params'; | ||
|
||
export const TicketListContainer = () => { | ||
const searchParams = useSearchParams(); | ||
const filter = | ||
searchParams.get(FILTER_QUERY_PARAM) === 'me' | ||
? 'me' | ||
: searchParams.get(FILTER_QUERY_PARAM) === 'unassigned' | ||
? 'unassigned' | ||
: 'all'; | ||
const status = | ||
searchParams.get(STATUS_QUERY_PARAM) === 'resolved' | ||
? TicketStatus.Resolved | ||
: TicketStatus.Open; | ||
const orderBy = | ||
searchParams.get(ORDER_BY_QUERY_PARAM) === 'oldest' ? 'oldest' : 'newest'; | ||
return ( | ||
<aside className="fixed inset-y-0 left-60 hidden w-96 flex-col border-r xl:flex"> | ||
<TicketListHeader status={status} orderBy={orderBy} /> | ||
<Suspense | ||
fallback={ | ||
<div className="flex w-full flex-col gap-4"> | ||
<TicketListItemSkeleton /> | ||
<TicketListItemSkeleton /> | ||
<TicketListItemSkeleton /> | ||
</div> | ||
} | ||
> | ||
<TicketList filter={filter} status={status} orderBy={orderBy} /> | ||
</Suspense> | ||
</aside> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ReadonlyURLSearchParams } from 'next/navigation'; | ||
|
||
export const FILTER_QUERY_PARAM = 'filter'; | ||
export const STATUS_QUERY_PARAM = 'status'; | ||
export const ORDER_BY_QUERY_PARAM = 'orderBy'; | ||
|
||
export const getUpdatedSearchParams = ( | ||
searchParams: ReadonlyURLSearchParams, | ||
key: string, | ||
value: string | ||
) => { | ||
const updatedSeachParams = new URLSearchParams( | ||
Array.from(searchParams.entries()) | ||
); | ||
|
||
if (updatedSeachParams.get(key) !== value) { | ||
updatedSeachParams.set(key, value); | ||
} | ||
|
||
return updatedSeachParams; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters