-
Notifications
You must be signed in to change notification settings - Fork 4
Conversation
29cd41b
to
0ee5627
Compare
app/src/features/Preview/Preview.tsx
Outdated
const errorKey = Object.keys(errors); | ||
errorKey.forEach((key) => { | ||
enqueueSnackbar( | ||
t<string>("catchValidationErrorPrompt", { | ||
query: errorField, | ||
errorStatus: errorType, | ||
errorKey: key, | ||
errorText: errors[key as keyof typeof errors], | ||
}), | ||
{ | ||
variant: "error", | ||
} | ||
); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest you use Object.entries
instead of Object.keys
, because of what you do in line 167 => accessing errors[key]
const errorKey = Object.keys(errors); | |
errorKey.forEach((key) => { | |
enqueueSnackbar( | |
t<string>("catchValidationErrorPrompt", { | |
query: errorField, | |
errorStatus: errorType, | |
errorKey: key, | |
errorText: errors[key as keyof typeof errors], | |
}), | |
{ | |
variant: "error", | |
} | |
); | |
}); | |
const errorEntries = Object.entries(errors); | |
errorEntries.forEach(([key, text]) => { | |
enqueueSnackbar( | |
t<string>("catchValidationErrorPrompt", { | |
query: errorField, | |
errorStatus: errorType, | |
errorKey: key, | |
errorText: text, | |
}), | |
{ | |
variant: "error", | |
} | |
); | |
}); |
} | ||
}; | ||
previewCreate(); | ||
} | ||
} | ||
}; | ||
|
||
useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a small comment explaining what this useEffect does?
fc65673
to
4f61fd4
Compare
1c5e0e6
to
4f61fd4
Compare
app/src/features/Preview/Preview.tsx
Outdated
|
||
const handleError = useCallback( | ||
(error: FetchBaseQueryError) => { | ||
const typedError = error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this line do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nothing anymore, i forgot to delete it
); | ||
|
||
const handleError = useCallback( | ||
(error: FetchBaseQueryError) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Casting the error variable here doesn't raise any eslint error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it doesn't
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nvm I thought we were in a catch statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nvm I thought we were in a catch statement
app/src/features/Preview/Preview.tsx
Outdated
setAlerts([ | ||
const handleValidationError = useCallback( | ||
( | ||
errors: ApiValidationError<unknown> | undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errors: ApiValidationError<unknown> | undefined, | |
errors?: ApiValidationError<unknown>, |
app/src/features/Preview/Preview.tsx
Outdated
const handleValidationError = useCallback( | ||
( | ||
errors: ApiValidationError<unknown> | undefined, | ||
errorType: number | "FETCH_ERROR" | "PARSING_ERROR" | "CUSTOM_ERROR", | ||
errorField: string | ||
) => { | ||
if (errors) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Declaring your props this way should raise you an error for defining facultative arguments before required ones
You can prevent this like this :
const handleValidationError = useCallback( | |
( | |
errors: ApiValidationError<unknown> | undefined, | |
errorType: number | "FETCH_ERROR" | "PARSING_ERROR" | "CUSTOM_ERROR", | |
errorField: string | |
) => { | |
if (errors) { | |
const handleValidationError = useCallback( | |
({ | |
errors?: ApiValidationError<unknown>, | |
errorType: number | "FETCH_ERROR" | "PARSING_ERROR" | "CUSTOM_ERROR", | |
errorField: string | |
}) => { | |
if (errors) { |
app/src/features/Preview/Preview.tsx
Outdated
else if (typedError.status === "PARSING_ERROR") { | ||
enqueueSnackbar( | ||
t<string>("catchValidationErrorPrompt", { | ||
query: typedError.status, | ||
errorStatus: typedError.originalStatus.toString(), | ||
errorText: typedError.error, | ||
}), | ||
{ variant: "error" } | ||
); | ||
} else if ( | ||
(typedError.status === "FETCH_ERROR" || | ||
typedError.status === "CUSTOM_ERROR") && | ||
typedError.data | ||
) { | ||
enqueueSnackbar(`${typedError.status} : ${typedError.data as string}`, { | ||
variant: "error", | ||
}); | ||
} | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is facultative, but maybe using a switch statement on the typedError.status
variable would be more elegant.
app/src/features/Preview/Preview.tsx
Outdated
|
||
const explore = async () => { | ||
try { | ||
const exploration = await apiExploreCreate({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are shadowing the exploration
variable
export type OperationOutcomeIssue = { | ||
severity: SeverityEnum; | ||
severity: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You definitely shouldn't have those changes in your PR. I guess the merge you made was not from the latest commit of v4
?
river-schema.yml
Outdated
OperationOutcomeIssue: | ||
type: object | ||
properties: | ||
severity: | ||
type: string | ||
code: | ||
type: string | ||
diagnostics: | ||
type: string | ||
location: | ||
type: array | ||
items: | ||
type: string | ||
expression: | ||
type: string | ||
required: | ||
- code | ||
- diagnostics | ||
- expression | ||
- location | ||
- severity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why this is here. From v4 branch, OperationOutcomeIssue
type should already be described at line 3396 :
OperationOutcomeIssue:
type: object
properties:
severity:
$ref: '#/components/schemas/SeverityEnum'
code:
type: string
diagnostics:
type: string
location:
type: array
items:
type: string
expression:
type: string
required:
- code
- diagnostics
- expression
- location
- severity
# name: test_inmemory_fhir_api_validate | ||
<class 'dict'> { | ||
'issue': <class 'list'> [ | ||
], | ||
'resourceType': 'OperationOutcome', | ||
'text': <class 'dict'> { | ||
'div': '<p> it went fine bro </p>', | ||
'status': 'generated', | ||
}, | ||
} | ||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what is this doing here? @simonvadee @tevariou any idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
must be removed (remains from the merge I guess)
app/src/features/Preview/Preview.tsx
Outdated
@@ -300,7 +363,7 @@ const Preview = (): JSX.Element => { | |||
<Alert | |||
key={index} | |||
className={classes.alert} | |||
severity={issue.severity} | |||
severity={issue.severity as Color} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue.severity
should already be of type Color
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
); | ||
|
||
const handleError = useCallback( | ||
(error: FetchBaseQueryError) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nvm I thought we were in a catch statement
); | ||
|
||
const handleError = useCallback( | ||
(error: FetchBaseQueryError) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nvm I thought we were in a catch statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some python files have been changes where the shouldn't: can you reset them to their version on v4 ? you can do:
git reset <commit hash> <filename>
to restore the correct version
# name: test_inmemory_fhir_api_validate | ||
<class 'dict'> { | ||
'issue': <class 'list'> [ | ||
], | ||
'resourceType': 'OperationOutcome', | ||
'text': <class 'dict'> { | ||
'div': '<p> it went fine bro </p>', | ||
'status': 'generated', | ||
}, | ||
} | ||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
must be removed (remains from the merge I guess)
I think I did it correctly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use "squash" instead of rebase to avoid conflicts
Fixes
Fixes #622
Description
Handle errors 500 and 400 on preview with notistack.
Definition of Done