Skip to content

Commit

Permalink
Merge pull request #554 from mission-apprentissage/fix/date-default-d…
Browse files Browse the repository at this point in the history
…emandes

fix: mise à jour des dates par défaut
  • Loading branch information
gBusato authored Jan 30, 2025
2 parents cb9c1e0 + 558b623 commit cb5adb6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const MenuBoiteReception = ({
leftIcon={<Icon icon="ri:file-add-line" height={"20px"} />}
as={hasPermissionSubmitIntention && !isSaisieDisabled() ? NextLink : undefined}
href="/intentions/perdir/saisie/new"
minHeight={"35px"}
>
Nouvelle demande
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const MenuBoiteReception = ({
leftIcon={<Icon icon="ri:file-add-line" height={"20px"} />}
as={hasPermissionSubmitIntention && !isSaisieDisabled() ? NextLink : undefined}
href="/intentions/saisie/new"
minHeight={"35px"}
>
Nouvelle demande
</Button>
Expand Down
38 changes: 4 additions & 34 deletions ui/app/(wrapped)/intentions/saisie/new/page.tsx
Original file line number Diff line number Diff line change
@@ -1,53 +1,23 @@
"use client";

import { useSearchParams } from "next/navigation";
import { CampagneStatutEnum } from "shared/enum/campagneStatutEnum";

import { client } from "@/api.client";
import { IntentionSpinner } from "@/app/(wrapped)/intentions/saisie/components/IntentionSpinner";
import { IntentionForm } from "@/app/(wrapped)/intentions/saisie/intentionForm/IntentionForm";
import {GuardExpe} from '@/utils/security/GuardExpe';
import { GuardExpe } from '@/utils/security/GuardExpe';
import { GuardPermission } from "@/utils/security/GuardPermission";

// eslint-disable-next-line import/no-anonymous-default-export, react/display-name
export default () => {
const queryParams = useSearchParams();
const numero = queryParams.get("numero");

const { data, isLoading } = client.ref("[GET]/demande/:numero").useQuery(
{ params: { numero: numero ?? "" } },
{
enabled: !!numero,
cacheTime: 0,
}
);

const { data: defaultCampagne } = client.ref("[GET]/demande/campagne/default").useQuery({});

if (isLoading && !!numero) return <IntentionSpinner />;
const { data: defaultCampagne, isLoading } = client.ref("[GET]/demande/campagne/default").useQuery({});

return (
<GuardPermission permission="intentions/ecriture">
<GuardExpe isExpeRoute={false}>
{numero ? (
data && (
<IntentionForm
disabled={defaultCampagne?.statut !== CampagneStatutEnum["en cours"]}
defaultValues={{
cfd: data?.compensationCfd,
codeDispositif: data?.compensationCodeDispositif,
uai: data?.compensationUai,
rentreeScolaire: data?.compensationRentreeScolaire,
campagneId: data?.campagneId,
}}
formMetadata={{
etablissement: data?.metadata?.etablissementCompensation,
formation: data?.metadata?.formationCompensation,
}}
campagne={defaultCampagne}
/>
)
) : (
{isLoading && (<IntentionSpinner />)}
{!isLoading && defaultCampagne && (
<IntentionForm
disabled={defaultCampagne?.statut !== CampagneStatutEnum["en cours"]}
defaultValues={{
Expand Down

0 comments on commit cb5adb6

Please sign in to comment.