Adding dropdown in ExpenseFilter.

This commit is contained in:
Kartik Sharma 2025-10-04 14:12:20 +05:30
parent 87d13d0f77
commit 4a05e67ff0
3 changed files with 17 additions and 9 deletions

View File

@ -46,6 +46,7 @@ const ExpenseFilterPanel = ({ onApply, handleGroupBy }) => {
projectIds: project ? [project] : defaultFilter.projectIds || [], projectIds: project ? [project] : defaultFilter.projectIds || [],
createdByIds: defaultFilter.createdByIds || [], createdByIds: defaultFilter.createdByIds || [],
paidById: defaultFilter.paidById || [], paidById: defaultFilter.paidById || [],
ExpenseTypeIds: defaultFilter.ExpenseTypeIds || [],
isTransactionDate: defaultFilter.isTransactionDate ?? true, isTransactionDate: defaultFilter.isTransactionDate ?? true,
startDate: defaultFilter.startDate, startDate: defaultFilter.startDate,
endDate: defaultFilter.endDate, endDate: defaultFilter.endDate,
@ -143,8 +144,7 @@ const ExpenseFilterPanel = ({ onApply, handleGroupBy }) => {
<div className="d-inline-flex border rounded-pill mb-1 overflow-hidden shadow-none"> <div className="d-inline-flex border rounded-pill mb-1 overflow-hidden shadow-none">
<button <button
type="button" type="button"
className={`btn px-2 py-1 rounded-0 text-tiny ${ className={`btn px-2 py-1 rounded-0 text-tiny ${isTransactionDate ? "active btn-primary text-white" : ""
isTransactionDate ? "active btn-primary text-white" : ""
}`} }`}
onClick={() => setValue("isTransactionDate", true)} onClick={() => setValue("isTransactionDate", true)}
> >
@ -152,8 +152,7 @@ const ExpenseFilterPanel = ({ onApply, handleGroupBy }) => {
</button> </button>
<button <button
type="button" type="button"
className={`btn px-2 py-1 rounded-0 text-tiny ${ className={`btn px-2 py-1 rounded-0 text-tiny ${!isTransactionDate ? "active btn-primary text-white" : ""
!isTransactionDate ? "active btn-primary text-white" : ""
}`} }`}
onClick={() => setValue("isTransactionDate", false)} onClick={() => setValue("isTransactionDate", false)}
> >
@ -194,6 +193,13 @@ const ExpenseFilterPanel = ({ onApply, handleGroupBy }) => {
labelKey={(item) => item.name} labelKey={(item) => item.name}
valueKey="id" valueKey="id"
/> />
<SelectMultiple
name="ExpenseTypeIds"
label="Category :"
options={data.expensesType}
labelKey={(item) => item.name}
valueKey="id"
/>
<div className="mb-3"> <div className="mb-3">
<label className="form-label">Status :</label> <label className="form-label">Status :</label>

View File

@ -159,6 +159,7 @@ export const SearchSchema = z.object({
statusIds: z.array(z.string()).optional(), statusIds: z.array(z.string()).optional(),
createdByIds: z.array(z.string()).optional(), createdByIds: z.array(z.string()).optional(),
paidById: z.array(z.string()).optional(), paidById: z.array(z.string()).optional(),
ExpenseTypeIds: z.array(z.string()).optional(),
startDate: z.string().optional(), startDate: z.string().optional(),
endDate: z.string().optional(), endDate: z.string().optional(),
isTransactionDate: z.boolean().default(true), isTransactionDate: z.boolean().default(true),
@ -169,6 +170,7 @@ export const defaultFilter = {
statusIds: [], statusIds: [],
createdByIds: [], createdByIds: [],
paidById: [], paidById: [],
ExpenseTypeIds: [],
isTransactionDate: true, isTransactionDate: true,
startDate: null, startDate: null,
endDate: null, endDate: null,

View File

@ -10,7 +10,7 @@ import moment from "moment";
const cleanFilter = (filter) => { const cleanFilter = (filter) => {
const cleaned = { ...filter }; const cleaned = { ...filter };
["projectIds", "statusIds", "createdByIds", "paidById"].forEach((key) => { ["projectIds", "statusIds", "createdByIds", "paidById","ExpenseTypeIds"].forEach((key) => {
if (Array.isArray(cleaned[key]) && cleaned[key].length === 0) { if (Array.isArray(cleaned[key]) && cleaned[key].length === 0) {
delete cleaned[key]; delete cleaned[key];
} }