Skip to content

Commit ff02d38

Browse files
committed
Consolidate Errata type definition
1 parent 7666e2c commit ff02d38

File tree

4 files changed

+14
-23
lines changed

4 files changed

+14
-23
lines changed

src/app/helpers/errata.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@ import {useState, useEffect} from 'react';
22
import bookPromise, {Item} from '~/models/book-titles';
33

44
export type Errata = {
5-
id: number;
5+
id: string;
66
status: string;
77
resolution: string;
88
reviewedDate: string | null;
99
correctedDate: string | null;
1010
created: string;
11+
modified: string;
1112
book: Item['id'];
1213
location?: string;
1314
additionalLocationInformation?: string;
1415
resource: string;
1516
resourceOther: string;
16-
errorType: unknown;
17-
detail: unknown;
17+
errorType: string;
18+
errorTypeOther?: string;
19+
detail: string;
1820
resolutionNotes: string;
1921
};
2022

src/app/pages/errata-summary/errata-summary.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import React, {useState} from 'react';
22
import Hero from './hero/hero';
33
import {RadioPanel} from '~/components/radio-panel/radio-panel';
4-
import Table, {RawErrataItem} from './table/table';
4+
import Table from './table/table';
55
import LoaderPage from '~/components/jsx-helpers/loader-page';
6+
import type {Errata} from '~/helpers/errata';
67
import './errata-summary.scss';
78

89
type ErrataSummaryProps = {
9-
data: RawErrataItem[];
10+
data: Errata[];
1011
book: string;
1112
};
1213

src/app/pages/errata-summary/table/table.tsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,6 @@ import {treatSpaceOrEnterAsClick} from '~/helpers/events';
33
import {getDisplayStatus, Errata} from '~/helpers/errata';
44
import './table.scss';
55

6-
export type RawErrataItem = Errata & {
7-
id: string;
8-
created: string;
9-
resource: string;
10-
resourceOther?: string;
11-
errorType: string;
12-
errorTypeOther?: string;
13-
location: string;
14-
additionalLocationInformation?: string;
15-
detail: string;
16-
modified: string;
17-
};
18-
196
type ProcessedErrataItem = {
207
date: string;
218
source: string;
@@ -67,7 +54,7 @@ type MobileTablesProps = {
6754
};
6855

6956
type TableProps = {
70-
data: RawErrataItem[];
57+
data: Errata[];
7158
filter: string;
7259
};
7360

@@ -327,7 +314,7 @@ function matchesFilter(filter: string, item: ProcessedErrataItem): boolean {
327314
export default function Table({data, filter}: TableProps): React.ReactElement {
328315
const details: ProcessedErrataItem[] = React.useMemo(
329316
() => data.map(
330-
(item: RawErrataItem): ProcessedErrataItem => {
317+
(item: Errata): ProcessedErrataItem => {
331318
const displayStatus = getDisplayStatus(item);
332319

333320
return {

test/src/helpers/errata.test.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import {render, screen} from '@testing-library/preact';
33
import {
44
approvedStatuses,
55
getDisplayStatus,
6-
useErrataDetail
6+
useErrataDetail,
7+
Errata
78
} from '~/helpers/errata';
89

910
describe('errata helpers', () => {
@@ -38,7 +39,7 @@ describe('errata helpers', () => {
3839
describe('useErrataDetail', () => {
3940
function Component() {
4041
const detail = useErrataDetail({
41-
id: 1,
42+
id: '1',
4243
resource: 'Other',
4344
reviewedDate: '2025-02-06',
4445
correctedDate: null,
@@ -50,7 +51,7 @@ describe('errata helpers', () => {
5051
created: '2000-01-01',
5152
detail: '',
5253
errorType: ''
53-
});
54+
} as unknown as Errata);
5455

5556
return (
5657
<div>

0 commit comments

Comments
 (0)