Skip to content
This repository was archived by the owner on May 4, 2019. It is now read-only.

Commit 8cea5bc

Browse files
committed
feat(item bank): add logic to display error message from api
1 parent 1b4a7c6 commit 8cea5bc

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

mocks/ItemBank/mocks.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ export const mockBankItemExistsClient = (items: ItemExistsRequestModel[]) => {
1818
const result: ItemExistsResponseModel[] = [];
1919
items.forEach((item, index) => {
2020
if (index % 2 === 0) {
21-
result.push({ ...item, exists: false });
21+
result.push({
22+
...item,
23+
exists: false,
24+
error: "Its Raining cats and Dogs"
25+
});
26+
} else {
27+
result.push({ ...item, exists: true });
2228
}
2329
});
2430

src/ItemBank/ItemBankModels.ts

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface ItemRevisionModel {
1313
revision?: string;
1414
isaap?: string;
1515
valid?: boolean;
16+
error?: string;
1617
}
1718

1819
export interface ItemExistsRequestModel {
@@ -23,6 +24,7 @@ export interface ItemExistsRequestModel {
2324

2425
export interface ItemExistsResponseModel extends ItemExistsRequestModel {
2526
exists: boolean;
27+
error?: string;
2628
}
2729

2830
export function itemsAreEqual(
@@ -79,6 +81,7 @@ export function existenceResponseModelToRevisionModel(
7981
);
8082
if (match) {
8183
item.valid = match.exists;
84+
item.error = match.error;
8285
}
8386

8487
return item;

src/ItemEntryTable/ItemEntryRow.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ export class ItemEntryRow extends React.Component<
188188
const hidden =
189189
this.props.row.valid !== undefined &&
190190
!this.props.row.valid &&
191-
this.props.row.itemKey
191+
this.props.row.itemKey &&
192+
this.props.row.error
192193
? ""
193194
: "hidden";
194195

@@ -206,7 +207,7 @@ export class ItemEntryRow extends React.Component<
206207
editRow.itemKey
207208
)}
208209
{this.renderDeleteButton()}
209-
<td className={`error-text ${hidden}`}>Item Not Found</td>
210+
<td className={`error-text ${hidden}`}>{this.props.row.error}</td>
210211
</tr>
211212
);
212213
}

0 commit comments

Comments
 (0)