Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add nom alt to commune #980

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions components/map/numero-marker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,6 @@ function NumeroMarker({
{completNumero}
</Text>

{numero.positions.find((position) => position.type === "inconnue") && (
<Tooltip
content="Le type d’une position est inconnu"
position={Position.BOTTOM_RIGHT}
>
<WarningSignIcon
color="warning"
size={13}
marginX={4}
marginBottom={2}
style={{ verticalAlign: "middle" }}
/>
</Tooltip>
)}

{numero.certifie && (
<Tooltip
content="Cette adresse est certifiée par la commune"
Expand Down
15 changes: 13 additions & 2 deletions components/settings/bal-settings-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import FormInput from "@/components/form-input";
import RenewTokenDialog from "@/components/renew-token-dialog";
import { BaseLocale, BasesLocalesService } from "@/lib/openapi-api-bal";
import LayoutContext from "@/contexts/layout";
import LanguesRegionalesForm from "../langues-regionales-form";

const mailHasChanged = (listA, listB) => {
return !isEqual(
Expand All @@ -45,6 +46,7 @@ const BALSettingsForm = React.memo(function BALSettingsForm({
const [isLoading, setIsLoading] = useState(false);
const [balEmails, setBalEmails] = useState([]);
const [nomInput, onNomInputChange] = useInput(baseLocale.nom);
const [nomAlt, setNomAlt] = useState(baseLocale.nomAlt);
const [email, onEmailChange, resetEmail] = useInput();
const [hasChanges, setHasChanges] = useState(false);
const [error, setError] = useState("");
Expand All @@ -54,9 +56,11 @@ const BALSettingsForm = React.memo(function BALSettingsForm({

const formHasChanged = useCallback(() => {
return (
nomInput !== baseLocale.nom || mailHasChanged(emails || [], balEmails)
nomInput !== baseLocale.nom ||
!isEqual(baseLocale.nomAlt, nomAlt) ||
mailHasChanged(emails || [], balEmails)
);
}, [nomInput, baseLocale.nom, emails, balEmails]);
}, [nomInput, baseLocale.nom, baseLocale.nomAlt, nomAlt, emails, balEmails]);

useEffect(() => {
setBalEmails(emails || []);
Expand Down Expand Up @@ -90,6 +94,7 @@ const BALSettingsForm = React.memo(function BALSettingsForm({
try {
await BasesLocalesService.updateBaseLocale(baseLocale.id, {
nom: nomInput.trim(),
nomAlt: nomAlt,
emails: balEmails,
});

Expand All @@ -116,6 +121,7 @@ const BALSettingsForm = React.memo(function BALSettingsForm({
[
baseLocale.id,
nomInput,
nomAlt,
balEmails,
reloadEmails,
reloadBaseLocale,
Expand Down Expand Up @@ -150,6 +156,11 @@ const BALSettingsForm = React.memo(function BALSettingsForm({
placeholder="Nom"
onChange={onNomInputChange}
/>

<LanguesRegionalesForm
initialValue={nomAlt}
handleLanguages={setNomAlt}
/>
</FormInput>

<FormInput>
Expand Down
14 changes: 0 additions & 14 deletions components/toponyme/toponyme-numeros.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,6 @@ function ToponymeNumeros({
</Tooltip>
</Table.Cell>
)}

{positions.find((p) => p.type === "inconnue") && (
<Table.TextCell flex="0 1 1">
<Tooltip
content="Le type d’une position est inconnu"
position={Position.BOTTOM}
>
<WarningSignIcon
color="warning"
style={{ verticalAlign: "bottom" }}
/>
</Tooltip>
</Table.TextCell>
)}
</Table.Row>
)
)}
Expand Down
5 changes: 0 additions & 5 deletions components/voie/numeros-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,6 @@ function NumerosList({
: null
}
comment={numero.comment}
warning={
numero.positions.some((p) => p.type === "inconnue")
? "Le type d’une position est inconnu"
: null
}
/>

{isEditingEnabled && (
Expand Down
1 change: 1 addition & 0 deletions lib/openapi-api-bal/models/BaseLocale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type BaseLocale = {
updatedAt: string;
deletedAt: string;
nom: string;
nomAlt: Record<string, any>;
commune: string;
emails: Array<string>;
token: string;
Expand Down
1 change: 1 addition & 0 deletions lib/openapi-api-bal/models/ExtendedBaseLocaleDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type ExtendedBaseLocaleDTO = {
updatedAt: string;
deletedAt: string;
nom: string;
nomAlt: Record<string, any>;
commune: string;
emails: Array<string>;
token: string;
Expand Down
1 change: 0 additions & 1 deletion lib/openapi-api-bal/models/Position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export namespace Position {
D_LIVRANCE_POSTALE = 'délivrance postale',
PARCELLE = 'parcelle',
SEGMENT = 'segment',
INCONNUE = 'inconnue',
}


Expand Down
1 change: 1 addition & 0 deletions lib/openapi-api-bal/models/UpdateBaseLocaleDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

export type UpdateBaseLocaleDTO = {
nom?: string;
nomAlt?: Record<string, any> | null;
emails?: Array<string>;
};

1 change: 0 additions & 1 deletion lib/positions-types-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export const positionsTypesList = [
{ value: "parcelle", name: "Parcelle" },
{ value: "segment", name: "Segment" },
{ value: "service technique", name: "Service technique" },
{ value: "inconnue", name: "Inconnu" },
];

export const getPositionName = (value) => {
Expand Down
Loading