DSingh0304 commented on code in PR #3222:
URL: https://github.com/apache/apisix-dashboard/pull/3222#discussion_r2453855081
##########
src/routes/routes/index.tsx:
##########
@@ -42,12 +48,57 @@ export type RouteListProps = {
export const RouteList = (props: RouteListProps) => {
const { routeKey, ToDetailBtn, defaultParams } = props;
- const { data, isLoading, refetch, pagination } = useRouteList(
+ const { data, isLoading, refetch, pagination, setParams } = useRouteList(
routeKey,
defaultParams
);
+ const { params } = useSearchParams(routeKey);
const { t } = useTranslation();
+ const handleSearch = (values: SearchFormValues) => {
+ // Send name filter to backend, keep others for client-side filtering
+ setParams({
+ page: 1,
+ name: values.name,
+ id: values.id,
+ host: values.host,
+ path: values.path,
+ description: values.description,
+ plugin: values.plugin,
+ labels: values.labels,
+ version: values.version,
+ status: values.status,
+ });
+ };
+
+ const handleReset = () => {
+ setParams({
+ page: 1,
+ name: undefined,
+ id: undefined,
+ host: undefined,
+ path: undefined,
+ description: undefined,
+ plugin: undefined,
+ labels: undefined,
+ version: undefined,
+ status: undefined,
+ });
+ };
Review Comment:
Good call! I pulled the shared search keys into a
[SEARCH_PARAM_KEYS](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html)
array plus a
[mapSearchParams](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html)
helper, so both
[handleSearch](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html)
and
[handleReset](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html)
just spread that result now. That trims the duplication and keeps the intent
clearer.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]