Skip to content

Commit 0365a83

Browse files
committed
Add useId to react-select components and remove unused fetch function
- Add instanceId via useId() to all FormikSelect components to prevent SSR hydration mismatches - Remove unused getAllScanReportFieldsV3 from scanreports.ts
1 parent 39dca7f commit 0365a83

6 files changed

Lines changed: 12 additions & 23 deletions

File tree

app/api/api/views.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -884,11 +884,6 @@ def get_queryset(self):
884884
)
885885
)
886886

887-
def list(self, request, *args, **kwargs):
888-
return super().list(request, *args, **kwargs)
889-
890-
891-
892887
class ScanReportValueListV2(ScanReportPermissionMixin, GenericAPIView, ListModelMixin):
893888
"""
894889
A view for listing ScanReportValue objects associated with a

app/next-client-app/api/scanreports.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -319,21 +319,6 @@ export async function getScanReportValuesV3(
319319
}
320320
}
321321

322-
export async function getAllScanReportFieldsV3(
323-
scanReportId: string,
324-
tableId: string,
325-
filter: string | undefined,
326-
): Promise<ScanReportFieldV3[]> {
327-
try {
328-
return await fetchAllPages<ScanReportFieldV3>(
329-
fetchKeys.fieldsV3(scanReportId, tableId, filter),
330-
);
331-
} catch (error) {
332-
console.warn("Failed to fetch data.");
333-
return [];
334-
}
335-
}
336-
337322
export async function getScanReportFieldsV3(
338323
scanReportId: string,
339324
tableId: string,

app/next-client-app/components/form-components/FormikSelect.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Field, FieldInputProps, FieldProps, FormikProps } from "formik";
2+
import { useId } from "react";
23
import Select from "react-select";
34
import makeAnimated from "react-select/animated";
45
import config from "@/tailwind.config";
@@ -26,6 +27,7 @@ const CustomSelect = ({
2627
isDisabled: boolean;
2728
required?: boolean;
2829
}) => {
30+
const instanceId = useId();
2931
const animatedComponents = makeAnimated();
3032

3133
// Optional: detect dark mode for better contrast
@@ -53,6 +55,7 @@ const CustomSelect = ({
5355

5456
return (
5557
<Select
58+
instanceId={instanceId}
5659
name={field.name}
5760
value={selected()}
5861
onChange={onChange}

app/next-client-app/components/form-components/FormikSelectDataset.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
import Select from "react-select";
1010
import makeAnimated from "react-select/animated";
1111
import { getDatasetList } from "@/api/datasets";
12-
import { useEffect, useState } from "react";
12+
import { useEffect, useId, useState } from "react";
1313
import { getAllProjects } from "@/api/projects";
1414

1515
type Option = {
@@ -80,6 +80,7 @@ const CustomSelect = ({
8080
isDisabled: boolean;
8181
required?: boolean;
8282
}) => {
83+
const instanceId = useId();
8384
const animatedComponents = makeAnimated();
8485
const onChange = (newValue: any, actionMeta: any) => {
8586
const selectedValues = isMulti
@@ -102,6 +103,7 @@ const CustomSelect = ({
102103

103104
return (
104105
<Select
106+
instanceId={instanceId}
105107
name={field.name}
106108
value={selected()}
107109
onChange={onChange}

app/next-client-app/components/form-components/FormikSelectEditors.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Select from "react-select";
1010
import makeAnimated from "react-select/animated";
1111
import config from "@/tailwind.config";
1212
import { getDataUsers } from "@/api/datasets";
13-
import { useEffect, useState } from "react";
13+
import { useEffect, useId, useState } from "react";
1414
import { FindAndFormat } from "./FormikUtils";
1515
import { getProjectsDataset } from "@/api/projects";
1616

@@ -47,6 +47,7 @@ const CustomSelect = ({
4747
form: FormikProps<any>;
4848
isDisabled: boolean;
4949
}) => {
50+
const instanceId = useId();
5051
const animatedComponents = makeAnimated();
5152
const onChange = (newValue: any, actionMeta: any) => {
5253
const selectedValues = isMulti
@@ -68,6 +69,7 @@ const CustomSelect = ({
6869

6970
return (
7071
<Select
72+
instanceId={instanceId}
7173
name={field.name}
7274
value={selected()}
7375
onChange={onChange}

app/next-client-app/components/form-components/FormikSelectUsers.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
import Select from "react-select";
1010
import makeAnimated from "react-select/animated";
1111
import { getDataUsers } from "@/api/datasets";
12-
import { useEffect, useState } from "react";
12+
import { useEffect, useId, useState } from "react";
1313
import { FindAndFormat } from "./FormikUtils";
1414
import { getAllProjects } from "@/api/projects";
1515

@@ -49,6 +49,7 @@ const CustomSelect = ({
4949
form: FormikProps<any>;
5050
isDisabled: boolean;
5151
}) => {
52+
const instanceId = useId();
5253
const animatedComponents = makeAnimated();
5354
const onChange = (newValue: any, actionMeta: any) => {
5455
const selectedValues = isMulti
@@ -70,6 +71,7 @@ const CustomSelect = ({
7071

7172
return (
7273
<Select
74+
instanceId={instanceId}
7375
name={field.name}
7476
value={selected()}
7577
onChange={onChange}

0 commit comments

Comments
 (0)