Skip to content

Commit

Permalink
refactor(api,admin-react,candidate): rework queries that needs feasib…
Browse files Browse the repository at this point in the history
…ility or dematerialized feasibility
  • Loading branch information
ThomasDos committed Jul 15, 2024
1 parent b1bafdf commit 9fc9063
Show file tree
Hide file tree
Showing 31 changed files with 913 additions and 585 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export default function DffSummary({
aapDecisionComment,
attachments,
prerequisites,
sentToCandidateAt,
blocsDeCompetences,
certificationCompetenceDetails,
swornStatementFile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,45 @@ const getCandidacyById = graphql(`
label
codeRncp
}
dematerializedFeasibilityFile {
swornStatementFileId
isReadyToBeSentToCandidate
isReadyToBeSentToCertificationAuthority
sentToCandidateAt
sentToCertificationAuthorityAt
certificationPartComplete
competenceBlocsPartCompletion
attachmentsPartComplete
prerequisitesPartComplete
prerequisites {
id
label
state
}
blocsDeCompetences {
complete
certificationCompetenceBloc {
feasibility {
dematerializedFeasibilityFile {
swornStatementFileId
isReadyToBeSentToCandidate
isReadyToBeSentToCertificationAuthority
sentToCandidateAt
sentToCertificationAuthorityAt
certificationPartComplete
competenceBlocsPartCompletion
attachmentsPartComplete
prerequisitesPartComplete
prerequisites {
id
code
label
competences {
state
}
blocsDeCompetences {
complete
certificationCompetenceBloc {
id
code
label
competences {
id
label
}
}
}
}
certificationCompetenceDetails {
state
text
certificationCompetence {
id
label
certificationCompetenceDetails {
state
text
certificationCompetence {
id
label
}
}
aapDecision
aapDecisionComment
}
aapDecision
aapDecisionComment
}
}
}
Expand All @@ -70,7 +72,7 @@ export const useAapFeasibilityPageLogic = () => {
const candidacy = getCandidacyByIdResponse?.getCandidacyById;
const certification = candidacy?.certification;
const dematerializedFeasibilityFile =
candidacy?.dematerializedFeasibilityFile;
candidacy?.feasibility?.dematerializedFeasibilityFile;
return {
certification,
dematerializedFeasibilityFile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,27 @@ export const createOrUpdateAttachments = graphql(`
}
`);

const dematerializedFeasibilityFileWithAttachmentsByCandidacyId = graphql(`
query dematerializedFeasibilityFileWithAttachmentsByCandidacyId(
$candidacyId: ID!
) {
dematerialized_feasibility_file_getByCandidacyId(
candidacyId: $candidacyId
const feasibilityWithDematerializedFeasibilityFileAttachmentsByCandidacyId =
graphql(`
query feasibilityWithDematerializedFeasibilityFileAttachmentsByCandidacyId(
$candidacyId: ID!
) {
attachments {
type
file {
name
previewUrl
url
mimeType
__typename
feasibility_getActiveFeasibilityByCandidacyId(candidacyId: $candidacyId) {
dematerializedFeasibilityFile {
attachments {
type
file {
name
previewUrl
url
mimeType
__typename
}
}
}
}
}
}
`);
`);

export const useAttachments = () => {
const { graphqlClient } = useGraphQlClient();
Expand All @@ -50,16 +51,16 @@ export const useAttachments = () => {
],
queryFn: () =>
graphqlClient.request(
dematerializedFeasibilityFileWithAttachmentsByCandidacyId,
feasibilityWithDematerializedFeasibilityFileAttachmentsByCandidacyId,
{
candidacyId,
},
),
});

const candidacy =
getCandidacyByIdResponse?.dematerialized_feasibility_file_getByCandidacyId;
const attachments = candidacy?.attachments;
const feasibility =
getCandidacyByIdResponse?.feasibility_getActiveFeasibilityByCandidacyId;
const attachments = feasibility?.dematerializedFeasibilityFile?.attachments;
return {
attachments,
queryStatus: getCandidacyByIdStatus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ const getCandidacyById = graphql(`
label
}
}
dematerializedFeasibilityFile {
firstForeignLanguage
secondForeignLanguage
option
blocsDeCompetences {
certificationCompetenceBloc {
id
feasibility {
dematerializedFeasibilityFile {
firstForeignLanguage
secondForeignLanguage
option
blocsDeCompetences {
certificationCompetenceBloc {
id
}
}
}
}
Expand Down Expand Up @@ -78,7 +80,7 @@ export const useCertificationPageLogic = () => {
const candidacy = getCandidacyByIdResponse?.getCandidacyById;
const certification = candidacy?.certification;
const dematerializedFeasibilityFile =
candidacy?.dematerializedFeasibilityFile;
candidacy?.feasibility?.dematerializedFeasibilityFile;
return {
candidacy,
certification,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const getBlocDeCompetencesQuery = graphql(`
$candidacyId: ID!
$blocDeCompetencesId: ID!
) {
getCandidacyById(id: $candidacyId) {
feasibility_getActiveFeasibilityByCandidacyId(candidacyId: $candidacyId) {
dematerializedFeasibilityFile {
id
certificationCompetenceDetails {
Expand Down Expand Up @@ -101,7 +101,7 @@ const CompetenciesBlockPage = () => {
});

const dematerializedFile =
getBlocDeCompetencesResponse?.getCandidacyById
getBlocDeCompetencesResponse?.feasibility_getActiveFeasibilityByCandidacyId
?.dematerializedFeasibilityFile;

const block =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ const createOrUpdateDecision = graphql(`
}
`);

const dematerializedFeasibilityFileDecisionByCandidacyId = graphql(`
query dematerializedFeasibilityFileDecisionByCandidacyId($candidacyId: ID!) {
dematerialized_feasibility_file_getByCandidacyId(
candidacyId: $candidacyId
const feasibilityWithDematerializedFeasibilityFileDecisionByCandidacyId =
graphql(`
query feasibilityWithDematerializedFeasibilityFileDecisionByCandidacyId(
$candidacyId: ID!
) {
aapDecision
aapDecisionComment
aapDecisionSentAt
feasibility_getActiveFeasibilityByCandidacyId(candidacyId: $candidacyId) {
dematerializedFeasibilityFile {
aapDecision
aapDecisionComment
}
}
}
}
`);
`);

export const useDecision = () => {
const { candidacyId } = useParams<{ candidacyId: string }>();
Expand Down Expand Up @@ -59,16 +61,18 @@ export const useDecision = () => {
],
queryFn: () =>
graphqlClient.request(
dematerializedFeasibilityFileDecisionByCandidacyId,
feasibilityWithDematerializedFeasibilityFileDecisionByCandidacyId,
{
candidacyId,
},
),
});
const aapDecision =
data?.dematerialized_feasibility_file_getByCandidacyId?.aapDecision;
data?.feasibility_getActiveFeasibilityByCandidacyId
?.dematerializedFeasibilityFile?.aapDecision;
const aapDecisionComment =
data?.dematerialized_feasibility_file_getByCandidacyId?.aapDecisionComment;
data?.feasibility_getActiveFeasibilityByCandidacyId
?.dematerializedFeasibilityFile?.aapDecisionComment;

return {
createOrUpdateDecisionMutation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,23 @@ const getCandidacyQuery = graphql(`
contactFullName
contactEmail
}
feasibilityFile {
name
url
}
IDFile {
name
url
}
documentaryProofFile {
name
url
}
certificateOfAttendanceFile {
name
url
feasibilityUploadedPdf {
feasibilityFile {
name
url
}
IDFile {
name
url
}
documentaryProofFile {
name
url
}
certificateOfAttendanceFile {
name
url
}
}
history {
id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GrayCard } from "@/components/card/gray-card/GrayCard";
import { AuthenticatedLink } from "@/components/authenticated-link/AuthenticatedLink";
import { GrayCard } from "@/components/card/gray-card/GrayCard";

import {
FeasibilityDecisionHistory,
Expand All @@ -22,10 +22,11 @@ export const FeasibiltyStatus = (props: Props): JSX.Element => {
const feasibility = candidacy.data?.getCandidacyById?.feasibility;
const certificationAuthority = feasibility?.certificationAuthority;

const feasibilityFile = feasibility?.feasibilityFile;
const IDFile = feasibility?.IDFile;
const documentaryProofFile = feasibility?.documentaryProofFile;
const certificateOfAttendanceFile = feasibility?.certificateOfAttendanceFile;
const uploadedPdf = feasibility?.feasibilityUploadedPdf;
const feasibilityFile = uploadedPdf?.feasibilityFile;
const IDFile = uploadedPdf?.IDFile;
const documentaryProofFile = uploadedPdf?.documentaryProofFile;
const certificateOfAttendanceFile = uploadedPdf?.certificateOfAttendanceFile;

return (
<div className="flex flex-col gap-6">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,23 @@ const getCandidacyQuery = graphql(`
contactFullName
contactEmail
}
feasibilityFile {
name
url
}
IDFile {
name
url
}
documentaryProofFile {
name
url
}
certificateOfAttendanceFile {
name
url
feasibilityUploadedPdf {
feasibilityFile {
name
url
}
IDFile {
name
url
}
documentaryProofFile {
name
url
}
certificateOfAttendanceFile {
name
url
}
}
history {
id
Expand Down
Loading

0 comments on commit 9fc9063

Please sign in to comment.