Skip to content

Commit e7ade06

Browse files
Merge pull request #37 from carlosthe19916/fix/certificate-unique-id-definition
fix: include index on certificate unique identifier
2 parents 7acc038 + dd77420 commit e7ade06

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

client/src/app/hooks/query-utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ export const useWithUiId = <T>(
1616
/** Source data to modify. */
1717
data: T[] | undefined,
1818
/** Generate the unique id for a specific `T`. */
19-
generator: (item: T) => string
19+
generator: (item: T, index: number) => string
2020
): WithUiId<T>[] => {
2121
const result = useMemo(() => {
2222
if (!data || data.length === 0) {
2323
return [];
2424
}
2525

26-
const dataWithUiId: WithUiId<T>[] = data.map((item) => ({
26+
const dataWithUiId: WithUiId<T>[] = data.map((item, index) => ({
2727
...item,
28-
[UI_UNIQUE_ID]: generator(item),
28+
[UI_UNIQUE_ID]: generator(item, index),
2929
}));
3030

3131
return dataWithUiId;

client/src/app/pages/TrustRoot/components/Certificates.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ interface ICertificatesTableProps {
3535
}
3636

3737
export const CertificatesTable: React.FC<ICertificatesTableProps> = ({ certificates, isFetching, fetchError }) => {
38-
const items = useWithUiId(certificates, (item) => `${item.type}-${item.issuer}-${item.subject}-${item.target}`);
38+
const items = useWithUiId(
39+
certificates,
40+
(item, index) => `${index}-${item.type}-${item.issuer}-${item.subject}-${item.target}`
41+
);
3942

4043
const tableState = usePFToolbarTable({
4144
items,

0 commit comments

Comments
 (0)