Skip to content

Commit

Permalink
Merge pull request #1391 from betagouv/1277-saisine-ansees-validation
Browse files Browse the repository at this point in the history
Ne permet pas la validation d'une déclaration en saisine ANSES
  • Loading branch information
alemangui authored Dec 19, 2024
2 parents 9d7aae2 + 47b2fe6 commit ba910d1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
19 changes: 18 additions & 1 deletion frontend/src/views/InstructionPage/DecisionTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,21 @@
v-model="comment"
/>
</DsfrInputGroup>
<DsfrButton class="" label="Soumettre" @click="submitDecision" />
<DsfrButton
class=""
label="Soumettre"
@click="submitDecision"
:disabled="needsAnsesReferal && decisionCategory === 'approve'"
/>
<div v-if="needsAnsesReferal && decisionCategory === 'approve'" class="mt-2">
<hr class="p-0 my-2" />
<p class="my-1">
<v-icon name="ri-error-warning-line"></v-icon>
La déclaration ne peut pas être validée en nécessitant une saisine ANSEES. Merci de changer l'article
avant de la valider.
</p>
<ArticleInfoRow v-model="declaration" v-if="needsAnsesReferal && decisionCategory === 'approve'" />
</div>

<div v-if="firstErrorMsg(v$, 'reasons')">{{ firstErrorMsg(v$, "reasons") }}</div>
</template>
Expand All @@ -90,6 +104,7 @@ import { useFetch } from "@vueuse/core"
import { headers } from "@/utils/data-fetching"
import useToaster from "@/composables/use-toaster"
import { handleError } from "@/utils/error-handling"
import ArticleInfoRow from "@/components/DeclarationSummary/ArticleInfoRow"
const decisionCategory = ref(null)
watch(decisionCategory, () => (proposal.value = decisionCategory.value === "approve" ? "autorisation" : null))
Expand Down Expand Up @@ -125,6 +140,8 @@ watch(proposal, (newProposal) => {
else delayDays.value = 15
})
const needsAnsesReferal = computed(() => declaration.value?.article === "ANSES_REFERAL")
const decisionCategories = [
{
value: "approve",
Expand Down
21 changes: 17 additions & 4 deletions frontend/src/views/VisaPage/VisaValidationTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@
<p class="fr-text--sm">
{{ decision.description }}
</p>
<div class="text-right">
<DsfrButton :label="decision.buttonText" @click="decision.buttonHandler" secondary />
<ArticleInfoRow class="mb-2" v-if="decision.blockedByAnses" v-model="declaration" />
<div v-else class="text-right">
<DsfrButton
:label="decision.buttonText"
@click="decision.buttonHandler"
secondary
:disabled="decision.blockedByAnses"
/>
</div>
</div>
</div>
Expand All @@ -57,6 +63,7 @@ import { useFetch } from "@vueuse/core"
import { handleError } from "@/utils/error-handling"
import useToaster from "@/composables/use-toaster"
import VisaInfoLine from "./VisaInfoLine.vue"
import ArticleInfoRow from "@/components/DeclarationSummary/ArticleInfoRow"
const $externalResults = ref({})
const emit = defineEmits(["decision-done"])
Expand Down Expand Up @@ -91,16 +98,22 @@ const acceptVisa = async () => {
emit("decision-done")
}
}
const needsAnsesReferal = computed(() => declaration.value?.article === "ANSES_REFERAL")
const shouldBlockApproval = computed(
() => needsAnsesReferal.value && declaration.value.postValidationStatus === "AUTHORIZED"
)
const decisionCategories = computed(() => {
return [
{
title: "Je valide cette décision",
icon: "ri-checkbox-circle-fill",
iconColor: "green",
description: "Je vise cette déclaration et signe.",
description: shouldBlockApproval.value
? "La déclaration ne peut pas être autorisée en nécessitant une saisine ANSEES."
: "Je vise cette déclaration et signe.",
buttonText: "Valider",
buttonHandler: acceptVisa,
blockedByAnses: shouldBlockApproval.value,
},
{
title: "Je ne suis pas d'accord",
Expand Down

0 comments on commit ba910d1

Please sign in to comment.