Skip to content

Commit

Permalink
Merge pull request #1048 from InseeFr/fix/reset-errors-messages
Browse files Browse the repository at this point in the history
Fix/reset errors messages
  • Loading branch information
PierreVasseur authored Oct 24, 2024
2 parents 568bacd + a3b6357 commit af9d7eb
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/actions/generic-ci-app/action.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: 'Build Application'
runs:
using: "composite"
using: 'composite'
steps:
- uses: actions/setup-node@v4
with:
node-version: 22
node-version: 23
cache: npm
- name: 🏗️ Installing Dependencies
shell: bash
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/generic-ci-documentation/action.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: 'Build Documentation'
runs:
using: "composite"
using: 'composite'
steps:
- uses: actions/setup-node@v4
with:
node-version: 22
node-version: 23
- name: 🏗️ Generate Astro Documentation
shell: bash
run: ./scripts/documentation-build.sh
Expand Down
10 changes: 6 additions & 4 deletions src/packages/auth/open-id-connect-auth/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import * as R from '../../auth/roles';
import { Collection } from '../../model/concepts/collection';
import { Concept } from '../../model/concepts/concept';

export const isAdmin = (roles: string[]) => roles.includes(R.ADMIN);

Expand All @@ -19,7 +21,7 @@ export const isConceptCreator = (
) => roles.includes(R.CONCEPTS_CREATOR) && stamp === conceptCreator;

export const filterConceptsToValidate = (
concepts: any[],
concepts: Concept[],
roles: string[],
stamp: string,
) =>
Expand All @@ -29,12 +31,12 @@ export const filterConceptsToValidate = (

export const isCollectionCreator = (
roles: string[],
stamp: string,
collectionCreator: string,
stamp?: string,
collectionCreator?: string,
) => roles.includes(R.COLLECTIONS_CREATOR) && stamp === collectionCreator;

export const filterCollectionsToValidate = (
collections: any[],
collections: Collection[],
roles: string[],
stamp: string,
) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ export const DumbCodelistPartialDetailEdit = ({

useTitle(D.codelistsPartialTitle, codelist?.labelLg1);

const resetErrorsMessages = () =>
setClientSideErrors({
...clientSideErrors,
errorMessage: [],
});

const handleParentCode = useCallback(
(code) => {
CodeListApi.getCodesListCodes(code, 1, 0).then((codes) => {
Expand All @@ -68,6 +74,7 @@ export const DumbCodelistPartialDetailEdit = ({
(parentCL) => parentCL.value === value,
).iriParent,
});
resetErrorsMessages();
handleParentCode(value);
},
[codelist, handleParentCode, globalCodeListOptions],
Expand Down Expand Up @@ -97,10 +104,7 @@ export const DumbCodelistPartialDetailEdit = ({
const handleChange = useCallback(
(e) => {
const { name, value } = e.target;
setClientSideErrors({
...clientSideErrors,
errorMessage: [],
});
resetErrorsMessages();

setCodelist({
...codelist,
Expand Down Expand Up @@ -194,9 +198,7 @@ export const DumbCodelistPartialDetailEdit = ({
onChange={handleChange}
disabled={updateMode}
aria-invalid={!!clientSideErrors.fields?.id}
aria-describedby={
clientSideErrors.fields?.id ? 'id-error' : null
}
aria-describedby={clientSideErrors.fields?.id ? 'id-error' : null}
/>
<ClientSideError
id="id-error"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,16 @@ export const DumbComponentDetailEdit = ({
}
}, [type, component, initialComponent]);

const resetErrorsMessages = () =>
setClientSideErrors({
...clientSideErrors,
errorMessage: [],
});

const handleChange = useCallback(
(e) => {
const { name, value } = e.target;
setClientSideErrors({
...clientSideErrors,
errorMessage: [],
});
resetErrorsMessages();
setComponent({
...component,
[name]: value,
Expand Down Expand Up @@ -264,6 +267,8 @@ export const DumbComponentDetailEdit = ({
},
{},
);

resetErrorsMessages();
setComponent({ ...newComponentWithoutAttributes, type: option });
};

Expand Down
6 changes: 4 additions & 2 deletions src/packages/utils/date-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { isDateIn, isOutOfDate, stringToDate } from './date-utils';
describe('is date in', () => {
it('returns true if the start and end dates are null', () => {
const toTest = '2017-06-25T10:51:47.812';
expect(isDateIn(toTest, null as any, null as any)).toBe(true);
expect(
isDateIn(toTest, null as unknown as Date, null as unknown as Date),
).toBe(true);
});

it('returns true if the dates match', () => {
Expand All @@ -23,7 +25,7 @@ describe('is date in', () => {

describe('has date passed', () => {
it('returns false if the end date is null', () => {
expect(isOutOfDate(null as any)).toBe(false);
expect(isOutOfDate(null as unknown as Date)).toBe(false);
});

it('returns false if the date has not passed', () => {
Expand Down

0 comments on commit af9d7eb

Please sign in to comment.