-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
admin#1870 Shortlisting outcome MVP, admin#2191 Pre Selection Day tas…
…ks (#971) * [ admin#1870 ] Shortlisting outcome MVP * [ jac-uk/admin/issues/2190 ] Pre Selection Day task * WIP * Create candidateFormResponses * Rules for candidateForm responses * Firestore rules for candidateForm responses Add flag to applicationRecord for form status Add applicationId to form response * Update rules --------- Co-authored-by: drieJac <jac.drie@digitalteam.uk>
- Loading branch information
1 parent
0aa2f11
commit 45c515f
Showing
10 changed files
with
511 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
const { applyUpdates } = require('../shared/helpers'); | ||
|
||
module.exports = (firebase, db) => { | ||
return { | ||
onCandidateFormCreate, | ||
}; | ||
|
||
/** | ||
* CandidateForm created event handler | ||
* - Creates CandidateFormResponses | ||
* - One per candidate | ||
*/ | ||
async function createCandidateResponses(data) { | ||
console.log('candidateForm created'); | ||
|
||
// { | ||
// exerciseId: { id: String }, | ||
// task: { type: String }, | ||
// createdAt: Timestamp, | ||
// lastUpdated: Timestamp, | ||
// openDate: Timestamp, | ||
// closeDate: Timestamp, | ||
// candidateIds: String[], | ||
// parts: String[], | ||
// panellists: [{ id: String, fullName: String }], | ||
// } | ||
|
||
if (data.candidateIds.length) { | ||
let commands = []; | ||
|
||
for (let i = 0; i < data.candidateIds.length; i++) { | ||
const candidateFormId = data.id; | ||
const candidateId = candidateIds[i]; | ||
|
||
// { | ||
// formId: String, // so we know ID of parent document | ||
// status: String, // e.g. created | requested | completed | ||
// statusLog: {}, // e.g. { created: Timestamp, requested: Timestamp, completed: Timestamp } | ||
// progress: {} // e.g. { part1: Boolean, part2: Boolean }, | ||
// candidateAvailability: {} // TBC | ||
// panelConflicts: {} // TBC | ||
// } | ||
|
||
const document = { | ||
formId: candidateFormId, | ||
status: 'CREATED', // @TODO: Use constant | ||
statusLog: { | ||
created: firebase.firestore.FieldValue.serverTimestamp(), | ||
requested: null, | ||
completed: null, | ||
}, | ||
progress: { | ||
part1: false, // @TODO: Check with Warren if this should be true here!!! | ||
part2: false, | ||
}, | ||
candidateAvailability: {}, // TBC | ||
panelConflicts: {}, // TBC | ||
}; | ||
|
||
commands.push({ | ||
command: 'set', | ||
ref: db.collection('candidateFormRequests').doc(), | ||
data: document, | ||
}); | ||
} | ||
} | ||
return await applyUpdates(db, commands); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.