Skip to content
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

Ne permet pas la validation d'une déclaration en saisine ANSES #1391

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
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
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
Loading