change notification sorting by creation date

This commit is contained in:
Raja Oktafrianto
2025-04-21 09:53:09 +07:00
parent b93dfd1bfd
commit 814bf9f04f
2 changed files with 5 additions and 3 deletions

View File

@ -262,7 +262,9 @@ const AddDialog = () => {
<div className="w-full"> <div className="w-full">
<div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5"> <div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label className="form-label flex items-center gap-1 max-w-56">Type</label> <label className="form-label flex items-center gap-1 max-w-56">
Type<span className="text-red-500">*</span>
</label>
<div className="flex gap-6 items-center"> <div className="flex gap-6 items-center">
{['info', 'promo'].map((type) => ( {['info', 'promo'].map((type) => (
<label key={type} className="flex items-center space-x-2"> <label key={type} className="flex items-center space-x-2">

View File

@ -107,7 +107,7 @@ const ManageNotifContextProvider = ({ children }: { children: React.ReactNode })
const getNotificationList = async (page: number, limit: number, sorting: any, filter: any) => { const getNotificationList = async (page: number, limit: number, sorting: any, filter: any) => {
try { try {
sorting = sorting.length == 0 ? [{ id: 'content', desc: false }] : sorting; sorting = sorting.length === 0 ? [{ id: 'created_at', desc: true }] : sorting;
filter = filter =
filter.length == 0 ? {} : { content: { like: `%${filter[0].value?.toLowerCase()}%` } }; filter.length == 0 ? {} : { content: { like: `%${filter[0].value?.toLowerCase()}%` } };
const response = await GetData(`${API_URL_NOTIFICATION}/list`, { const response = await GetData(`${API_URL_NOTIFICATION}/list`, {
@ -145,7 +145,7 @@ const ManageNotifContextProvider = ({ children }: { children: React.ReactNode })
pagination={{ size: 10 }} pagination={{ size: 10 }}
toolbar={<ListToolBar />} toolbar={<ListToolBar />}
layout={{ card: true }} layout={{ card: true }}
sorting={[{ id: 'content', desc: false }]} sorting={[{ id: 'created_at', desc: true }]}
serverSide={true} serverSide={true}
onFetchData={({ pageIndex, pageSize, sorting, columnFilters }) => onFetchData={({ pageIndex, pageSize, sorting, columnFilters }) =>
getNotificationList(pageIndex, pageSize, sorting, columnFilters) getNotificationList(pageIndex, pageSize, sorting, columnFilters)