-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/information form #103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Suboyyy
wants to merge
26
commits into
dev
Choose a base branch
from
feat/information-form
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
671f17a
feat(front): contact informations in admin user page
Suboyyy 7ad8db8
feat(back): add endpoint and service for retrieving user contact info…
Suboyyy 3e152d3
fix(back): wrong table
Suboyyy 4571f0b
feat(front): Add header when form isn't complete
Suboyyy 4e53913
feat(front): add urgency modal (empty) and header button
Suboyyy 5c34228
feat(back): add user contact information creation endpoints
Suboyyy 4e3e1a3
feat: add form with answer sending
Suboyyy f791d7d
feat(back): billetweb requests
tuturd db81338
refactor(back): billetweb with API route created for us
tuturd cb214ae
fix: delete contact_CE in form
Suboyyy cc817fa
feat: add vssqcm schemas and seed
Suboyyy c086704
fix: database works
Suboyyy 4523e4f
fix: made a lot of shit but seems good
Suboyyy fa6cadf
feat: implement vss form
Suboyyy 8358ceb
feat: can't access to billetweb iframe if form not submissed or vss d…
Suboyyy 8e9c9f2
refactor: introduction text in urgency and vss modal
Suboyyy 3518f39
feat: add to billetweb if VSS accepted
Suboyyy 282c6b4
feat: only student can now see form and be impacted
Suboyyy bee4ea7
fix: resolve conflict in database (hope don't break everything)
Suboyyy b3a7993
Merge branch 'dev' into feat/information-form
Suboyyy 2ed250b
fix: pointing to right prev migration
Suboyyy 810169c
fix(lint)
Suboyyy 7cd3d23
refactor: update user controller methods to use AppRequestHandler type
Suboyyy 5b78707
Update frontend/src/components/Admin/adminUser.tsx
Suboyyy 7a2f629
Update frontend/src/services/requests/user.service.ts
Suboyyy d3c945d
Update frontend/src/components/home/vssModal.tsx
Suboyyy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,13 +1,13 @@ | ||
| import { defineConfig } from 'drizzle-kit' | ||
| import * as dotenv from "dotenv"; | ||
| import { defineConfig } from 'drizzle-kit'; | ||
| import * as dotenv from 'dotenv'; | ||
|
|
||
| dotenv.config(); | ||
|
|
||
| export default defineConfig({ | ||
| schema: "./src/schemas/*", | ||
| out: "./src/database/migrations", | ||
| dialect: "postgresql", | ||
| dbCredentials: { | ||
| url: process.env.OUTSIDE_DATABASE_URL ?? "" | ||
| }, | ||
| schema: './src/schemas/*', | ||
| out: './src/database/migrations', | ||
| dialect: 'postgresql', | ||
| dbCredentials: { | ||
| url: process.env.OUTSIDE_DATABASE_URL ?? '', | ||
| }, | ||
| }); |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import type { AdminCreateUserDto, PermissionParams, ProfileBody, SyncBody, UserIdParams } from '../dto/user.dto'; | ||
| import * as user_service from '../services/user.service'; | ||
| import { Error, Ok } from '../utils/responses'; | ||
| import { type UserContactInformation } from '../../types/user'; | ||
| import type { AppRequestHandler } from '../types/http'; | ||
|
|
||
| export const getUsersAdmin: AppRequestHandler = async (_req, res) => { | ||
|
|
@@ -66,6 +67,61 @@ export const getCurrentUser: AppRequestHandler = async (req, res) => { | |
| } | ||
| }; | ||
|
|
||
| export const getUserContactInformation: AppRequestHandler = async (req, res) => { | ||
| const { userId } = req.params; | ||
|
|
||
| try { | ||
| const userContactInfo = await user_service.getUserContactInformation(parseInt(userId)); | ||
| Ok(res, { data: userContactInfo }); | ||
| } catch { | ||
| Error(res, { msg: "Erreur lors de la récupération des informations de contact de l'utilisateur." }); | ||
| } | ||
| }; | ||
|
|
||
| export const createUserContactInformation: AppRequestHandler<UserContactInformation> = async (req, res) => { | ||
| const userId = req.user?.userId; | ||
| const contact = req.body; | ||
|
|
||
| try { | ||
| const result = await user_service.createUserContactInformation(userId, contact); | ||
| Ok(res, { msg: 'Informations de contact créées', data: result }); | ||
| } catch { | ||
| Error(res, { msg: 'Erreur lors de la création des informations de contact.' }); | ||
| } | ||
| }; | ||
|
|
||
| export const getCurrentUserOnboardingStatus: AppRequestHandler = async (req, res) => { | ||
| const userId = req.user?.userId; | ||
|
|
||
| try { | ||
| const status = await user_service.getCurrentUserOnboardingStatus(userId); | ||
| Ok(res, { data: status }); | ||
| } catch { | ||
| Error(res, { msg: "Erreur lors de la récupération du statut d'onboarding." }); | ||
| } | ||
| }; | ||
|
|
||
| export const getVssQuestionnaire: AppRequestHandler = async (req, res) => { | ||
| try { | ||
| const questionnaire = await user_service.getVssQuestionnaire(); | ||
| Ok(res, { data: questionnaire }); | ||
| } catch { | ||
| Error(res, { msg: 'Erreur lors de la récupération du questionnaire VSS.' }); | ||
| } | ||
| }; | ||
|
|
||
| export const submitVssQuestionnaire: AppRequestHandler<user_service.VssSubmissionPayload> = async (req, res) => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pareil ça devrait venir du DTO et pas du service (un type dans le service c moche) |
||
| const userId = req.user?.userId; | ||
| const payload = req.body; | ||
|
|
||
| try { | ||
| const result = await user_service.submitVssQuestionnaire(userId, payload); | ||
| Ok(res, { data: result }); | ||
| } catch { | ||
| Error(res, { msg: 'Erreur lors de la soumission du questionnaire VSS.' }); | ||
| } | ||
| }; | ||
|
|
||
| export const updateProfile: AppRequestHandler<ProfileBody> = async (req, res) => { | ||
| const userId = req.user?.userId; | ||
| const { branch, contact } = req.body; | ||
|
|
||
This file contains hidden or 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,215 @@ | ||
| import { db } from '../db'; | ||
| import { vssqcmanswerSchema } from '../../schemas/Relational/vssqcmanswer.schema'; | ||
| import { vssqcmquestionSchema } from '../../schemas/Basic/vssqcmquestion.schema'; | ||
|
|
||
| type SeedQuestion = { | ||
| question: string; | ||
| points: number; | ||
| type: 'single_choice' | 'multiple_choice'; | ||
| answers: { | ||
| answer: string; | ||
| is_correct: boolean; | ||
| }[]; | ||
| }; | ||
|
|
||
| const qcmQuestions: SeedQuestion[] = [ | ||
| { | ||
| question: 'Oui = ', | ||
| points: 1, | ||
| type: 'single_choice', | ||
| answers: [ | ||
| { answer: 'Non', is_correct: false }, | ||
| { answer: 'Toujours oui', is_correct: false }, | ||
| { answer: 'Peut-être non plus tard', is_correct: true }, | ||
| ], | ||
| }, | ||
| { | ||
| question: 'Non = ', | ||
| points: 1, | ||
| type: 'single_choice', | ||
| answers: [ | ||
| { answer: 'Oui', is_correct: false }, | ||
| { answer: 'Non', is_correct: true }, | ||
| { answer: "Peut-être oui si j'insiste", is_correct: false }, | ||
| ], | ||
| }, | ||
| { | ||
| question: 'En résumé, le consentement', | ||
| points: 2, | ||
| type: 'multiple_choice', | ||
| answers: [ | ||
| { answer: 'concerne une action précise', is_correct: true }, | ||
| { answer: "ne peut-être considéré comme éclairé venant d'un personne en état d'ébriété", is_correct: true }, | ||
| { answer: 'doit être libre et éclairé', is_correct: true }, | ||
| { answer: 'peut être retiré à tout moment', is_correct: true }, | ||
| { | ||
| answer: "spécifique, enthousiaste; valable quand la personne chancèle sous l'effet de l'alcool", | ||
| is_correct: false, | ||
| }, | ||
| { answer: "peut s'obtenir en insistant", is_correct: false }, | ||
| { answer: 'est valable quand la personne est bourrée', is_correct: false }, | ||
| ], | ||
| }, | ||
| { | ||
| question: | ||
| "B a embrassé A de force pendant le bang. B était complètement bourré. Il s'agit d'une agression sexuelle. La prise d'alcool est alors une condition :", | ||
| points: 1, | ||
| type: 'single_choice', | ||
| answers: [ | ||
| { answer: 'Aggravante', is_correct: true }, | ||
| { answer: 'Atténuante', is_correct: false }, | ||
| ], | ||
| }, | ||
| { | ||
| question: 'Parmi les situations suivantes, lesquelles sont des agressions sexuelles :', | ||
| points: 1, | ||
| type: 'multiple_choice', | ||
| answers: [ | ||
| { answer: "Se frotter à quelqu'un•e", is_correct: true }, | ||
| { answer: 'Caresser les fesses de son•sa partenaire endormi•e', is_correct: true }, | ||
| { answer: "Embrasser quelqu'un•e de force", is_correct: true }, | ||
| { answer: "Embrasser par surprise quelqu'un•e qui danse au milieu de la foule", is_correct: true }, | ||
| { answer: "Embrasser quelqu'un•e tant alcoolisé•e qu'iel vient de vomir", is_correct: true }, | ||
| ], | ||
| }, | ||
| { | ||
| question: "Un.e de tes amis touche les fesses de B et l'enlace. B a un mouvement de recul. Que peux-tu faire ?", | ||
| points: 1, | ||
| type: 'multiple_choice', | ||
| answers: [ | ||
| { answer: "Rien de particulier. B ne s'en souviendra sûrement pas.", is_correct: false }, | ||
| { answer: 'Demander à B si elle•il va bien', is_correct: true }, | ||
| { | ||
| answer: "Prendre cet•te ami•e à part et lui faire comprendre qu'il•elle a mal agi, que B n'avait pas envie d'être touché•e.", | ||
| is_correct: true, | ||
| }, | ||
| { answer: 'Eloigner ton ami•e de B', is_correct: true }, | ||
| { answer: "Le signaler à un tiers si tu penses que B peut avoir besoin d'aide", is_correct: true }, | ||
| ], | ||
| }, | ||
| { | ||
| question: "A qui et où peux-tu demander de l'aide si tu en as besoin ?", | ||
| points: 1, | ||
| type: 'multiple_choice', | ||
| answers: [ | ||
| { answer: 'Dans la Safe Zone', is_correct: true }, | ||
| { answer: 'Aux personnes des confiance', is_correct: true }, | ||
| { answer: 'Au stand de prévention', is_correct: true }, | ||
| { answer: 'A la team prévention', is_correct: true }, | ||
| { answer: 'Aux super orgas', is_correct: true }, | ||
| { answer: "A tes chefs d'équipe", is_correct: true }, | ||
| { answer: 'A ta marraine / A ton parrain', is_correct: true }, | ||
| { answer: 'À un•e ami•e', is_correct: true }, | ||
| ], | ||
| }, | ||
| { | ||
| question: | ||
| 'En cas de VSS, quelles sont les peines maximales légalement encourue par une personne ayant commis une agression sexuelle ?', | ||
| points: 1, | ||
| type: 'single_choice', | ||
| answers: [ | ||
| { answer: "75 000 € d'amende et 5 ans d'emprisonnemen", is_correct: true }, | ||
| { answer: "10 000€ d'amende", is_correct: false }, | ||
| { answer: '15 ans de prison', is_correct: false }, | ||
| ], | ||
| }, | ||
| { | ||
| question: 'Quelles sont les conséquences possibles pour la victime de VSS ?', | ||
| points: 1, | ||
| type: 'multiple_choice', | ||
| answers: [ | ||
| { answer: 'Aucun effet particulier', is_correct: false }, | ||
| { answer: 'Problèmes somatiques (nausées, migraines, fatigue)', is_correct: true }, | ||
| { answer: 'Dysfonction sexuelle', is_correct: true }, | ||
| { answer: "Crainte de l'intimité", is_correct: true }, | ||
| { answer: 'Dépression majeure', is_correct: true }, | ||
| { answer: 'Détresse psychologique', is_correct: true }, | ||
| ], | ||
| }, | ||
| { | ||
| question: 'Que puis-je faire si je suis témoins de VSS ?', | ||
| points: 1, | ||
| type: 'multiple_choice', | ||
| answers: [ | ||
| { answer: "Dire à la victime de faire attention à elle et de mieux s'habiller", is_correct: false }, | ||
| { answer: 'Aller voir la team prévention ou les super-orgas', is_correct: true }, | ||
| { answer: 'Appeler France Victime (01 80 52 33 86)', is_correct: true }, | ||
| { answer: "Appeler le numéro d'astreinte", is_correct: true }, | ||
| ], | ||
| }, | ||
| { | ||
| question: | ||
| "A quelle sentence s'expose une personne commettant un viol ? \`n Article 222-23 Version en vigueur depuis le 23 avril 2021 \n Tout acte de pénétration sexuelle, de quelque nature qu'il soit, ou tout acte bucco-génital commis sur la personne d'autrui ou sur la personne de l'auteur par violence, contrainte, menace ou surprise est un viol. \n Le viol est puni de quinze ans de réclusion criminelle.", | ||
| points: 1, | ||
| type: 'multiple_choice', | ||
| answers: [ | ||
| { answer: '15 ans de réclusion criminelle', is_correct: true }, | ||
| { answer: "100 000€ d'amence et 20 ans de réclusion criminelle", is_correct: false }, | ||
| { answer: "100 000€ d'amence et 10 ans de réclusion criminelle", is_correct: false }, | ||
| ], | ||
| }, | ||
| { | ||
| question: "Qu'est-ce qui est considéré comme un acte de bizutage (et qui est donc interdit) ? ", | ||
| points: 1, | ||
| type: 'multiple_choice', | ||
| answers: [ | ||
| { answer: "Se dénuder ou inciter quelqu'un à se dénuder (Limousin, Maréchal...)", is_correct: true }, | ||
| { answer: "Obliger quelqu'un à boire de l'alcool de force lors d'une soirée", is_correct: true }, | ||
| { | ||
| answer: 'Organiser une chasse au trésor géante à travers toute la ville pour les nouveaux', | ||
| is_correct: false, | ||
| }, | ||
| { answer: 'Humilier publiquement un nouveau devant le groupe', is_correct: true }, | ||
| { answer: 'Forcer une personne à effectuer des tâches dégradantes ou dangereuses', is_correct: true }, | ||
| { answer: "Défier un nouveau à réciter l'annuaire téléphonique en dansant la macarena", is_correct: false }, | ||
| { answer: 'Motiver les nouveaux à se déguiser en canard', is_correct: false }, | ||
| { answer: 'Forcer les nouveaux à porter un déguisement obscène', is_correct: true }, | ||
| ], | ||
| }, | ||
| { | ||
| question: "A quelles sanctions s'expose l'auteur du bizutage ?", | ||
| points: 1, | ||
| type: 'multiple_choice', | ||
| answers: [ | ||
| { answer: "Une exclusion de l'intégration", is_correct: true }, | ||
| { answer: 'Rien du tout', is_correct: false }, | ||
| { | ||
| answer: "Le bizutage est un délit. Il est puni de 6 mois d'emprisonnement et de 7 500 € d'amende.", | ||
| is_correct: true, | ||
| }, | ||
| { answer: 'Si la victime est une personne vulnérable, les peines sont doublées', is_correct: true }, | ||
| { answer: 'Une mauvaise note', is_correct: false }, | ||
| ], | ||
| }, | ||
| ]; | ||
|
|
||
| export const initQcmvss = async () => { | ||
| const existingQuestion = await db.select().from(vssqcmquestionSchema).limit(1); | ||
|
|
||
| if (existingQuestion.length > 0) { | ||
| return; | ||
| } | ||
|
|
||
| for (const seedQuestion of qcmQuestions) { | ||
| const [createdQuestion] = await db | ||
| .insert(vssqcmquestionSchema) | ||
| .values({ | ||
| question: seedQuestion.question, | ||
| points: seedQuestion.points, | ||
| type: seedQuestion.type, | ||
| }) | ||
| .returning({ id: vssqcmquestionSchema.id }); | ||
|
|
||
| if (!createdQuestion) { | ||
| throw new Error(`Question not inserted: ${seedQuestion.question}`); | ||
| } | ||
|
|
||
| await db.insert(vssqcmanswerSchema).values( | ||
| seedQuestion.answers.map((seedAnswer) => ({ | ||
| questionid: createdQuestion.id, | ||
| answer: seedAnswer.answer, | ||
| is_correct: seedAnswer.is_correct, | ||
| })), | ||
| ); | ||
| } | ||
| }; |
This file contains hidden or 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,8 @@ | ||
| CREATE TABLE "user_informations" ( | ||
| "user_id" integer PRIMARY KEY NOT NULL, | ||
| "urgency_contact_name" text, | ||
| "urgency_contact_phone" text, | ||
| "contact_CE" text | ||
| ); | ||
| --> statement-breakpoint | ||
| ALTER TABLE "user_informations" ADD CONSTRAINT "user_informations_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action; |
1 change: 1 addition & 0 deletions
1
backend/src/database/migrations/0025_natural_human_cannonball.sql
This file contains hidden or 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 @@ | ||
| ALTER TABLE "user_informations" DROP COLUMN "contact_CE"; |
This file contains hidden or 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,18 @@ | ||
| CREATE TYPE "public"."vss_form" AS ENUM('pending', 'validated', 'rejected');--> statement-breakpoint | ||
| CREATE TYPE "public"."question_type" AS ENUM('single_choice', 'multiple_choice');--> statement-breakpoint | ||
| CREATE TABLE "vssqcmquestion" ( | ||
| "id" serial PRIMARY KEY NOT NULL, | ||
| "question" text NOT NULL, | ||
| "points" integer NOT NULL, | ||
| "type" "question_type" NOT NULL | ||
| ); | ||
| --> statement-breakpoint | ||
| CREATE TABLE "vssqcmanswer" ( | ||
| "id" serial PRIMARY KEY NOT NULL, | ||
| "questionid" integer NOT NULL, | ||
| "answer" text NOT NULL, | ||
| "is_correct" boolean NOT NULL | ||
| ); | ||
| --> statement-breakpoint | ||
| ALTER TABLE "users" ADD COLUMN "vss_form" "vss_form" DEFAULT 'pending';--> statement-breakpoint | ||
| ALTER TABLE "vssqcmanswer" ADD CONSTRAINT "vssqcmanswer_questionid_vssqcmquestion_id_fk" FOREIGN KEY ("questionid") REFERENCES "public"."vssqcmquestion"("id") ON DELETE cascade ON UPDATE no action; |
This file contains hidden or 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 @@ | ||
| ALTER TYPE "public"."vss_form" ADD VALUE 'toretry' BEFORE 'validated'; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Les types des controllers seront à décaller dans des DTOs