Skip to content

Commit b40f25d

Browse files
committed
refactor(admin): drop Index and Valeur filters on /admin/declarations (#3274)
1 parent 97d644f commit b40f25d

6 files changed

Lines changed: 6 additions & 76 deletions

File tree

packages/app/src/modules/admin/declarations/AdminDeclarationsPage.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ function DeclarationsContent() {
2222
dateFrom: searchParams.get("dateFrom") ?? undefined,
2323
dateTo: searchParams.get("dateTo") ?? undefined,
2424
status: (searchParams.get("status") as "draft" | "submitted") || undefined,
25-
index: searchParams.get("index")
26-
? Number(searchParams.get("index"))
27-
: undefined,
28-
indexOperator:
29-
(searchParams.get("indexOperator") as "gt" | "lt" | "eq") || undefined,
3025
page: Number(searchParams.get("page") ?? "1"),
3126
pageSize: Number(searchParams.get("pageSize") ?? String(DEFAULT_PAGE_SIZE)),
3227
sortBy: (searchParams.get("sortBy") as SortColumn) ?? "createdAt",

packages/app/src/modules/admin/declarations/SearchForm.tsx

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ export function SearchForm() {
2323
dateTo: searchParams.get("dateTo") ?? "",
2424
status:
2525
(searchParams.get("status") as "" | "draft" | "submitted") ?? "",
26-
index: searchParams.get("index") ?? "",
27-
indexOperator:
28-
(searchParams.get("indexOperator") as "" | "gt" | "lt" | "eq") ?? "",
2926
},
3027
},
3128
);
@@ -52,8 +49,6 @@ export function SearchForm() {
5249
dateFrom: "",
5350
dateTo: "",
5451
status: "",
55-
index: "",
56-
indexOperator: "",
5752
});
5853
router.push("/admin/declarations");
5954
}, [reset, router]);
@@ -144,42 +139,6 @@ export function SearchForm() {
144139
</select>
145140
</div>
146141
</div>
147-
<div className="fr-col-12 fr-col-md-3">
148-
<div className="fr-grid-row fr-grid-row--gutters">
149-
<div className="fr-col-6">
150-
<div className="fr-select-group">
151-
<label className="fr-label" htmlFor="search-index-op">
152-
Index
153-
</label>
154-
<select
155-
className="fr-select"
156-
id="search-index-op"
157-
{...register("indexOperator")}
158-
>
159-
<option value=""></option>
160-
<option value="eq">=</option>
161-
<option value="gt">&ge;</option>
162-
<option value="lt">&le;</option>
163-
</select>
164-
</div>
165-
</div>
166-
<div className="fr-col-6">
167-
<div className="fr-input-group">
168-
<label className="fr-label" htmlFor="search-index">
169-
Valeur
170-
</label>
171-
<input
172-
className="fr-input"
173-
id="search-index"
174-
max={100}
175-
min={0}
176-
type="number"
177-
{...register("index")}
178-
/>
179-
</div>
180-
</div>
181-
</div>
182-
</div>
183142
</div>
184143
<div className="fr-grid-row fr-grid-row--right fr-mt-2w">
185144
<ul className="fr-btns-group fr-btns-group--inline">

packages/app/src/modules/admin/declarations/__tests__/SearchForm.test.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ describe("SearchForm", () => {
2929
expect(screen.getByLabelText("Date de dépôt (du)")).toBeInTheDocument();
3030
expect(screen.getByLabelText("Date de dépôt (au)")).toBeInTheDocument();
3131
expect(screen.getByLabelText("Statut")).toBeInTheDocument();
32-
expect(screen.getByLabelText("Index")).toBeInTheDocument();
33-
expect(screen.getByLabelText("Valeur")).toBeInTheDocument();
32+
});
33+
34+
it("does not render removed Index / Valeur filters", () => {
35+
render(<SearchForm />);
36+
expect(screen.queryByLabelText("Index")).not.toBeInTheDocument();
37+
expect(screen.queryByLabelText("Valeur")).not.toBeInTheDocument();
3438
});
3539

3640
it("renders search and reset buttons", () => {

packages/app/src/modules/admin/declarations/__tests__/schemas.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ describe("searchDeclarationsSchema", () => {
2020
year: "2024",
2121
dateFrom: "2024-01-01",
2222
dateTo: "2024-12-31",
23-
index: "75",
24-
indexOperator: "gt",
2523
status: "submitted",
2624
page: "2",
2725
pageSize: "50",
@@ -35,8 +33,6 @@ describe("searchDeclarationsSchema", () => {
3533
year: 2024,
3634
dateFrom: "2024-01-01",
3735
dateTo: "2024-12-31",
38-
index: 75,
39-
indexOperator: "gt",
4036
status: "submitted",
4137
page: 2,
4238
pageSize: 50,

packages/app/src/modules/admin/declarations/schemas.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ export const SORT_COLUMNS = [
1111

1212
export type SortColumn = (typeof SORT_COLUMNS)[number];
1313

14-
export const INDEX_OPERATORS = ["gt", "lt", "eq"] as const;
15-
16-
export type IndexOperator = (typeof INDEX_OPERATORS)[number];
17-
1814
export const DEFAULT_PAGE_SIZE = 20;
1915

2016
export const searchDeclarationsSchema = z.object({
@@ -23,8 +19,6 @@ export const searchDeclarationsSchema = z.object({
2319
year: z.coerce.number().int().min(2018).max(2100).optional(),
2420
dateFrom: z.string().date().optional().or(z.literal("")),
2521
dateTo: z.string().date().optional().or(z.literal("")),
26-
index: z.coerce.number().int().min(0).max(100).optional(),
27-
indexOperator: z.enum(INDEX_OPERATORS).optional(),
2822
status: z.enum(["draft", "submitted"]).optional(),
2923
page: z.coerce.number().int().min(1).default(1),
3024
pageSize: z.coerce.number().int().min(10).max(100).default(DEFAULT_PAGE_SIZE),
@@ -43,8 +37,6 @@ export const searchDeclarationsFormSchema = z.object({
4337
year: z.string().optional(),
4438
dateFrom: z.string().optional(),
4539
dateTo: z.string().optional(),
46-
index: z.string().optional(),
47-
indexOperator: z.enum(["", ...INDEX_OPERATORS]).optional(),
4840
status: z.enum(["", "draft", "submitted"]).optional(),
4941
});
5042

packages/app/src/server/api/routers/adminDeclarations.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
gte,
88
ilike,
99
lt,
10-
lte,
1110
or,
1211
type SQL,
1312
} from "drizzle-orm";
@@ -75,21 +74,6 @@ export const adminDeclarationsRouter = createTRPCRouter({
7574
filters.push(eq(declarations.status, input.status));
7675
}
7776

78-
if (input.index !== undefined && input.indexOperator) {
79-
const indexScore = declarations.remunerationScore;
80-
switch (input.indexOperator) {
81-
case "gt":
82-
filters.push(gte(indexScore, input.index));
83-
break;
84-
case "lt":
85-
filters.push(lte(indexScore, input.index));
86-
break;
87-
case "eq":
88-
filters.push(eq(indexScore, input.index));
89-
break;
90-
}
91-
}
92-
9377
const where = filters.length > 0 ? and(...filters) : undefined;
9478
const orderDir = input.sortOrder === "asc" ? asc : desc;
9579
const orderColumn = sortColumnMap[input.sortBy];

0 commit comments

Comments
 (0)