-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #760 from wri/feat/TM-1578-duplicate-species-names
[TM-1578] Prevent adding a species that is already on the list.
- Loading branch information
Showing
4 changed files
with
103 additions
and
41 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/components/elements/Inputs/TreeSpeciesInput/NonScientificConfirmationModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { useT } from "@transifex/react"; | ||
|
||
import Button from "@/components/elements/Button/Button"; | ||
import TreeSpeciesModal from "@/components/elements/Inputs/TreeSpeciesInput/TreeSpeciesModal"; | ||
import { ModalId } from "@/components/extensive/Modal/ModalConst"; | ||
import { useModalContext } from "@/context/modal.provider"; | ||
|
||
const NonScientificConfirmationModal = ({ onConfirm }: { onConfirm: () => void }) => { | ||
const t = useT(); | ||
const { closeModal } = useModalContext(); | ||
|
||
return ( | ||
<TreeSpeciesModal | ||
title={t("Your input is a not a scientific name")} | ||
content={t("You can add this species, but it will be pending review from Admin.")} | ||
buttons={ | ||
<> | ||
<Button variant="secondary" onClick={() => closeModal(ModalId.ERROR_MODAL)}> | ||
{t("CANCEL")} | ||
</Button> | ||
<Button | ||
variant="primary" | ||
onClick={() => { | ||
closeModal(ModalId.ERROR_MODAL); | ||
onConfirm(); | ||
}} | ||
> | ||
{t("CONFIRM")} | ||
</Button> | ||
</> | ||
} | ||
/> | ||
); | ||
}; | ||
|
||
export default NonScientificConfirmationModal; |
27 changes: 27 additions & 0 deletions
27
src/components/elements/Inputs/TreeSpeciesInput/SpeciesAlreadyExistsModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useT } from "@transifex/react"; | ||
|
||
import Button from "@/components/elements/Button/Button"; | ||
import TreeSpeciesModal from "@/components/elements/Inputs/TreeSpeciesInput/TreeSpeciesModal"; | ||
import { ModalId } from "@/components/extensive/Modal/ModalConst"; | ||
import { useModalContext } from "@/context/modal.provider"; | ||
|
||
const SpeciesAlreadyExistsModal = ({ speciesName }: { speciesName: string }) => { | ||
const { closeModal } = useModalContext(); | ||
const t = useT(); | ||
|
||
return ( | ||
<TreeSpeciesModal | ||
title={t("Species {name} already included", { name: speciesName })} | ||
content={t("Please find species below to enter reported value.")} | ||
buttons={ | ||
<> | ||
<Button variant="secondary" onClick={() => closeModal(ModalId.ERROR_MODAL)}> | ||
{t("CONTINUE")} | ||
</Button> | ||
</> | ||
} | ||
/> | ||
); | ||
}; | ||
|
||
export default SpeciesAlreadyExistsModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/components/elements/Inputs/TreeSpeciesInput/TreeSpeciesModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ReactNode } from "react"; | ||
|
||
import Text from "@/components/elements/Text/Text"; | ||
import Icon, { IconNames } from "@/components/extensive/Icon/Icon"; | ||
|
||
type TreeSpeciesModalProps = { | ||
title: string; | ||
content: string; | ||
buttons: ReactNode; | ||
}; | ||
|
||
const TreeSpeciesModal = ({ title, content, buttons }: TreeSpeciesModalProps) => ( | ||
<div className="margin-4 z-50 m-auto flex max-h-full flex-col items-center justify-start overflow-y-auto rounded-lg border-2 border-neutral-100 bg-white"> | ||
<div className="flex w-full items-center justify-center gap-1 border-b-2 border-neutral-100 py-1"> | ||
<Icon name={IconNames.EXCLAMATION_CIRCLE_FILL} className="min-h-4 min-w-4 mb-1 h-4 w-4 text-tertiary-600" /> | ||
<Text variant="text-16-semibold" className="mb-1 text-blueCustom-700"> | ||
{title} | ||
</Text> | ||
</div> | ||
<div className="w-full p-4"> | ||
<div className="w-full rounded-lg border border-dashed bg-neutral-250 p-2"> | ||
<div className="flex items-center gap-1"> | ||
<Text variant="text-14-light" className="text-blueCustom-700"> | ||
{content} | ||
</Text> | ||
</div> | ||
</div> | ||
<div className="mt-4 flex w-full justify-end gap-3">{buttons}</div> | ||
</div> | ||
</div> | ||
); | ||
|
||
export default TreeSpeciesModal; |