-
Notifications
You must be signed in to change notification settings - Fork 0
✨🏢 Add foster families emergencies #757
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import { Icon } from "#i/generated/icon"; | ||
| import { cn } from "@animeaux/core"; | ||
| import { FosterFamilyEmergencies } from "@animeaux/prisma"; | ||
| import type { Except } from "type-fest"; | ||
|
|
||
| export const SORTED_EMERGENCIES = [ | ||
| FosterFamilyEmergencies.YES, | ||
| FosterFamilyEmergencies.NO, | ||
| FosterFamilyEmergencies.UNKNOWN, | ||
| ]; | ||
|
|
||
| export const EMERGENCIES_TRANSLATION: Record<FosterFamilyEmergencies, string> = | ||
| { | ||
| [FosterFamilyEmergencies.NO]: "Non", | ||
| [FosterFamilyEmergencies.YES]: "Oui", | ||
| [FosterFamilyEmergencies.UNKNOWN]: "Inconnu", | ||
| }; | ||
|
|
||
| export const ICON_BY_EMERGENCIES: Record< | ||
| FosterFamilyEmergencies, | ||
| React.ReactNode | ||
| > = { | ||
| [FosterFamilyEmergencies.NO]: <Icon href="icon-tree-slash-solid" />, | ||
| [FosterFamilyEmergencies.YES]: <Icon href="icon-tree-solid" />, | ||
| [FosterFamilyEmergencies.UNKNOWN]: <Icon href="icon-tree-question-solid" />, | ||
| }; | ||
|
|
||
| export function EmergenciesIcon({ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Je n'ai pas l'impression que ce composant soit utilisé.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Effectivement... Je me suis basée sur le Form.Field pour les types de logements. Je vais le supprimer :) |
||
| emergencies, | ||
| className, | ||
| ...props | ||
| }: Except<React.ComponentPropsWithoutRef<typeof Icon>, "href"> & { | ||
| emergencies: FosterFamilyEmergencies; | ||
| }) { | ||
| return ( | ||
| <Icon | ||
| {...props} | ||
| href="icon-status-solid" | ||
| className={cn(ICON_CLASS_NAMES_BY_EMERGENCIES[emergencies], className)} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| const ICON_CLASS_NAMES_BY_EMERGENCIES: Record<FosterFamilyEmergencies, string> = | ||
| { | ||
| [FosterFamilyEmergencies.YES]: cn("text-green-600"), | ||
| [FosterFamilyEmergencies.NO]: cn("text-red-500"), | ||
| [FosterFamilyEmergencies.UNKNOWN]: cn("text-gray-800"), | ||
| }; | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -16,6 +16,10 @@ import { | |||||
| AVAILABILITY_TRANSLATION, | ||||||
| SORTED_AVAILABILITIES, | ||||||
| } from "#i/foster-families/availability"; | ||||||
| import { | ||||||
| EMERGENCIES_TRANSLATION, | ||||||
| SORTED_EMERGENCIES, | ||||||
| } from "#i/foster-families/emergencies"; | ||||||
| import { | ||||||
| GARDEN_TRANSLATION, | ||||||
| HOUSING_TRANSLATION, | ||||||
|
|
@@ -27,6 +31,7 @@ import { FormDataDelegate } from "@animeaux/form-data"; | |||||
| import type { FosterFamily } from "@animeaux/prisma"; | ||||||
| import { | ||||||
| FosterFamilyAvailability, | ||||||
| FosterFamilyEmergencies, | ||||||
| FosterFamilyGarden, | ||||||
| FosterFamilyHousing, | ||||||
| Species, | ||||||
|
|
@@ -50,6 +55,7 @@ const actionSchema = zu.object({ | |||||
| comments: zu.string().trim(), | ||||||
| displayName: zu.string().trim().min(1, "Veuillez entrer un nom"), | ||||||
| email: zu.string().email("Veuillez entrer un email valide"), | ||||||
| emergencies: zu.nativeEnum(FosterFamilyEmergencies), | ||||||
| garden: zu.nativeEnum(FosterFamilyGarden), | ||||||
| housing: zu.nativeEnum(FosterFamilyHousing), | ||||||
| phone: zu | ||||||
|
|
@@ -76,6 +82,7 @@ type DefaultFosterFamily = null | SerializeFrom< | |||||
| Pick< | ||||||
| FosterFamily, | ||||||
| | "address" | ||||||
| | "emergencies" | ||||||
| | "availability" | ||||||
| | "availabilityExpirationDate" | ||||||
| | "city" | ||||||
|
|
@@ -489,6 +496,10 @@ export function FosterFamilyForm({ | |||||
|
|
||||||
| <Separator /> | ||||||
|
|
||||||
| <Emergencies defaultFosterFamily={defaultFosterFamily} /> | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Je mettrais bien ce champs juste après la disponibilité
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Je fais la modif :) |
||||||
|
|
||||||
| <Separator /> | ||||||
|
|
||||||
| <Form.Field> | ||||||
| <Form.Label htmlFor={ActionFormData.keys.comments}> | ||||||
| Commentaires privés | ||||||
|
|
@@ -569,3 +580,33 @@ function GardenField({ | |||||
| </Form.Field> | ||||||
| ); | ||||||
| } | ||||||
|
|
||||||
| function Emergencies({ | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Merci ! |
||||||
| defaultFosterFamily, | ||||||
| }: { | ||||||
| defaultFosterFamily?: DefaultFosterFamily; | ||||||
| }) { | ||||||
| return ( | ||||||
| <Form.Field> | ||||||
| <Form.Label> | ||||||
| Accepte les accueils court terme et d'urgence <RequiredStar /> | ||||||
| </Form.Label> | ||||||
|
|
||||||
| <RadioInputList> | ||||||
| {SORTED_EMERGENCIES.map((emergencies) => ( | ||||||
| <RadioInput | ||||||
| key={emergencies} | ||||||
| label={EMERGENCIES_TRANSLATION[emergencies]} | ||||||
| name={ActionFormData.keys.emergencies} | ||||||
| value={emergencies} | ||||||
| defaultChecked={ | ||||||
| emergencies === | ||||||
| (defaultFosterFamily?.emergencies ?? | ||||||
| FosterFamilyEmergencies.UNKNOWN) | ||||||
| } | ||||||
| /> | ||||||
| ))} | ||||||
| </RadioInputList> | ||||||
| </Form.Field> | ||||||
| ); | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -14,6 +14,7 @@ import { Icon } from "#i/generated/icon"; | |||||
| import { joinReactNodes } from "@animeaux/core"; | ||||||
| import { | ||||||
| FosterFamilyAvailability, | ||||||
| FosterFamilyEmergencies, | ||||||
| FosterFamilyGarden, | ||||||
| FosterFamilyHousing, | ||||||
| } from "@animeaux/prisma"; | ||||||
|
|
@@ -113,6 +114,12 @@ export function SituationCard() { | |||||
| ].join("")} | ||||||
| </Markdown> | ||||||
| </SimpleItem> | ||||||
|
|
||||||
| <SimpleItem icon={<Icon href="icon-hand-holding-heart-solid" />}> | ||||||
| <Markdown components={HIGHLIGHT_COMPONENTS}> | ||||||
| {[TEXT_BY_EMERGENCY[fosterFamily.emergencies]].join("")} | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Merci ! |
||||||
| </Markdown> | ||||||
| </SimpleItem> | ||||||
| </ItemList> | ||||||
| </Card.Content> | ||||||
| </Card> | ||||||
|
|
@@ -131,3 +138,10 @@ const TEXT_BY_GARDEN: Record<FosterFamilyGarden, string> = { | |||||
| [FosterFamilyGarden.UNKNOWN]: "", | ||||||
| [FosterFamilyGarden.YES]: ", avec **jardin**", | ||||||
| }; | ||||||
|
|
||||||
| const TEXT_BY_EMERGENCY: Record<FosterFamilyEmergencies, string> = { | ||||||
| [FosterFamilyEmergencies.NO]: "Accueil court terme et urgence : **Non**", | ||||||
| [FosterFamilyEmergencies.YES]: "Accueil court terme et urgence : **Oui**", | ||||||
| [FosterFamilyEmergencies.UNKNOWN]: | ||||||
| "Accueil court terme et urgence : **Inconnu**", | ||||||
| }; | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| -- CreateEnum | ||
| CREATE TYPE "FosterFamilyEmergencies" AS ENUM ('NO', 'YES', 'UNKNOWN'); | ||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "FosterFamily" ADD COLUMN "emergencies" "FosterFamilyEmergencies" NOT NULL DEFAULT 'UNKNOWN'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,6 +84,7 @@ model FosterFamily { | |
| updatedAt DateTime @updatedAt | ||
| activities Activity[] | ||
|
|
||
| emergencies FosterFamilyEmergencies @default(UNKNOWN) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Est-ce qu'il y a une raison particulière pour utiliser une enum à la place d'un boolean ? 🤔
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pas forcément, je me suis basée sur un exemple, il me semble que c'était celui des jardins 🤔
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok je vois. Pour |
||
| availability FosterFamilyAvailability @default(UNKNOWN) | ||
| availabilityExpirationDate DateTime? | ||
| comments String? | ||
|
|
@@ -110,6 +111,12 @@ enum FosterFamilyAvailability { | |
| UNKNOWN | ||
| } | ||
|
|
||
| enum FosterFamilyEmergencies { | ||
| NO | ||
| YES | ||
| UNKNOWN | ||
| } | ||
|
|
||
| enum FosterFamilyHousing { | ||
| FLAT | ||
| HOUSE | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je vais te fournir les icons a utiliser ici 👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merci ! :)
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On va utiliser
siren-on-solid.svgquand une FA accepte les urgences et celle là (siren-on-slash-solid.svg) sinon: