From 68833e3b839c51789c9525d36b0aed2c939cb87f Mon Sep 17 00:00:00 2001 From: alebinson Date: Thu, 26 Feb 2026 14:31:36 +0200 Subject: [PATCH 1/3] fix: remarks field and error handling --- src/common/services/ExtractableService.ts | 4 +++ src/common/services/HistoryService.ts | 1 + .../MetadataConfirm/MetadataConfirm.tsx | 5 ++-- .../Wizard/MetadataForm/MetadataForm.tsx | 16 ++++++------ .../MetadataHistory/MetadataHistory.css | 1 - .../MetadataHistory/MetadataHistory.tsx | 25 +++++++++++++------ src/i18n/locales/en.json | 13 ++++++---- src/i18n/locales/he.json | 13 ++++++---- src/utils/requestHandler.ts | 8 +++++- src/utils/snackbarError.tsx | 4 +-- 10 files changed, 59 insertions(+), 31 deletions(-) diff --git a/src/common/services/ExtractableService.ts b/src/common/services/ExtractableService.ts index eaa0059..8a8df5f 100644 --- a/src/common/services/ExtractableService.ts +++ b/src/common/services/ExtractableService.ts @@ -16,6 +16,7 @@ export const extractableCreateAPI = async ( username: string, password: string, authorizedBy: string, + remarks: string, data: Record, setLoading: loadingUpdater ): Promise => { @@ -29,6 +30,7 @@ export const extractableCreateAPI = async ( username, password, authorizedBy, + remarks, data } } @@ -47,6 +49,7 @@ export const extractableDeleteAPI = async ( username: string, password: string, authorizedBy: string, + remarks: string, data: Record, setLoading: loadingUpdater ): Promise => { @@ -60,6 +63,7 @@ export const extractableDeleteAPI = async ( username, password, authorizedBy, + remarks, data } } diff --git a/src/common/services/HistoryService.ts b/src/common/services/HistoryService.ts index 6c0dd57..d7e4080 100644 --- a/src/common/services/HistoryService.ts +++ b/src/common/services/HistoryService.ts @@ -9,6 +9,7 @@ export interface HistoryRecord { authorizedBy: string; action: string; authorizedAt: string; + remarks: string; } export const historyAPI = async ( diff --git a/src/components/Wizard/MetadataConfirm/MetadataConfirm.tsx b/src/components/Wizard/MetadataConfirm/MetadataConfirm.tsx index 5c5256b..e45fd32 100644 --- a/src/components/Wizard/MetadataConfirm/MetadataConfirm.tsx +++ b/src/components/Wizard/MetadataConfirm/MetadataConfirm.tsx @@ -48,7 +48,8 @@ export const MetadataConfirm: React.FC = ({ user.username, formData.password, selectedItem.approver as string, - { additionalInfo: selectedItem.additionalInfo }, + selectedItem.remarks as string, + {}, setIsLoading ); if (response && isMounted) { @@ -106,7 +107,7 @@ export const MetadataConfirm: React.FC = ({ { [ intl.formatMessage({ id: 'form.message.confirm.approver' }, { value: selectedItem?.approver as string }), - intl.formatMessage({ id: 'form.message.confirm.additionalInfo' }, { value: selectedItem?.additionalInfo as string }) + intl.formatMessage({ id: 'form.message.confirm.remarks' }, { value: selectedItem?.remarks as string }) ].map((line, index) => ( {line} diff --git a/src/components/Wizard/MetadataForm/MetadataForm.tsx b/src/components/Wizard/MetadataForm/MetadataForm.tsx index 8d4fb73..71ea904 100644 --- a/src/components/Wizard/MetadataForm/MetadataForm.tsx +++ b/src/components/Wizard/MetadataForm/MetadataForm.tsx @@ -10,9 +10,9 @@ import './MetadataForm.css'; export const MetadataForm: React.FC = ({ setIsNextBtnDisabled, selectedItem, setSelectedItem }) => { const intl = useIntl(); - const [formData, setFormData] = useState<{ approver: string; additionalInfo: string }>({ + const [formData, setFormData] = useState<{ approver: string; remarks: string }>({ approver: typeof selectedItem?.approver === 'string' ? selectedItem.approver : '', - additionalInfo: typeof selectedItem?.additionalInfo === 'string' ? selectedItem.additionalInfo : '' + remarks: typeof selectedItem?.remarks === 'string' ? selectedItem.remarks : '' }); useEffect(() => { @@ -69,17 +69,17 @@ export const MetadataForm: React.FC = ({ setIsNextBtnDisabled, /> - diff --git a/src/components/Wizard/MetadataHistory/MetadataHistory.css b/src/components/Wizard/MetadataHistory/MetadataHistory.css index 36ddca2..a1db2ee 100644 --- a/src/components/Wizard/MetadataHistory/MetadataHistory.css +++ b/src/components/Wizard/MetadataHistory/MetadataHistory.css @@ -49,7 +49,6 @@ } .historyContainer .cardContent { - font-size: var(--mdc-theme-gc-title-font-size); margin: 6px 0; } diff --git a/src/components/Wizard/MetadataHistory/MetadataHistory.tsx b/src/components/Wizard/MetadataHistory/MetadataHistory.tsx index 264621e..acce4f1 100644 --- a/src/components/Wizard/MetadataHistory/MetadataHistory.tsx +++ b/src/components/Wizard/MetadataHistory/MetadataHistory.tsx @@ -54,19 +54,30 @@ export const MetadataHistory: React.FC = ({ setIsNextBtnDisable historyItems.map((item, index) => ( - + {formatDate(item.authorizedAt, locale, true)} - - + + + + + + + + {item.username} - + - + diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index 59d792b..e391a97 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -2,6 +2,7 @@ "app.title": "Coordinate Extract Approval", "err.code.INVALID_CREDENTIALS": "Invalid username or password", + "err.code.INVALID_RECORD_NAME": "Model not found", "auth.login.btn": "Login", "auth.logout.btn": "Logout", @@ -87,8 +88,10 @@ "details.field.productSource": "Product Source", "details.field.productStatus": "Product Status", - "history.action.create": " · Approved · by {value}", - "history.action.delete": " · Rejected · by {value}", + "history.action.create": " Approved ", + "history.action.delete": " Rejected ", + "history.action.authorizedBy": " by {value} ", + "history.action.remarks": "Comments: {value}", "form.message.approve": "Approval of the model will expose it to operational factors for coordinates extraction", "form.message.reject": "Rejecting the approval will remove the model from exposure to operational factors", @@ -96,13 +99,13 @@ "form.message.confirm.model": "Model: {value}", "form.message.confirm.action": "Action: {value}", "form.message.confirm.approver": "Approver: {value}", - "form.message.confirm.additionalInfo": "Comments: {value}", + "form.message.confirm.remarks": "Comments: {value}", "form.message.confirm.approve": "Approve for coordinates extraction", "form.message.confirm.reject": "Reject approval", "form.approver.label": "Approver full name *", "form.approver.placeholder": "Enter your full name", - "form.additionalInfo.label": "Comments (optional)", - "form.additionalInfo.placeholder": "Add comments here...", + "form.remarks.label": "Comments (optional)", + "form.remarks.placeholder": "Add comments here...", "form.password.label": "Password *", "form.password.placeholder": "Re-enter password for confirmation to proceed with the action" } diff --git a/src/i18n/locales/he.json b/src/i18n/locales/he.json index 2219e4c..5be52c8 100644 --- a/src/i18n/locales/he.json +++ b/src/i18n/locales/he.json @@ -2,6 +2,7 @@ "app.title": "אישור מודל לחילוץ נ.צ.", "err.code.INVALID_CREDENTIALS": "שם משתמש או סיסמה לא חוקיים", + "err.code.INVALID_RECORD_NAME": "מודל לא קיים", "auth.login.btn": "התחבר", "auth.logout.btn": "התנתק", @@ -90,8 +91,10 @@ "details.field.productSource": "מקור", "details.field.productStatus": "סטטוס", - "history.action.create": " · אושר · על-ידי {value}", - "history.action.delete": " · הוסר · על-ידי {value}", + "history.action.create": " אושר ", + "history.action.delete": " הוסר ", + "history.action.authorizedBy": " על-ידי {value}", + "history.action.remarks": "הערות: {value}", "form.message.approve": "אישור המודל יחשוף אותו לגורמים מבצעיים לחילוץ קואורדינטות", "form.message.reject": "ביטול האישור יסיר את המודל מחשיפה לגורמים מבצעיים", @@ -99,13 +102,13 @@ "form.message.confirm.model": "מודל: {value}", "form.message.confirm.action": "פעולה: {value}", "form.message.confirm.approver": "מבצע הפעולה: {value}", - "form.message.confirm.additionalInfo": "הערות: {value}", + "form.message.confirm.remarks": "הערות: {value}", "form.message.confirm.approve": "אישור לחילוץ נ.צ.", "form.message.confirm.reject": "ביטול אישור", "form.approver.label": "שם מלא של מבצע הפעולה *", "form.approver.placeholder": "הזן את שמך המלא", - "form.additionalInfo.label": "הערות (אופציונלי)", - "form.additionalInfo.placeholder": "הוסף הערות לתיעוד...", + "form.remarks.label": "הערות (אופציונלי)", + "form.remarks.placeholder": "הוסף הערות לתיעוד...", "form.password.label": "סיסמה *", "form.password.placeholder": "הזן סיסמה שנית לאימות וביצוע הפעולה" } diff --git a/src/utils/requestHandler.ts b/src/utils/requestHandler.ts index d36b93a..1d91e75 100644 --- a/src/utils/requestHandler.ts +++ b/src/utils/requestHandler.ts @@ -2,6 +2,7 @@ import axios, { AxiosRequestConfig, AxiosResponse, Method } from 'axios'; import { SnackbarManager } from '../components/common/Snackbar/SnackbarManager'; import appConfig from './Config'; import { getSnackbarErrorMessage } from './snackbarError'; +import { get } from 'lodash'; interface IResource { url: string; @@ -85,7 +86,12 @@ export const execute = async ( return response?.status === 204 ? 'OK' : response?.data; } catch (error) { if (submitErrorToSnackbarQueue) { - SnackbarManager.notify(getSnackbarErrorMessage((error as any).message as string)); + const respData = get(error, 'response.data'); + let errText = (error as any).message; + if (respData) { + errText = `err.code.${respData.code}`; + } + SnackbarManager.notify(getSnackbarErrorMessage(errText, respData ? true : false)); } throw error; } diff --git a/src/utils/snackbarError.tsx b/src/utils/snackbarError.tsx index c67dbe2..b4c07b1 100644 --- a/src/utils/snackbarError.tsx +++ b/src/utils/snackbarError.tsx @@ -1,10 +1,10 @@ import { FormattedMessage } from 'react-intl'; import { ExclamationSVGIcon } from '../common/icons/ExclamationSVGIcon'; -export const getSnackbarErrorMessage = (body: string) => { +export const getSnackbarErrorMessage = (body: string, isTranslate: boolean) => { return { title: , - body: body, + body: !isTranslate? body : , dismissesOnAction: true, icon: , leading: false, From a57b3bf46df423ff980ace2026f62420b74d1d32 Mon Sep 17 00:00:00 2001 From: alebinson Date: Thu, 26 Feb 2026 14:54:40 +0200 Subject: [PATCH 2/3] chore: master merge continue --- src/components/Wizard/MetadataForm/MetadataForm.tsx | 5 ----- src/utils/snackbarError.tsx | 9 --------- 2 files changed, 14 deletions(-) diff --git a/src/components/Wizard/MetadataForm/MetadataForm.tsx b/src/components/Wizard/MetadataForm/MetadataForm.tsx index f50ea6d..1bdb4c4 100644 --- a/src/components/Wizard/MetadataForm/MetadataForm.tsx +++ b/src/components/Wizard/MetadataForm/MetadataForm.tsx @@ -16,12 +16,7 @@ export const MetadataForm: React.FC = ({ const [formData, setFormData] = useState<{ approver: string; remarks: string }>({ approver: typeof selectedItem?.approver === 'string' ? selectedItem.approver : '', -<<<<<<< HEAD remarks: typeof selectedItem?.remarks === 'string' ? selectedItem.remarks : '' -======= - additionalInfo: - typeof selectedItem?.additionalInfo === 'string' ? selectedItem.additionalInfo : '', ->>>>>>> 2fe72340c3fc47d84ebd25f6ca1958421cbabf93 }); useEffect(() => { diff --git a/src/utils/snackbarError.tsx b/src/utils/snackbarError.tsx index 3debb17..598e184 100644 --- a/src/utils/snackbarError.tsx +++ b/src/utils/snackbarError.tsx @@ -3,17 +3,8 @@ import { ExclamationSVGIcon } from '../common/icons/ExclamationSVGIcon'; export const getSnackbarErrorMessage = (body: string, isTranslate: boolean) => { return { -<<<<<<< HEAD title: , body: !isTranslate? body : , -======= - title: ( - - - - ), - body: body, ->>>>>>> 2fe72340c3fc47d84ebd25f6ca1958421cbabf93 dismissesOnAction: true, icon: , leading: false, From 32ef825adc5d78a1614bd81205462cbecf053a65 Mon Sep 17 00:00:00 2001 From: alebinson Date: Thu, 26 Feb 2026 15:10:39 +0200 Subject: [PATCH 3/3] chore: lint --- src/common/services/ExtractableService.ts | 2 +- .../MetadataConfirm/MetadataConfirm.tsx | 30 +++++++++---------- .../Wizard/MetadataForm/MetadataForm.tsx | 2 +- .../MetadataHistory/MetadataHistory.tsx | 22 +++++--------- src/utils/snackbarError.tsx | 8 +++-- 5 files changed, 30 insertions(+), 34 deletions(-) diff --git a/src/common/services/ExtractableService.ts b/src/common/services/ExtractableService.ts index e849891..79ca757 100644 --- a/src/common/services/ExtractableService.ts +++ b/src/common/services/ExtractableService.ts @@ -32,7 +32,7 @@ export const extractableCreateAPI = async ( authorizedBy, remarks, data, - } + }, } ); return response as unknown as ExtractableRecord; diff --git a/src/components/Wizard/MetadataConfirm/MetadataConfirm.tsx b/src/components/Wizard/MetadataConfirm/MetadataConfirm.tsx index 69ea54d..f1bce9d 100644 --- a/src/components/Wizard/MetadataConfirm/MetadataConfirm.tsx +++ b/src/components/Wizard/MetadataConfirm/MetadataConfirm.tsx @@ -102,22 +102,20 @@ export const MetadataConfirm: React.FC = ({ }} /> - { - [ - intl.formatMessage( - { id: 'form.message.confirm.approver' }, - { value: selectedItem?.approver as string } - ), - intl.formatMessage( - { id: 'form.message.confirm.remarks' }, - { value: selectedItem?.remarks as string } - ) - ].map((line, index) => ( - - {line} - - )) - } + {[ + intl.formatMessage( + { id: 'form.message.confirm.approver' }, + { value: selectedItem?.approver as string } + ), + intl.formatMessage( + { id: 'form.message.confirm.remarks' }, + { value: selectedItem?.remarks as string } + ), + ].map((line, index) => ( + + {line} + + ))}
diff --git a/src/components/Wizard/MetadataForm/MetadataForm.tsx b/src/components/Wizard/MetadataForm/MetadataForm.tsx index 1bdb4c4..51206d6 100644 --- a/src/components/Wizard/MetadataForm/MetadataForm.tsx +++ b/src/components/Wizard/MetadataForm/MetadataForm.tsx @@ -16,7 +16,7 @@ export const MetadataForm: React.FC = ({ const [formData, setFormData] = useState<{ approver: string; remarks: string }>({ approver: typeof selectedItem?.approver === 'string' ? selectedItem.approver : '', - remarks: typeof selectedItem?.remarks === 'string' ? selectedItem.remarks : '' + remarks: typeof selectedItem?.remarks === 'string' ? selectedItem.remarks : '', }); useEffect(() => { diff --git a/src/components/Wizard/MetadataHistory/MetadataHistory.tsx b/src/components/Wizard/MetadataHistory/MetadataHistory.tsx index b9b224a..2f51b8d 100644 --- a/src/components/Wizard/MetadataHistory/MetadataHistory.tsx +++ b/src/components/Wizard/MetadataHistory/MetadataHistory.tsx @@ -56,13 +56,12 @@ export const MetadataHistory: React.FC = ({ - - {formatDate(item.authorizedAt, locale, true)} - - - + {formatDate(item.authorizedAt, locale, true)} + + = ({ /> - - {item.username} - + {item.username} - + ))} diff --git a/src/utils/snackbarError.tsx b/src/utils/snackbarError.tsx index 598e184..1bf57b7 100644 --- a/src/utils/snackbarError.tsx +++ b/src/utils/snackbarError.tsx @@ -3,8 +3,12 @@ import { ExclamationSVGIcon } from '../common/icons/ExclamationSVGIcon'; export const getSnackbarErrorMessage = (body: string, isTranslate: boolean) => { return { - title: , - body: !isTranslate? body : , + title: ( + + + + ), + body: !isTranslate ? body : , dismissesOnAction: true, icon: , leading: false,