Skip to content

Commit

Permalink
refactor(admin-react,api,candidate): finalise sql migration
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasDos committed Jul 16, 2024
1 parent 4ffb725 commit 96f1761
Show file tree
Hide file tree
Showing 20 changed files with 211 additions and 189 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ import ParcoursSection from "./_components/ParcoursSection";

export default function DffSummary({
dematerializedFeasibilityFile,
candidacy,
HasBeenSentComponent,
}: {
dematerializedFeasibilityFile?: DematerializedFeasibilityFile;
candidacy: Candidacy;
HasBeenSentComponent?: React.ReactNode;
}) {
if (!dematerializedFeasibilityFile) {
if (!dematerializedFeasibilityFile || !candidacy) {
return null;
}

const { candidacy } = dematerializedFeasibilityFile;

const {
option,
firstForeignLanguage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ const getCandidacyById = graphql(`
codeRncp
}
feasibility {
feasibilityFileSentAt
dematerializedFeasibilityFile {
swornStatementFileId
isReadyToBeSentToCandidate
isReadyToBeSentToCertificationAuthority
sentToCandidateAt
sentToCertificationAuthorityAt
certificationPartComplete
competenceBlocsPartCompletion
attachmentsPartComplete
Expand Down Expand Up @@ -71,11 +71,13 @@ export const useAapFeasibilityPageLogic = () => {

const candidacy = getCandidacyByIdResponse?.getCandidacyById;
const certification = candidacy?.certification;
const feasibilityFileSentAt = candidacy?.feasibility?.feasibilityFileSentAt;
const dematerializedFeasibilityFile =
candidacy?.feasibility?.dematerializedFeasibilityFile;
return {
certification,
dematerializedFeasibilityFile,
queryStatus: getCandidacyByIdStatus,
feasibilityFileSentAt,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ const AapFeasibilityPage = () => {
candidacyId: string;
}>();

const { certification, dematerializedFeasibilityFile, queryStatus } =
useAapFeasibilityPageLogic();
const {
certification,
dematerializedFeasibilityFile,
queryStatus,
feasibilityFileSentAt,
} = useAapFeasibilityPageLogic();

return (
<div className="flex flex-col">
Expand Down Expand Up @@ -106,7 +110,7 @@ const AapFeasibilityPage = () => {

<SendFileCertificationAuthoritySection
sentToCertificationAuthorityAt={
dematerializedFeasibilityFile?.sentToCertificationAuthorityAt as Date | null
feasibilityFileSentAt as any as Date | null
}
isReadyToBeSentToCertificationAuthority={
dematerializedFeasibilityFile?.isReadyToBeSentToCertificationAuthority
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,10 @@ export const useSendFileCandidate = () => {
const dematerializedFeasibilityFile =
feasibility?.dematerializedFeasibilityFile;
const dematerializedFeasibilityFileId = dematerializedFeasibilityFile?.id;
const candidacy = feasibility?.candidacy;
return {
dematerializedFeasibilityFileId,
candidacy,
sendToCandidateMutation,
dematerializedFeasibilityFile,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"use client";
import { graphqlErrorToast, successToast } from "@/components/toast/toast";
import { DematerializedFeasibilityFile } from "@/graphql/generated/graphql";
import {
Candidacy,
DematerializedFeasibilityFile,
} from "@/graphql/generated/graphql";
import Alert from "@codegouvfr/react-dsfr/Alert";
import Button from "@codegouvfr/react-dsfr/Button";
import { format } from "date-fns";
Expand Down Expand Up @@ -37,6 +40,7 @@ export default function SendFileCandidatePage() {
sendToCandidateMutation,
dematerializedFeasibilityFileId,
dematerializedFeasibilityFile,
candidacy,
} = useSendFileCandidate();
const router = useRouter();
const feasibilitySummaryUrl = `/candidacies/${candidacyId}/feasibility-aap`;
Expand All @@ -59,6 +63,7 @@ export default function SendFileCandidatePage() {
dematerializedFeasibilityFile={
dematerializedFeasibilityFile as DematerializedFeasibilityFile
}
candidacy={candidacy as Candidacy}
HasBeenSentComponent={
<HasBeenSentComponent
sentToCandidateAt={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,133 +17,137 @@ const sendToCertificationAuthority = graphql(`
}
`);

const feasibilityGetActiveFeasibilityByCandidacyId = graphql(`
query feasibilityGetActiveFeasibilityByCandidacyId($candidacyId: ID!) {
feasibility_getActiveFeasibilityByCandidacyId(candidacyId: $candidacyId) {
dematerializedFeasibilityFile {
id
swornStatementFile {
name
previewUrl
mimeType
}
sentToCandidateAt
sentToCertificationAuthorityAt
aapDecision
aapDecisionComment
prerequisites {
label
state
}
firstForeignLanguage
secondForeignLanguage
option
blocsDeCompetences {
certificationCompetenceBloc {
id
code
const getActiveFeasibilitySendFileCertificationAuthorityByCandidacyId = graphql(
`
query getActiveFeasibilitySendFileCertificationAuthorityByCandidacyId(
$candidacyId: ID!
) {
feasibility_getActiveFeasibilityByCandidacyId(candidacyId: $candidacyId) {
feasibilityFileSentAt
dematerializedFeasibilityFile {
id
swornStatementFile {
name
previewUrl
mimeType
}
sentToCandidateAt
aapDecision
aapDecisionComment
prerequisites {
label
isOptional
FCCompetences
competences {
state
}
firstForeignLanguage
secondForeignLanguage
option
blocsDeCompetences {
certificationCompetenceBloc {
id
code
label
isOptional
FCCompetences
competences {
id
label
}
}
}
}
certificationCompetenceDetails {
text
state
certificationCompetence {
id
label
certificationCompetenceDetails {
text
state
certificationCompetence {
id
label
}
}
}
attachments {
type
file {
name
previewUrl
mimeType
attachments {
type
file {
name
previewUrl
mimeType
}
}
}
}
candidacy {
certificationAuthorities {
label
}
individualHourCount
collectiveHourCount
additionalHourCount
basicSkills {
label
id
}
mandatoryTrainings {
label
id
}
certification {
candidacy {
certificationAuthorities {
id
label
}
label
codeRncp
level
degree {
longLabel
level
individualHourCount
collectiveHourCount
additionalHourCount
basicSkills {
label
id
}
}
goals {
id
label
isActive
}
experiences {
id
title
startedAt
duration
description
}
certificateSkills
candidate {
highestDegree {
level
longLabel
mandatoryTrainings {
label
id
}
niveauDeFormationLePlusEleve {
certification {
certificationAuthorities {
id
label
}
label
codeRncp
level
degree {
longLabel
level
}
}
firstname
firstname2
firstname3
lastname
email
givenName
birthdate
birthCity
birthDepartment {
goals {
id
label
code
region {
code
isActive
}
experiences {
id
title
startedAt
duration
description
}
certificateSkills
candidate {
highestDegree {
level
longLabel
}
niveauDeFormationLePlusEleve {
level
}
firstname
firstname2
firstname3
lastname
email
givenName
birthdate
birthCity
birthDepartment {
label
code
region {
code
label
}
}
nationality
gender
phone
city
street
zip
}
nationality
gender
phone
city
street
zip
}
}
}
}
`);
`,
);

export const useSendFileCertificationAuthority = () => {
const { graphqlClient } = useGraphQlClient();
Expand All @@ -157,9 +161,12 @@ export const useSendFileCertificationAuthority = () => {
"dematerializedFeasibilityFileSendFileCertificationAuthorityByCandidacyId",
],
queryFn: () =>
graphqlClient.request(feasibilityGetActiveFeasibilityByCandidacyId, {
candidacyId,
}),
graphqlClient.request(
getActiveFeasibilitySendFileCertificationAuthorityByCandidacyId,
{
candidacyId,
},
),
});

const { mutateAsync: sendToCertificationAuthorityMutation } = useMutation({
Expand All @@ -183,11 +190,13 @@ export const useSendFileCertificationAuthority = () => {
const dematerializedFeasibilityFile =
feasibility?.dematerializedFeasibilityFile;
const dematerializedFeasibilityFileId = dematerializedFeasibilityFile?.id;
const feasibilityFileSentAt = feasibility?.feasibilityFileSentAt;

return {
dematerializedFeasibilityFileId,
candidacy,
sendToCertificationAuthorityMutation,
dematerializedFeasibilityFile,
feasibilityFileSentAt,
};
};
Loading

0 comments on commit 96f1761

Please sign in to comment.