File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed
packages/reva-api/modules/candidacy Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ type Candidacy {
72
72
status : CandidacyStatusStep !
73
73
typeAccompagnement : TypeAccompagnement !
74
74
lastActivityDate : Timestamp
75
+ isObsolete : Boolean !
75
76
}
76
77
enum TypeAccompagnement {
77
78
ACCOMPAGNE
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ import {
57
57
sendCandidacyDropOutEmailToCertificateur ,
58
58
} from "./mails" ;
59
59
import { resolversSecurityMap } from "./security/security" ;
60
+ import { getCandidacyIsObsolete } from "./features/getCandidacyIsObsolete" ;
60
61
61
62
const unsafeResolvers = {
62
63
Candidacy : {
@@ -83,6 +84,8 @@ const unsafeResolvers = {
83
84
getCandidacyDropOutByCandidacyId ( { candidacyId } ) ,
84
85
candidacyOnCandidacyFinancingMethods : ( { id : candidacyId } : Candidacy ) =>
85
86
getCandidacyOnCandidacyFinancingMethodsByCandidacyId ( { candidacyId } ) ,
87
+ isObsolete : ( { id : candidacyId } : Candidacy ) =>
88
+ getCandidacyIsObsolete ( { candidacyId } ) ,
86
89
} ,
87
90
CandidacyOnCandidacyFinancingMethod : {
88
91
candidacyFinancingMethod : ( {
Original file line number Diff line number Diff line change
1
+ import { addMonths , isBefore } from "date-fns" ;
2
+ import { getCandidacyById } from "./getCandidacyById" ;
3
+
4
+ export const getCandidacyIsObsolete = async ( {
5
+ candidacyId,
6
+ } : {
7
+ candidacyId : string ;
8
+ } ) : Promise < boolean > => {
9
+ const candidacy = await getCandidacyById ( { candidacyId } ) ;
10
+
11
+ if ( ! candidacy ?. lastActivityDate ) {
12
+ return false ;
13
+ }
14
+
15
+ const sixMonthsFromLastActivity = addMonths ( candidacy . lastActivityDate , 6 ) ;
16
+
17
+ return isBefore ( sixMonthsFromLastActivity , new Date ( ) ) ;
18
+ } ;
You can’t perform that action at this time.
0 commit comments