-
Notifications
You must be signed in to change notification settings - Fork 1
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: ajouter une nouvelle contribution #1524
Conversation
@@ -11,6 +11,12 @@ export const generateMetadata = ( | |||
contribution: DocumentElasticWithSource<ContributionDocumentJson>, | |||
breadcrumbs: Breadcrumb[] | |||
): ContributionMetadata => { | |||
if (breadcrumbs.length === 0) { |
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.
J'ai remonté la condition pour le valider même si c'est une contribution générique. Sinon, on pouvait avoir une contrib générique sans thème et ça fait planter le front.
J'en ai profité pour revoir le message d'erreur.
}); | ||
|
||
export type QuestionFormData = z.infer<typeof formDataSchema>; | ||
|
||
export const Form = ({ | ||
question, | ||
messages, | ||
onUpsert, | ||
defaultOrder, |
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 passe un defaultOrder
pour renseigné par défaut le prochain index disponible en BDD
} | ||
label="Ordre" | ||
fullWidth | ||
disabled={question !== undefined} |
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 désactive si on est en mode édition.
} | ||
maxOrder: contribution_questions(order_by: { order: desc }, limit: 1) { | ||
order | ||
} |
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.
Ici je récupère les messages blocks, la liste des CCs supportées (j'ai besoin de savoir si elles sont unextended
pour une règle métier que je gère plus tard) et le maxOrder qui me permet d'avoir le prochain order disponible et de le renseigner par défaut dans le formulaire de création
messages: data.messages, | ||
agreementIds: data.agreements | ||
.flatMap((item) => item) | ||
.concat([{ id: "0000", unextended: false }]), |
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.
Ici j'ajoute pour générer la réponse à la générique. Je ne sais pas si c'est pas mieux de le faire dans le code de création d'une nouvelle contrib.
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.
ça me choque pas ici
@@ -154,7 +154,7 @@ export const questionBaseSchema = z.object({ | |||
required_error: "Une question doit être renseignée", | |||
}) | |||
.min(1, "Une question doit être renseignée"), | |||
order: z.number(), | |||
order: z.coerce.number(), |
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.
Cela permet d'obliger zod à convertir en number la valeur avant de la valider. C'est pour faire fonctionner avec le formulaire car l'input retourne un string.
if (!contribution.cdtnId) { | ||
postTreatment = async (document) => { | ||
await this.contributionRepository.updateCdtnId( | ||
contribution.id, | ||
document.cdtn_id | ||
); | ||
}; |
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.
Ici ça corrige le soucis des états de publication qui n'étaient pas bon. Avant, on tentait de mettre à jour le cdtn_id à ce moment mais le document n'est pas encore créé. Du coup, on a une erreur hasura de foreign key. J'ai placé le processus dans un postTreatment que l'on va exécuté à la fin après avoir insérer le document.
1c475cc
to
8901636
Compare
data: data.agreementIds.map((item) => ({ | ||
display_date: "01/01/2025", | ||
agreement_id: item.id, | ||
content_type: item.unextended ? "NOTHING" : undefined, | ||
})), |
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 créer les questions ici. Du coup, on utilise la liste des cc que l'on a récupéré auparavant.
La ligne content_type: item.unextended ? "NOTHING" : undefined
permet de corriger le soucis du champ non éditable sur certaines réponses. En fait, pour les CCs non étendues (comme la 29), on désactive ce champ car elle ne peut être que dans l'état UNKNOWN pour indiquer la cc est non étendue et que l'on a pas le choix que de mettre une réponse à l'utilisateur. C'est géré dans le formulaire d'une réponse directement.
message_id: formData.message_id ? formData.message_id : undefined, // use to transform empty string sent by the form to undefined | ||
answers: { | ||
data: data.agreementIds.map((item) => ({ | ||
display_date: "01/01/2025", |
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.
A voir par la suite :
Ce champ n'est pas nullable actuellement. Mais c'est étrange de mettre une date à ce moment. Est ce que l'on met la date de création de la contribution ? Est ce que l'on ne met rien ? Il faudrait ajouter le message d'alerte quand on sauvegarde une réponse pour rappeler qu'il faut mettre à jour la date de mise à jour. Car il ça risque d'être oublier je pense.
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.
il faudrait mettre la date de création de la question. Une date en dur c'est un peu bizarre.
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.
Le soucis c'est qu'elle ne devrait pas être renseigné avant la publication car elle va changer :(
8901636
to
b682378
Compare
b682378
to
b52a000
Compare
.kontinuous/env/dev/values.yaml
Outdated
annotations: | ||
oblik.socialgouv.io/min-request-cpu: "500m" | ||
oblik.socialgouv.io/min-request-memory: "500Mi" | ||
oblik.socialgouv.io/min-limit-cpu: "1000m" | ||
oblik.socialgouv.io/min-limit-memory: "1Gi" |
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 force kube à nous filer plus de ressources sinon la mise à jour des docs échouent.
@@ -98,7 +98,7 @@ export: | |||
|
|||
hasura: | |||
~chart: hasura | |||
~needs: [build-hasura, pg] | |||
~needs: [ build-hasura, pg ] |
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.
Il manquait la dépendance sur pg et hasura se lançait avant pg et du coup ça plante le process de déploiement.
fc99402
to
e76a7c4
Compare
@@ -59,3 +59,8 @@ pg: | |||
region: | |||
~tpl~name: "cdtn-prod-backups-access-key" | |||
key: bucket_region | |||
annotations: |
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.
ça on commit du coup ?
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 dirai que oui pour ne pas être bloqué sur les branches de dev...
control={control} | ||
hintText={ | ||
<> | ||
Cette valeur est indicative. Vous pouvez modifier cette valeur |
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.
Cette valeur est indicative. Vous pouvez modifier cette valeur | |
Cette valeur est indicative. Vous pouvez la modifier mais le numéro de question ne doit pas déjà être utilisée. |
<> | ||
Cette valeur est indicative. Vous pouvez modifier cette valeur | ||
mais elle ne doit pas déjà être utilisée.{" "} | ||
<b> |
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.
<b> | |
<strong> |
|
||
export function ContributionsPage() { | ||
return ( | ||
<Layout title="Contributions"> |
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.
<Layout title="Contributions"> | |
<Layout title="Nouvelle Contribution"> |
`/contributions/questions/${result.insert_contribution_questions_one.id}` | ||
); | ||
}; | ||
if (!data) { |
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.
Lorsque je clique sur "créer" j'ai un message furtif d'erreur qui apparait. Cela n'est pas bloquant mais cela n'est pas un comportement normal attendu.
5d97fdb
to
21c96ec
Compare
21c96ec
to
56ce9db
Compare
|
🎉 Deployment for commit 56ce9db : IngressesDocker images
|
No description provided.