Skip to content

Commit

Permalink
Merge pull request #984 from InseeFr/fix/useTitle
Browse files Browse the repository at this point in the history
uniformise useTitle hook behavior
  • Loading branch information
PierreVasseur authored Oct 1, 2024
2 parents 6d041bc + 6d805b3 commit 12480cd
Show file tree
Hide file tree
Showing 15 changed files with 15 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const DumbCodelistDetailEdit = ({
const [clientSideErrors, setClientSideErrors] = useState({});
const [submitting, setSubmitting] = useState(false);

useTitle(D.codelistsTitle, codelist?.labelLg1 || D.codelistsCreateTitle);
useTitle(D.codelistsTitle, codelist?.labelLg1);

const permission = usePermission();
const stamp = permission?.stamp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ export const DumbCodelistPartialDetailEdit = ({
const [clientSideErrors, setClientSideErrors] = useState({});
const [submitting, setSubmitting] = useState(false);

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

const handleParentCode = useCallback(
(code) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ export const Component = () => {
);

const { general, members } = collection;
useTitle(
D.collectionsTitle,
general?.prefLabelLg1 || D.createCollectionTitle
);
useTitle(D.collectionsTitle, general?.prefLabelLg1);

if (saving) {
return <Loading textType="saving" />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ export const Component = () => {
);

const { general, members } = collection;
useTitle(
D.collectionsTitle,
general?.prefLabelLg1 || D.createCollectionTitle
);
useTitle(D.collectionsTitle, general?.prefLabelLg1);

if (saving) {
return <Loading textType="saving" />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const Component = () => {

const { general, notes, links } = concept;

useTitle(D.conceptsTitle, general?.prefLabelLg1 || D.createConceptTitle);
useTitle(D.conceptsTitle, general?.prefLabelLg1);

const conceptsWithLinks = mergeWithAllConcepts(concepts, links);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const Component = () => {

const { general, notes, links } = concept;

useTitle(D.conceptsTitle, general?.prefLabelLg1 || D.createConceptTitle);
useTitle(D.conceptsTitle, general?.prefLabelLg1);

const conceptsWithLinks = mergeWithAllConcepts(concepts, links ?? []);

Expand Down
2 changes: 1 addition & 1 deletion src/packages/modules-datasets/datasets/edit/edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const Component = () => {
},
});

useTitle(D.datasetsTitle, editingDataset?.labelLg1 || D.datasetsCreateTitle);
useTitle(D.datasetsTitle, editingDataset?.labelLg1);

if (!editingDataset.id && isEditing) {
return <Loading />;
Expand Down
5 changes: 1 addition & 4 deletions src/packages/modules-datasets/distributions/edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ export const Component = () => {
},
});

useTitle(
D.distributionsTitle,
editingDistribution?.labelLg1 || D.distributionsCreateTitle
);
useTitle(D.distributionsTitle, editingDistribution?.labelLg1);

if (!distribution && isEditing) {
return <Loading />;
Expand Down
4 changes: 1 addition & 3 deletions src/packages/modules-operations/document/edition/edition.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ const OperationsDocumentationEdition = (props) => {

useTitle(
type === LINK ? D.titleLink : D.titleDocument,
props.document.labelLg1 || type === LINK
? D.linksCreateTitle
: D.documentsCreateTitle
props.document.labelLg1
);

const goBack = useGoBack();
Expand Down
5 changes: 1 addition & 4 deletions src/packages/modules-operations/families/edition/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ export const Component = () => {
}
}, [id]);

useTitle(
D.familiesTitle + ' - ' + D.operationsTitle,
family?.prefLabelLg1 || D.familiesCreateTitle
);
useTitle(D.familiesTitle + ' - ' + D.operationsTitle, family?.prefLabelLg1);

if (!family.id && id) return <Loading />;
return <OperationsFamilyEdition id={id} family={family} goBack={goBack} />;
Expand Down
2 changes: 1 addition & 1 deletion src/packages/modules-operations/families/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const Component = () => {
title={D.familiesSearchTitle}
childPath="operations/family"
searchURL="/operations/families/search"
createButton={<FeminineButton action="/operations/family/create" />}
createButton={<FeminineButton action="/operations/families/create" />}
/>
);
};
5 changes: 1 addition & 4 deletions src/packages/modules-operations/indicators/edition/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ export const Component = (props) => {
OperationsApi.getSeriesList().then((payload) => setSeries(payload));
}, []);

useTitle(
D.indicatorsTitle,
indicator?.prefLabelLg1 || D.indicatorsCreateTitle
);
useTitle(D.indicatorsTitle, indicator?.prefLabelLg1);

if (!indicator.id && id) return <Loading />;

Expand Down
5 changes: 1 addition & 4 deletions src/packages/modules-operations/operations/edition/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ export const Component = () => {
);
}, [stamp]);

useTitle(
D.operationsTitle,
operation?.prefLabelLg1 || D.operationsCreateTitle
);
useTitle(D.operationsTitle, operation?.prefLabelLg1);

if (!operation?.id && id) return <Loading />;

Expand Down
5 changes: 1 addition & 4 deletions src/packages/modules-operations/series/edition/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ export const Component = (props) => {
OperationsApi.getSeriesList().then((results) => setSeries(results));
}, []);

useTitle(
D.seriesTitle + ' - ' + D.operationsTitle,
serie?.prefLabelLg1 || D.seriesCreateTitle
);
useTitle(D.seriesTitle + ' - ' + D.operationsTitle, serie?.prefLabelLg1);

if (!serie.id && id) return <Loading />;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export const DumbComponentDetailEdit = ({
const [submitting, setSubmitting] = useState(false);

const { lg1, lg2 } = useAppContext();
useTitle(D.componentTitle, component?.labelLg1 || D.componentsCreateTitle);
useTitle(D.componentTitle, component?.labelLg1);

const permission = usePermission();
const stamp = permission?.stamp;
Expand Down

0 comments on commit 12480cd

Please sign in to comment.