Skip to content

feat: add alert on edition position #984

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

Merged
merged 2 commits into from
Jan 22, 2025
Merged
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
37 changes: 21 additions & 16 deletions components/bal/position-editor.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { useCallback, useEffect, useContext } from "react";
import { useCallback, useEffect, useContext, useMemo } from "react";
import {
Strong,
Pane,
Heading,
Button,
AddIcon,
FormField,
Alert,
Text,
} from "evergreen-ui";

import MarkersContext from "@/contexts/markers";
Expand Down Expand Up @@ -59,23 +61,26 @@ function PositionEditor({
// Remove addMarker and handleAddMarker from hooks to prevent useEffect running when viewport changing
}, [initialPositions, disableMarkers]); // eslint-disable-line react-hooks/exhaustive-deps

const msgAlert = useMemo(() => {
return markers.length > 1
? "Déplacez les marqueurs sur la carte pour modifier les positions"
: markers.length === 1
? `Déplacez le marqueur sur la carte pour positioner le ${
isToponyme ? "toponyme" : "numéro"
}.`
: `Déplacez le marqueur sur la carte pour placer le ${
isToponyme ? "toponyme" : "numéro"
}.`;
}, [markers.length, isToponyme]);

return (
<FormField label="" validationMessage={validationMessage}>
<InputLabel
title="Positions"
help={
markers.length > 1
? "Déplacer les marqueurs sur la carte pour modifier les positions"
: markers.length === 1
? `Déplacer le marqueur sur la carte pour déplacer le ${
isToponyme ? "toponyme" : "numéro"
}.`
: `Déplacer le marqueur sur la carte pour placer le ${
isToponyme ? "toponyme" : "numéro"
}.`
}
/>

<InputLabel title="Positions" help={msgAlert} />
<Pane>
<Alert marginTop={8} marginBottom={8}>
<Text>{msgAlert}</Text>
</Alert>
</Pane>
{markers.length > 0 ? (
<Pane display="grid" gridTemplateColumns="2fr .5fr 1fr 1fr .5fr">
<Strong fontWeight={400} paddingBottom=".5em">
Expand Down
Loading