From 996e7eeb95d60732d96850de5d7fe30f72f69277 Mon Sep 17 00:00:00 2001 From: Charles Proust Date: Wed, 20 Dec 2023 10:30:46 +0100 Subject: [PATCH 01/15] creation schema sql and seed --- backend/.env.sample | 2 +- backend/database/schema.sql | 138 +++++++++++++++++++++++++++++++++++- backend/seed.js | 40 +++++++---- 3 files changed, 162 insertions(+), 18 deletions(-) diff --git a/backend/.env.sample b/backend/.env.sample index 0b7bf47..20eec61 100644 --- a/backend/.env.sample +++ b/backend/.env.sample @@ -9,7 +9,7 @@ DB_HOST=localhost DB_PORT=3306 DB_USER=YOUR_DATABASE_USERNAME DB_PASSWORD=YOUR_DATABASE_PASSWORD -DB_NAME=YOUR_DATABASE_NAME +DB_NAME=baby_place # Frontend URL (for CORS configuration) FRONTEND_URL=http://localhost:3000 diff --git a/backend/database/schema.sql b/backend/database/schema.sql index d7542a2..3ad52c2 100644 --- a/backend/database/schema.sql +++ b/backend/database/schema.sql @@ -1,4 +1,136 @@ -create table item ( - id int unsigned primary key auto_increment not null, - title varchar(255) not null +drop database if exists baby_place; +create database baby_place; +use baby_place; +drop table if exists employees_assignments; +drop table if exists employees_disponibilities; +drop table if exists reservation; +drop table if exists documents; +drop table if exists employees; +drop table if exists structures; +drop table if exists child; +drop table if exists parents; +drop table if exists users; + +create table users ( + id int auto_increment primary key, + email varchar(100) unique not null, + password text not null, + profile enum('Structure', 'Parent', 'Employee') not null, + confirmation_inscription boolean, + confirmation_date_sent datetime, + created_date datetime default current_timestamp, + last_connection datetime, + constraint unique_email unique (email) ); + +create table parents ( + id int auto_increment primary key, + user_id int unique, + first_name varchar(100) not null, + last_name varchar(100) not null, + birth_name varchar(100), + terms_accepted boolean, + date_acceptance_terms datetime, + marital_status enum('Single', 'Married', 'Divorced', 'Other'), + address varchar(100), + address_complements varchar(100), + zip_code varchar(5), + city varchar(100), + phone_number varchar(15), + email varchar(100), + profession varchar(100), + constraint fk_parents_users foreign key (user_id) references users(id) ON DELETE CASCADE +); + +create table child ( + id int auto_increment primary key, + parents_id int, + first_name varchar(100) not null, + last_name varchar(100) not null, + date_of_birth date not null, + walker boolean, + name_of_doctor varchar(100), + allergies text, + alimentation enum('All', 'Vegan', 'Vegetarian', 'Halal', 'Kosher'), + constraint fk_child_parents foreign key (parents_id) references parents(id) ON DELETE CASCADE +); + +create table structures ( + id int auto_increment primary key, + user_id int unique, + name varchar(100) not null, + description text, + address varchar(100), + address_complements varchar(100), + zip_code varchar(5), + city varchar(100), + phone_number varchar(15), + email varchar(100), + activities text, + welcomes text, + experiences text, + prices decimal(10,2), + constraint fk_structures_users foreign key (user_id) references users(id) ON DELETE CASCADE +); + +create table employees ( + id int auto_increment primary key, + structure_id int, + first_name varchar(100) not null, + last_name varchar(100) not null, + qualification varchar(100), + max_children_capacity int, + constraint fk_employees_structures foreign key (structure_id) references structures(id) + ON DELETE CASCADE +); + +create table documents ( + id int auto_increment primary key, + reservation_folder_id int, + document_type_id int, + added boolean, + upload_date datetime, + file_name varchar(260), + storage_path varchar(500), + type enum('certificate_insurance', 'certificate_vaccination', 'certificate_birth', 'certificate_aptitude', 'authorisation_care', 'proof_income', 'declaration_income', 'num_CAF', 'num_SS', 'proof_address', 'proof_professional_status', 'RIB', 'authorization_photo', 'authorisation_exit', 'family_booklet', 'divorce_decree'), + origin enum('child_folder', 'parent_folder', 'reservation_folder', 'other') +); + +create table reservation ( + id int auto_increment primary key, + parent_id int, + document_id int, + child_id int, + available_place_id int, + status enum('in_progress', 'waiting', 'accepted', 'refused'), + rejection_reason text, + reservation_date date, + start_time time, + end_time time, + created_date datetime default current_timestamp, + constraint fk_reservation_parents foreign key (parent_id) references parents(id), + constraint fk_reservation_documents foreign key (document_id) references documents(id), + constraint fk_reservation_child foreign key (child_id) references child(id) +); + +create table employees_disponibilities ( + id int auto_increment primary key, + employee_id int, + available_date date, + start_time time, + end_time time, + number_of_places int, + constraint fk_employees_disponibilities_employees foreign key (employee_id) references employees(id) + ON DELETE CASCADE +); + +create table employees_assignments ( + id int auto_increment primary key, + reservation_id int, +employee_id int, +constraint fk_employees_assignements_employees foreign key (employee_id) references employees(id) +ON DELETE CASCADE +); + +alter table documents +add constraint fk_documents_reservation foreign key (reservation_folder_id) references reservation(id); \ No newline at end of file diff --git a/backend/seed.js b/backend/seed.js index fdcf805..5db8326 100644 --- a/backend/seed.js +++ b/backend/seed.js @@ -3,9 +3,6 @@ // Load environment variables from .env file require("dotenv").config(); -// Import Faker library for generating fake data -const { faker } = require("@faker-js/faker"); - // Import database client const database = require("./database/client"); @@ -19,17 +16,32 @@ const seed = async () => { // Generating Seed Data - // Optional: Truncate tables (remove existing data) - await database.query("truncate item"); - - // Insert fake data into the 'item' table - for (let i = 0; i < 10; i += 1) { - queries.push( - database.query("insert into item(title) values (?)", [ - faker.lorem.word(), - ]) - ); - } + // Insert initial data into the database baby_place + await database.query("delete from users"); + queries.push( + database.query( + "insert into users (email, password, profile, confirmation_inscription, confirmation_date_sent, created_date, last_connection) values ('picotipicota@structure.fr', 'baby', 'Structure', '1', '2024-01-01 00:00:00', '2024-01-01 00:00:00', '2024-01-01 00:00:00')" + ) + ); + queries.push( + database.query( + "insert into users (email, password, profile, confirmation_inscription, confirmation_date_sent, created_date, last_connection) values ('papapoule@papaoule.fr', 'papapoule', 'Parent', '1', '2024-01-01 00:00:00', '2024-01-01 00:00:00', '2024-01-01 00:00:00')" + ) + ); + + await database.query("delete from structures"); + queries.push( + database.query( + "insert into structures (user_id, name, description, address, address_complements, zip_code, city, phone_number, email, activities, welcomes, experiences, prices) values ('1','BabyWilder', 'lorem ipsum', '33 Wild Code Place', '', '33000', 'Bordeaux', '05.56.56.56.56', 'picotipicota@structure.com', 'Promenade Musique Activités déveil', 'Sorties extérieures Repas maison Foyer non fumeur', 'Formation premier secours Formation nesting Pédagogie Montessori', '3.50')" + ) + ); + + await database.query("delete from parents"); + queries.push( + database.query( + "insert into parents (user_id, first_name, last_name, birth_name, terms_accepted, date_acceptance_terms, marital_status, address, address_complements, zip_code, city, phone_number, email, profession) values ('2','Papa', 'Poule', 'Poule', '1', '2024-01-01 00:00:00', 'Married', '12 impasse de la rue imaginaire', '', '33000', 'Bordeaux', '06.07.08.09.10', 'papapoule@papaoule.fr', 'Papa à domicile')" + ) + ); /* ************************************************************************* */ From 4f050addc0f15e5c04aa9476242581794efbef27 Mon Sep 17 00:00:00 2001 From: Pras Date: Wed, 20 Dec 2023 11:00:39 +0100 Subject: [PATCH 02/15] npm sass, react router --- frontend/package-lock.json | 260 ++++++++++++++++++++++++++++++------- frontend/package.json | 3 +- 2 files changed, 215 insertions(+), 48 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 69fbe5f..69004e0 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -8,7 +8,8 @@ "prop-types": "^15.8.1", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-router-dom": "^6.14.2" + "react-router-dom": "^6.21.0", + "sass": "^1.69.5" }, "devDependencies": { "@vitejs/plugin-react": "^4.0.3", @@ -945,9 +946,9 @@ } }, "node_modules/@remix-run/router": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.13.0.tgz", - "integrity": "sha512-5dMOnVnefRsl4uRnAdoWjtVTdh8e6aZqgM4puy9nmEADH72ck+uXwzpJLEKE9Q6F8ZljNewLgmTfkxUrBdv4WA==", + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.14.0.tgz", + "integrity": "sha512-WOHih+ClN7N8oHk9N4JUiMxQJmRVaOxcg8w7F/oHUXzJt920ekASLI/7cYX8XkntDWRhLZtsk6LbGrkgOAvi5A==", "engines": { "node": ">=14.0.0" } @@ -1082,6 +1083,18 @@ "node": ">=4" } }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -1278,6 +1291,14 @@ "node": ">=0.6" } }, + "node_modules/binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "engines": { + "node": ">=8" + } + }, "node_modules/bplist-parser": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.2.0.tgz", @@ -1304,7 +1325,6 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dev": true, "dependencies": { "fill-range": "^7.0.1" }, @@ -1416,6 +1436,43 @@ "node": ">=4" } }, + "node_modules/chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/chokidar/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", @@ -2391,7 +2448,6 @@ "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dev": true, "dependencies": { "to-regex-range": "^5.0.1" }, @@ -2454,7 +2510,6 @@ "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, "hasInstallScript": true, "optional": true, "os": [ @@ -2725,6 +2780,11 @@ "node": ">= 4" } }, + "node_modules/immutable": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.4.tgz", + "integrity": "sha512-fsXeu4J4i6WNWSikpI88v/PcVflZz+6kMhUfIwc5SY+poQRPnaf5V7qds6SUyUN3cVxEzuCab7QIoLOQ+DQ1wA==" + }, "node_modules/import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -2821,6 +2881,17 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/is-boolean-object": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", @@ -2895,7 +2966,6 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -2931,7 +3001,6 @@ "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, "dependencies": { "is-extglob": "^2.1.1" }, @@ -2982,7 +3051,6 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true, "engines": { "node": ">=0.12.0" } @@ -3443,6 +3511,14 @@ "integrity": "sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==", "dev": true }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/npm-run-path": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.1.0.tgz", @@ -3731,7 +3807,6 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true, "engines": { "node": ">=8.6" }, @@ -3880,11 +3955,11 @@ } }, "node_modules/react-router": { - "version": "6.20.0", - "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.20.0.tgz", - "integrity": "sha512-pVvzsSsgUxxtuNfTHC4IxjATs10UaAtvLGVSA1tbUE4GDaOSU1Esu2xF5nWLz7KPiMuW8BJWuPFdlGYJ7/rW0w==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.21.0.tgz", + "integrity": "sha512-hGZ0HXbwz3zw52pLZV3j3+ec+m/PQ9cTpBvqjFQmy2XVUWGn5MD+31oXHb6dVTxYzmAeaiUBYjkoNz66n3RGCg==", "dependencies": { - "@remix-run/router": "1.13.0" + "@remix-run/router": "1.14.0" }, "engines": { "node": ">=14.0.0" @@ -3894,12 +3969,12 @@ } }, "node_modules/react-router-dom": { - "version": "6.20.0", - "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.20.0.tgz", - "integrity": "sha512-CbcKjEyiSVpA6UtCHOIYLUYn/UJfwzp55va4yEfpk7JBN3GPqWfHrdLkAvNCcpXr8QoihcDMuk0dzWZxtlB/mQ==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.21.0.tgz", + "integrity": "sha512-1dUdVj3cwc1npzJaf23gulB562ESNvxf7E4x8upNJycqyUm5BRRZ6dd3LrlzhtLaMrwOCO8R0zoiYxdaJx4LlQ==", "dependencies": { - "@remix-run/router": "1.13.0", - "react-router": "6.20.0" + "@remix-run/router": "1.14.0", + "react-router": "6.21.0" }, "engines": { "node": ">=14.0.0" @@ -3909,6 +3984,17 @@ "react-dom": ">=16.8" } }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, "node_modules/reflect.getprototypeof": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.4.tgz", @@ -4178,6 +4264,22 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/sass": { + "version": "1.69.5", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.69.5.tgz", + "integrity": "sha512-qg2+UCJibLr2LCVOt3OlPhr/dqVHWOa9XtZf2OjbLs/T4VPSJ00udtgJxH3neXZm+QqX8B+3cU7RaLqp1iVfcQ==", + "dependencies": { + "chokidar": ">=3.0.0 <4.0.0", + "immutable": "^4.0.0", + "source-map-js": ">=0.6.2 <2.0.0" + }, + "bin": { + "sass": "sass.js" + }, + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/scheduler": { "version": "0.23.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz", @@ -4269,7 +4371,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -4455,7 +4556,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, "dependencies": { "is-number": "^7.0.0" }, @@ -5387,9 +5487,9 @@ } }, "@remix-run/router": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.13.0.tgz", - "integrity": "sha512-5dMOnVnefRsl4uRnAdoWjtVTdh8e6aZqgM4puy9nmEADH72ck+uXwzpJLEKE9Q6F8ZljNewLgmTfkxUrBdv4WA==" + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.14.0.tgz", + "integrity": "sha512-WOHih+ClN7N8oHk9N4JUiMxQJmRVaOxcg8w7F/oHUXzJt920ekASLI/7cYX8XkntDWRhLZtsk6LbGrkgOAvi5A==" }, "@types/babel__core": { "version": "7.20.5", @@ -5497,6 +5597,15 @@ "color-convert": "^1.9.0" } }, + "anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, "argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -5648,6 +5757,11 @@ "integrity": "sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg==", "dev": true }, + "binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==" + }, "bplist-parser": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.2.0.tgz", @@ -5671,7 +5785,6 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dev": true, "requires": { "fill-range": "^7.0.1" } @@ -5731,6 +5844,31 @@ "supports-color": "^5.3.0" } }, + "chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "requires": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "fsevents": "~2.3.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "dependencies": { + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "requires": { + "is-glob": "^4.0.1" + } + } + } + }, "color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", @@ -6475,7 +6613,6 @@ "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dev": true, "requires": { "to-regex-range": "^5.0.1" } @@ -6526,7 +6663,6 @@ "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, "optional": true }, "function-bind": { @@ -6703,6 +6839,11 @@ "integrity": "sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg==", "dev": true }, + "immutable": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.4.tgz", + "integrity": "sha512-fsXeu4J4i6WNWSikpI88v/PcVflZz+6kMhUfIwc5SY+poQRPnaf5V7qds6SUyUN3cVxEzuCab7QIoLOQ+DQ1wA==" + }, "import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -6775,6 +6916,14 @@ "has-bigints": "^1.0.1" } }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "requires": { + "binary-extensions": "^2.0.0" + } + }, "is-boolean-object": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", @@ -6818,8 +6967,7 @@ "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "dev": true + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==" }, "is-finalizationregistry": { "version": "1.0.2", @@ -6843,7 +6991,6 @@ "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, "requires": { "is-extglob": "^2.1.1" } @@ -6872,8 +7019,7 @@ "is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" }, "is-number-object": { "version": "1.0.7", @@ -7204,6 +7350,11 @@ "integrity": "sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==", "dev": true }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" + }, "npm-run-path": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.1.0.tgz", @@ -7409,8 +7560,7 @@ "picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" }, "postcss": { "version": "8.4.31", @@ -7495,20 +7645,28 @@ "dev": true }, "react-router": { - "version": "6.20.0", - "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.20.0.tgz", - "integrity": "sha512-pVvzsSsgUxxtuNfTHC4IxjATs10UaAtvLGVSA1tbUE4GDaOSU1Esu2xF5nWLz7KPiMuW8BJWuPFdlGYJ7/rW0w==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.21.0.tgz", + "integrity": "sha512-hGZ0HXbwz3zw52pLZV3j3+ec+m/PQ9cTpBvqjFQmy2XVUWGn5MD+31oXHb6dVTxYzmAeaiUBYjkoNz66n3RGCg==", "requires": { - "@remix-run/router": "1.13.0" + "@remix-run/router": "1.14.0" } }, "react-router-dom": { - "version": "6.20.0", - "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.20.0.tgz", - "integrity": "sha512-CbcKjEyiSVpA6UtCHOIYLUYn/UJfwzp55va4yEfpk7JBN3GPqWfHrdLkAvNCcpXr8QoihcDMuk0dzWZxtlB/mQ==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.21.0.tgz", + "integrity": "sha512-1dUdVj3cwc1npzJaf23gulB562ESNvxf7E4x8upNJycqyUm5BRRZ6dd3LrlzhtLaMrwOCO8R0zoiYxdaJx4LlQ==", + "requires": { + "@remix-run/router": "1.14.0", + "react-router": "6.21.0" + } + }, + "readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", "requires": { - "@remix-run/router": "1.13.0", - "react-router": "6.20.0" + "picomatch": "^2.2.1" } }, "reflect.getprototypeof": { @@ -7685,6 +7843,16 @@ "is-regex": "^1.1.4" } }, + "sass": { + "version": "1.69.5", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.69.5.tgz", + "integrity": "sha512-qg2+UCJibLr2LCVOt3OlPhr/dqVHWOa9XtZf2OjbLs/T4VPSJ00udtgJxH3neXZm+QqX8B+3cU7RaLqp1iVfcQ==", + "requires": { + "chokidar": ">=3.0.0 <4.0.0", + "immutable": "^4.0.0", + "source-map-js": ">=0.6.2 <2.0.0" + } + }, "scheduler": { "version": "0.23.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz", @@ -7757,8 +7925,7 @@ "source-map-js": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", - "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", - "dev": true + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==" }, "string.prototype.matchall": { "version": "4.0.10", @@ -7884,7 +8051,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, "requires": { "is-number": "^7.0.0" } diff --git a/frontend/package.json b/frontend/package.json index 9f85c66..57b5ed8 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -8,7 +8,8 @@ "prop-types": "^15.8.1", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-router-dom": "^6.14.2" + "react-router-dom": "^6.21.0", + "sass": "^1.69.5" }, "devDependencies": { "@vitejs/plugin-react": "^4.0.3", From 68ae5655d51ee558acc9c7072925fcc9b65d2303 Mon Sep 17 00:00:00 2001 From: Paul-DELESQUES Date: Wed, 20 Dec 2023 17:22:52 +0100 Subject: [PATCH 03/15] add model + controller for table structures --- backend/src/app.js | 2 +- .../src/controllers/stucturesControllers.js | 95 ++++++++++++++ backend/src/models/StructureManager.js | 123 ++++++++++++++++++ backend/src/router.js | 15 +-- backend/src/tables.js | 4 +- 5 files changed, 227 insertions(+), 12 deletions(-) create mode 100644 backend/src/controllers/stucturesControllers.js create mode 100644 backend/src/models/StructureManager.js diff --git a/backend/src/app.js b/backend/src/app.js index 4252c41..1f07560 100644 --- a/backend/src/app.js +++ b/backend/src/app.js @@ -54,7 +54,7 @@ app.use( // Uncomment one or more of these options depending on the format of the data sent by your client: -// app.use(express.json()); +app.use(express.json()); // app.use(express.urlencoded()); // app.use(express.text()); // app.use(express.raw()); diff --git a/backend/src/controllers/stucturesControllers.js b/backend/src/controllers/stucturesControllers.js new file mode 100644 index 0000000..8461119 --- /dev/null +++ b/backend/src/controllers/stucturesControllers.js @@ -0,0 +1,95 @@ +// Import access to database tables +const tables = require("../tables"); + +// The B of BREAD - Browse (Read All) operation +const browse = async (req, res, next) => { + try { + // Fetch all items from the database + const structure = await tables.structures.readAll(); + + // Respond with the structures in JSON format + res.json(structure); + } catch (err) { + // Pass any errors to the error-handling middleware + next(err); + } +}; + +// The R of BREAD - Read operation +const read = async (req, res, next) => { + try { + // Fetch a specific item from the database based on the provided ID + const structure = await tables.structures.read(req.params.id); + + // If the item is not found, respond with HTTP 404 (Not Found) + // Otherwise, respond with the item in JSON format + if (structure == null) { + res.sendStatus(404); + } else { + res.json(structure); + } + } catch (err) { + // Pass any errors to the error-handling middleware + next(err); + } +}; + +// The E of BREAD - Edit (Update) operation +const edit = async (req, res, next) => { + try { + const { id } = req.params; + const structure = req.body; + const [result] = await tables.structures.update({ id, ...structure }); + + if (result.affectedRows === 0) { + res.sendStatus(404); + } else { + res.sendStatus(204); + } + } catch (err) { + res.sendStatus(500); + next(err); + } +}; + +// The A of BREAD - Add (Create) operation +const add = async (req, res, next) => { + // Extract the item data from the request body + const structure = req.body; + try { + // Insert the structures into the database + const insertId = await tables.structures.create(structure); + + // Respond with HTTP 201 (Created) and the ID of the newly inserted item + res.status(201).json({ insertId }); + } catch (err) { + // Pass any errors to the error-handling middleware + next(err); + } +}; + +// The D of BREAD - Destroy (Delete) operation +const destroy = async (req, res, next) => { + const { id } = req.params; + try { + const [result] = await tables.structures.delete(id); + + if (result.affectedRows === 0) { + res.sendStatus(404); + } else { + res.sendStatus(204); + } + } catch (err) { + res.sendStatus(500); + next(err); + } +}; + +// Ready to export the controller functions +module.exports = { + browse, + read, + edit, + add, + destroy, +}; diff --git a/backend/src/models/StructureManager.js b/backend/src/models/StructureManager.js new file mode 100644 index 0000000..25ecd92 --- /dev/null +++ b/backend/src/models/StructureManager.js @@ -0,0 +1,123 @@ +const AbstractManager = require("./AbstractManager"); + +class StructureManager extends AbstractManager { + constructor() { + // Call the constructor of the parent class (AbstractManager) + // and pass the table name "item" as configuration + super({ table: "structures" }); + } + + // The C of CRUD - Create operation + + async create({ + userId, + name, + description, + address, + addressComplements, + zipCode, + city, + phoneNumber, + email, + activities, + welcomes, + experiences, + prices, + }) { + // Execute the SQL INSERT query to add a new item to the "item" table + const [rows] = await this.database.query( + `INSERT INTO ${this.table} (user_id, name, description, address, address_complements, zip_code, city, phone_number, email, activities, welcomes, experiences, prices) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)`, + [ + userId, + name, + description, + address, + addressComplements, + zipCode, + city, + phoneNumber, + email, + activities, + welcomes, + experiences, + prices, + ] + ); + + // Return the ID of the newly inserted item + return rows.insertId; + } + + // The Rs of CRUD - Read operations + + async read(id) { + // Execute the SQL SELECT query to retrieve a specific item by its ID + const [rows] = await this.database.query( + `SELECT * FROM ${this.table} WHERE id = ?`, + [id] + ); + + // Return the first row of the rows, which represents the item + return rows[0]; + } + + async readAll() { + // Execute the SQL SELECT query to retrieve all items from the "item" table + const [rows] = await this.database.query(`SELECT * FROM ${this.table}`); + + // Return the array of items + return rows; + } + + // The U of CRUD - Update operation + // TODO: Implement the update operation to modify an existing item + + async update({ + name, + description, + address, + addressComplements, + zipCode, + city, + phoneNumber, + email, + activities, + welcomes, + experiences, + prices, + id, + }) { + const [rows] = await this.database.query( + ` UPDATE ${this.table} SET name = ?, description = ?, address = ?, address_complements = ?, zip_code = ?, city = ?, phone_number = ?, email = ?, activities = ?, welcomes = ?, experiences = ?, prices = ? WHERE id = ?`, + [ + name, + description, + address, + addressComplements, + zipCode, + city, + phoneNumber, + email, + activities, + welcomes, + experiences, + prices, + id, + ] + ); + return [rows]; + } + + // The D of CRUD - Delete operation + // TODO: Implement the delete operation to remove an item by its ID + + async delete(id) { + const [rows] = await this.database.query( + `DELETE FROM ${this.table} WHERE id = ?`, + [id] + ); + return [rows]; + } +} + +module.exports = StructureManager; diff --git a/backend/src/router.js b/backend/src/router.js index 38f375d..fbd45cd 100644 --- a/backend/src/router.js +++ b/backend/src/router.js @@ -7,16 +7,13 @@ const router = express.Router(); /* ************************************************************************* */ // Import itemControllers module for handling item-related operations -const itemControllers = require("./controllers/itemControllers"); +const structuresControllers = require("./controllers/stucturesControllers"); -// Route to get a list of items -router.get("/items", itemControllers.browse); - -// Route to get a specific item by ID -router.get("/items/:id", itemControllers.read); - -// Route to add a new item -router.post("/items", itemControllers.add); +router.get("/structures", structuresControllers.browse); +router.get("/structures/:id", structuresControllers.read); +router.post("/structures", structuresControllers.add); +router.put("/structures/:id", structuresControllers.edit); +router.delete("/structures/:id", structuresControllers.destroy); /* ************************************************************************* */ diff --git a/backend/src/tables.js b/backend/src/tables.js index 66d032c..e8c922e 100644 --- a/backend/src/tables.js +++ b/backend/src/tables.js @@ -3,10 +3,10 @@ /* ************************************************************************* */ // Import the manager modules responsible for handling data operations on the tables -const ItemManager = require("./models/ItemManager"); +const StructureManager = require("./models/StructureManager"); const managers = [ - ItemManager, + StructureManager, // Add other managers here ]; From 401a1383bea086150610fc2874f82d305b099f9d Mon Sep 17 00:00:00 2001 From: FredP21 Date: Wed, 20 Dec 2023 17:40:01 +0100 Subject: [PATCH 04/15] I create the Manager and the controller for table parents, and i confidurate router. --- backend/src/app.js | 2 +- backend/src/controllers/itemControllers.js | 67 ---------- backend/src/controllers/parentsController.js | 98 +++++++++++++++ backend/src/models/ItemManager.js | 59 --------- backend/src/models/ParentsManager.js | 125 +++++++++++++++++++ backend/src/router.js | 14 +-- backend/src/tables.js | 4 +- 7 files changed, 233 insertions(+), 136 deletions(-) delete mode 100644 backend/src/controllers/itemControllers.js create mode 100644 backend/src/controllers/parentsController.js delete mode 100644 backend/src/models/ItemManager.js create mode 100644 backend/src/models/ParentsManager.js diff --git a/backend/src/app.js b/backend/src/app.js index 4252c41..1f07560 100644 --- a/backend/src/app.js +++ b/backend/src/app.js @@ -54,7 +54,7 @@ app.use( // Uncomment one or more of these options depending on the format of the data sent by your client: -// app.use(express.json()); +app.use(express.json()); // app.use(express.urlencoded()); // app.use(express.text()); // app.use(express.raw()); diff --git a/backend/src/controllers/itemControllers.js b/backend/src/controllers/itemControllers.js deleted file mode 100644 index fca2dc2..0000000 --- a/backend/src/controllers/itemControllers.js +++ /dev/null @@ -1,67 +0,0 @@ -// Import access to database tables -const tables = require("../tables"); - -// The B of BREAD - Browse (Read All) operation -const browse = async (req, res, next) => { - try { - // Fetch all items from the database - const items = await tables.item.readAll(); - - // Respond with the items in JSON format - res.json(items); - } catch (err) { - // Pass any errors to the error-handling middleware - next(err); - } -}; - -// The R of BREAD - Read operation -const read = async (req, res, next) => { - try { - // Fetch a specific item from the database based on the provided ID - const item = await tables.item.read(req.params.id); - - // If the item is not found, respond with HTTP 404 (Not Found) - // Otherwise, respond with the item in JSON format - if (item == null) { - res.sendStatus(404); - } else { - res.json(item); - } - } catch (err) { - // Pass any errors to the error-handling middleware - next(err); - } -}; - -// The E of BREAD - Edit (Update) operation -// This operation is not yet implemented - -// The A of BREAD - Add (Create) operation -const add = async (req, res, next) => { - // Extract the item data from the request body - const item = req.body; - - try { - // Insert the item into the database - const insertId = await tables.item.create(item); - - // Respond with HTTP 201 (Created) and the ID of the newly inserted item - res.status(201).json({ insertId }); - } catch (err) { - // Pass any errors to the error-handling middleware - next(err); - } -}; - -// The D of BREAD - Destroy (Delete) operation -// This operation is not yet implemented - -// Ready to export the controller functions -module.exports = { - browse, - read, - // edit, - add, - // destroy, -}; diff --git a/backend/src/controllers/parentsController.js b/backend/src/controllers/parentsController.js new file mode 100644 index 0000000..0a91486 --- /dev/null +++ b/backend/src/controllers/parentsController.js @@ -0,0 +1,98 @@ +// Import access to database tables +const tables = require("../tables"); + +// The B of BREAD - Browse (Read All) operation +const browse = async (req, res, next) => { + try { + // Fetch all parents from the database + const parents = await tables.parents.readAll(); + + // Respond with the parents in JSON format + res.json(parents); + } catch (err) { + // Pass any errors to the error-handling middleware + next(err); + } +}; + +// The R of BREAD - Read operation +const read = async (req, res, next) => { + try { + // Fetch a specific parents from the database based on the provided ID + const parents = await tables.parents.read(req.params.id); + + // If the parents is not found, respond with HTTP 404 (Not Found) + // Otherwise, respond with the parents in JSON format + if (parents == null) { + res.sendStatus(404); + } else { + res.json(parents); + } + } catch (err) { + // Pass any errors to the error-handling middleware + next(err); + } +}; + +// The E of BREAD - Edit (Update) operation +// This operation is not yet implemented + +const edit = async (req, res, next) => { + try { + const parents = req.body; + const { id } = req.params; + const [result] = await tables.parents.update({ ...parents, id }); + if (result.affectedRows === 0) { + res.sendStatus(404); + } else { + res.sendStatus(204); + } + next(); + } catch (err) { + console.error(err); + res.status(500); + next(err); + } +}; + +// The A of BREAD - Add (Create) operation +const add = async (req, res, next) => { + // Extract the parents data from the request body + const parents = req.body; + + try { + // Insert the parents into the database + const insertId = await tables.parents.create(parents); + + // Respond with HTTP 201 (Created) and the ID of the newly inserted parents + res.status(201).json({ insertId }); + } catch (err) { + // Pass any errors to the error-handling middleware + next(err); + } +}; + +// The D of BREAD - Destroy (Delete) operation +// This operation is not yet implemented +const destroy = async (req, res, next) => { + try { + // Fetch a specific parents from the database based on the provided ID + const [parents] = await tables.parents.delete(req.params.id); + if (parents.affectedRows === 0) { + res.sendStatus(404); + } else { + res.sendStatus(204); + } + } catch (err) { + res.status(500).json({ message: "Error with server" }); + next(err); + } +}; +// Ready to export the controller functions +module.exports = { + browse, + read, + edit, + add, + destroy, +}; diff --git a/backend/src/models/ItemManager.js b/backend/src/models/ItemManager.js deleted file mode 100644 index eeeae9f..0000000 --- a/backend/src/models/ItemManager.js +++ /dev/null @@ -1,59 +0,0 @@ -const AbstractManager = require("./AbstractManager"); - -class ItemManager extends AbstractManager { - constructor() { - // Call the constructor of the parent class (AbstractManager) - // and pass the table name "item" as configuration - super({ table: "item" }); - } - - // The C of CRUD - Create operation - - async create(item) { - // Execute the SQL INSERT query to add a new item to the "item" table - const [result] = await this.database.query( - `insert into ${this.table} (title) values (?)`, - [item.title] - ); - - // Return the ID of the newly inserted item - return result.insertId; - } - - // The Rs of CRUD - Read operations - - async read(id) { - // Execute the SQL SELECT query to retrieve a specific item by its ID - const [rows] = await this.database.query( - `select * from ${this.table} where id = ?`, - [id] - ); - - // Return the first row of the result, which represents the item - return rows[0]; - } - - async readAll() { - // Execute the SQL SELECT query to retrieve all items from the "item" table - const [rows] = await this.database.query(`select * from ${this.table}`); - - // Return the array of items - return rows; - } - - // The U of CRUD - Update operation - // TODO: Implement the update operation to modify an existing item - - // async update(item) { - // ... - // } - - // The D of CRUD - Delete operation - // TODO: Implement the delete operation to remove an item by its ID - - // async delete(id) { - // ... - // } -} - -module.exports = ItemManager; diff --git a/backend/src/models/ParentsManager.js b/backend/src/models/ParentsManager.js new file mode 100644 index 0000000..d025480 --- /dev/null +++ b/backend/src/models/ParentsManager.js @@ -0,0 +1,125 @@ +const AbstractManager = require("./AbstractManager"); + +class ParentsManager extends AbstractManager { + constructor() { + // Call the constructor of the parent class (AbstractManager) + // and pass the table name "item" as configuration + super({ table: "parents" }); + } + + // The C of CRUD - Create operation + + async create({ + firstName, + lastName, + birthName, + termsAccepted, + dateAcceptanceTerms, + maritalStatus, + address, + addressComplements, + zipCode, + city, + phoneNumber, + email, + profession, + }) { + // Execute the SQL INSERT query to add a new parents to the "parents" table + const [result] = await this.database.query( + `INSERT INTO ${this.table} ( first_name, last_name, birth_name, terms_accepted, date_acceptance_terms, marital_status, address, address_complements, zip_code, city, phone_number, email, profession) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)`, + [ + firstName, + lastName, + birthName, + termsAccepted, + dateAcceptanceTerms, + maritalStatus, + address, + addressComplements, + zipCode, + city, + phoneNumber, + email, + profession, + ] + ); + + // Return the ID of the newly inserted parents + return result.insertId; + } + + // The Rs of CRUD - Read operations + + async read(id) { + // Execute the SQL SELECT query to retrieve a specific parents by its ID + const [rows] = await this.database.query( + `SELECT * FROM ${this.table} WHERE id = ?`, + [id] + ); + + // Return the first row of the result, which represents the parents + return rows[0]; + } + + async readAll() { + // Execute the SQL SELECT query to retrieve all parents from the "parents" table + const [rows] = await this.database.query(`SELECT * FROM ${this.table}`); + + // Return the array of parents + return rows; + } + + // The U of CRUD - Update operation + // TODO: Implement the update operation to modify an existing parents + + async update({ + firstName, + lastName, + birthName, + termsAccepted, + dateAcceptanceTerms, + maritalStatus, + address, + addressComplements, + zipCode, + city, + phoneNumber, + email, + profession, + id, + }) { + const [rows] = await this.database.query( + `UPDATE ${this.table} SET first_name=?, last_name=?, birth_name=?, terms_accepted=?, date_acceptance_terms=?, marital_status=?, address=?, address_complements=?, zip_code=?, city=?, phone_number=?, email=?, profession=? WHERE id=?`, + [ + firstName, + lastName, + birthName, + termsAccepted, + dateAcceptanceTerms, + maritalStatus, + address, + addressComplements, + zipCode, + city, + phoneNumber, + email, + profession, + id, + ] + ); + return [rows]; + } + + // The D of CRUD - Delete operation + // TODO: Implement the delete operation to remove an parents by its ID + + async delete(id) { + const [rows] = await this.database.query( + `DELETE FROM ${this.table} WHERE id = ?`, + [id] + ); + return [rows]; + } +} + +module.exports = ParentsManager; diff --git a/backend/src/router.js b/backend/src/router.js index 38f375d..de1469d 100644 --- a/backend/src/router.js +++ b/backend/src/router.js @@ -7,16 +7,16 @@ const router = express.Router(); /* ************************************************************************* */ // Import itemControllers module for handling item-related operations -const itemControllers = require("./controllers/itemControllers"); -// Route to get a list of items -router.get("/items", itemControllers.browse); +const parentsControllers = require("./controllers/parentsController"); -// Route to get a specific item by ID -router.get("/items/:id", itemControllers.read); +// parents -// Route to add a new item -router.post("/items", itemControllers.add); +router.get("/parents", parentsControllers.browse); +router.get("/parents/:id", parentsControllers.read); +router.put("/parents/:id", parentsControllers.edit); +router.post("/parents", parentsControllers.add); +router.delete("/parents/:id", parentsControllers.destroy); /* ************************************************************************* */ diff --git a/backend/src/tables.js b/backend/src/tables.js index 66d032c..5d5a0d0 100644 --- a/backend/src/tables.js +++ b/backend/src/tables.js @@ -3,10 +3,10 @@ /* ************************************************************************* */ // Import the manager modules responsible for handling data operations on the tables -const ItemManager = require("./models/ItemManager"); +const ParentsManager = require("./models/ParentsManager"); const managers = [ - ItemManager, + ParentsManager, // Add other managers here ]; From b13753975df251de164dda687189151c2f20c779 Mon Sep 17 00:00:00 2001 From: Pras Date: Wed, 20 Dec 2023 18:02:11 +0100 Subject: [PATCH 05/15] child controller, model, router --- backend/src/controllers/childControllers.js | 109 ++++++++++++++++++ .../src/controllers/reservationControllers.js | 109 ++++++++++++++++++ backend/src/models/ChildManager.js | 103 +++++++++++++++++ backend/src/router.js | 20 ++-- backend/src/tables.js | 4 +- 5 files changed, 332 insertions(+), 13 deletions(-) create mode 100644 backend/src/controllers/childControllers.js create mode 100644 backend/src/controllers/reservationControllers.js create mode 100644 backend/src/models/ChildManager.js diff --git a/backend/src/controllers/childControllers.js b/backend/src/controllers/childControllers.js new file mode 100644 index 0000000..d413257 --- /dev/null +++ b/backend/src/controllers/childControllers.js @@ -0,0 +1,109 @@ +// Import access to database tables +const tables = require("../tables"); + +// The B of BREAD - Browse (Read All) operation +const browse = async (req, res, next) => { + try { + // Fetch all child from the database + const child = await tables.child.readAll(); + + // Respond with the child in JSON format + res.json(child); + } catch (err) { + // Pass any errors to the error-handling middleware + next(err); + } +}; + +// The R of BREAD - Read operation +const read = async (req, res, next) => { + try { + // Fetch a specific child from the database based on the provided ID + const child = await tables.child.read(req.params.id); + + // If the child is not found, respond with HTTP 404 (Not Found) + // Otherwise, respond with the child in JSON format + if (child == null) { + res.sendStatus(404); + } else { + res.json(child); + } + } catch (err) { + // Pass any errors to the error-handling middleware + next(err); + } +}; + +// The E of BREAD - Edit (Update) operation +// This operation is not yet implemented +const edit = async (req, res, next) => { + const { id } = req.params; + const firstName = req.body.first_name; + const lastName = req.body.last_name; + const dateOfBirth = req.body.date_of_birth; + const { walker } = req.body; + const { allergies } = req.body; + const { alimentation } = req.body; + try { + const childResult = await tables.child.update( + id, + firstName, + lastName, + dateOfBirth, + walker, + allergies, + alimentation + ); + + if (childResult.affectedRows === 0) { + res.sendStatus(404); + } else { + res.sendStatus(204); + } + } catch (err) { + next(err); + } +}; + +// The A of BREAD - Add (Create) operation +const add = async (req, res, next) => { + // Extract the child data from the request body + const child = req.body; + + try { + // Insert the child into the database + const insertId = await tables.child.create(child); + + // Respond with HTTP 201 (Created) and the ID of the newly inserted child + res.status(201).json({ insertId }); + } catch (err) { + res.status(500).json({ message: "hello fredo" }); + next(err); + } +}; + +// The D of BREAD - Destroy (Delete) operation +// This operation is not yet implemented +const destroy = async (req, res, next) => { + try { + const [result] = await tables.child.delete(req.params.id); + + if (result.affectedRows) { + res.sendStatus(204); + } else { + res.sendStatus(404); + } + } catch (err) { + res.status(500).json({ message: "Couldn't delete" }); + next(); + } +}; + +// Ready to export the controller functions +module.exports = { + browse, + read, + edit, + add, + destroy, +}; diff --git a/backend/src/controllers/reservationControllers.js b/backend/src/controllers/reservationControllers.js new file mode 100644 index 0000000..dd480cb --- /dev/null +++ b/backend/src/controllers/reservationControllers.js @@ -0,0 +1,109 @@ +// Import access to database tables +const tables = require("../tables"); + +// The B of BREAD - Browse (Read All) operation +const browse = async (req, res, next) => { + try { + // Fetch all reservation from the database + const reservation = await tables.reservations.readAll(); + + // Respond with the reservation in JSON format + res.json(reservation); + } catch (err) { + // Pass any errors to the error-handling middleware + next(err); + } +}; + +// The R of BREAD - Read operation +const read = async (req, res, next) => { + try { + // Fetch a specific reservation from the database based on the provided ID + const reservation = await tables.reservation.read(req.params.id); + + // If the reservation is not found, respond with HTTP 404 (Not Found) + // Otherwise, respond with the reservation in JSON format + if (reservation == null) { + res.sendStatus(404); + } else { + res.json(reservation); + } + } catch (err) { + // Pass any errors to the error-handling middleware + next(err); + } +}; + +// The E of BREAD - Edit (Update) operation +// This operation is not yet implemented +const edit = async (req, res, next) => { + const { id } = req.params; + const firstName = req.body.first_name; + const lastName = req.body.last_name; + const dateOfBirth = req.body.date_of_birth; + const { walker } = req.body; + const { allergies } = req.body; + const { alimentation } = req.body; + try { + const reservationResult = await tables.reservation.update( + id, + firstName, + lastName, + dateOfBirth, + walker, + allergies, + alimentation + ); + + if (reservationResult.affectedRows === 0) { + res.sendStatus(404); + } else { + res.sendStatus(204); + } + } catch (err) { + next(err); + } +}; + +// The A of BREAD - Add (Create) operation +const add = async (req, res, next) => { + // Extract the reservation data from the request body + const reservation = req.body; + + try { + // Insert the reservation into the database + const insertId = await tables.reservation.create(reservation); + + // Respond with HTTP 201 (Created) and the ID of the newly inserted reservation + res.status(201).json({ insertId }); + } catch (err) { + res.status(500).json({ message: "Error with server" }); + next(err); + } +}; + +// The D of BREAD - Destroy (Delete) operation +// This operation is not yet implemented +const destroy = async (req, res, next) => { + try { + const [result] = await tables.reservation.delete(req.params.id); + + if (result.affectedRows) { + res.sendStatus(204); + } else { + res.sendStatus(404); + } + } catch (err) { + res.status(500).json({ message: "Error with server" }); + next(); + } +}; + +// Ready to export the controller functions +module.exports = { + browse, + read, + edit, + add, + destroy, +}; diff --git a/backend/src/models/ChildManager.js b/backend/src/models/ChildManager.js new file mode 100644 index 0000000..585cacf --- /dev/null +++ b/backend/src/models/ChildManager.js @@ -0,0 +1,103 @@ +const AbstractManager = require("./AbstractManager"); + +class ChildManager extends AbstractManager { + constructor() { + // Call the constructor of the parent class (AbstractManager) + // and pass the table name "child" as configuration + super({ table: "child" }); + } + + // The C of CRUD - Create operation + + async create({ + firstName, + lastName, + dateOfBirth, + walker, + nameOfDoctor, + allergies, + alimentation, + }) { + // Execute the SQL INSERT query to add a new item to the "child" table + const [rows] = await this.database.query( + `INSERT INTO ${this.table} (first_name, last_name, date_of_birth, walker, name_of_doctor, allergies, alimentation) VALUES (?,?,?,?,?,?,?)`, + [ + firstName, + lastName, + dateOfBirth, + walker, + nameOfDoctor, + allergies, + alimentation, + ] + ); + + // Return the ID of the newly inserted child + return rows.insertId; + } + + // The Rs of CRUD - Read operations + + async read(id) { + // Execute the SQL SELECT query to retrieve a specific child by its ID + const [rows] = await this.database.query( + `SELECT * FROM ${this.table} WHERE id = ?`, + [id] + ); + + // Return the first row of the result, which represents the child + return [rows]; + } + + async readAll() { + // Execute the SQL SELECT query to retrieve all items from the "child" table + const [rows] = await this.database.query(`SELECT * FROM ${this.table}`); + + // Return the array of items + return [rows]; + } + + // The U of CRUD - Update operation + // TODO: Implement the update operation to modify an existing child + + async update( + id, + firstName, + lastName, + dateOfBirth, + walker, + nameOfDoctor, + allergies, + alimentation + ) { + const [rows] = await this.database.query( + `UPDATE ${this.table} SET first_name= ?, last_name= ?, date_of_birth= ?, walker= ?, name_of_doctor= ?, allergies= ?, alimentation= ? WHERE id= ?`, + [ + firstName, + lastName, + dateOfBirth, + walker, + nameOfDoctor, + allergies, + alimentation, + id, + ] + ); + + return [rows]; + } + + // The D of CRUD - Delete operation + // TODO: Implement the delete operation to remove an child by its ID + + async delete(id) { + const [rows] = await this.database.query( + `DELETE FROM movies where id = ?", [id]`, + [id] + ); + + return [rows]; + } +} + +module.exports = ChildManager; diff --git a/backend/src/router.js b/backend/src/router.js index 38f375d..5221255 100644 --- a/backend/src/router.js +++ b/backend/src/router.js @@ -6,17 +6,15 @@ const router = express.Router(); // Define Your API Routes Here /* ************************************************************************* */ -// Import itemControllers module for handling item-related operations -const itemControllers = require("./controllers/itemControllers"); - -// Route to get a list of items -router.get("/items", itemControllers.browse); - -// Route to get a specific item by ID -router.get("/items/:id", itemControllers.read); - -// Route to add a new item -router.post("/items", itemControllers.add); +// Import Controllers module for handling all-related operations +const childControllers = require("./controllers/childControllers"); + +// child +router.get("/child", childControllers.browse); +router.get("/child/:id", childControllers.read); +router.put("/child/:id", childControllers.edit); +router.post("/child", childControllers.add); +router.delete("/child/:id", childControllers.destroy); /* ************************************************************************* */ diff --git a/backend/src/tables.js b/backend/src/tables.js index 66d032c..a6141ef 100644 --- a/backend/src/tables.js +++ b/backend/src/tables.js @@ -3,10 +3,10 @@ /* ************************************************************************* */ // Import the manager modules responsible for handling data operations on the tables -const ItemManager = require("./models/ItemManager"); +const ChildManager = require("./models/ChildManager"); const managers = [ - ItemManager, + ChildManager, // Add other managers here ]; From 39c21f200e9c31b4ec1275705fa55d31bf99ae5f Mon Sep 17 00:00:00 2001 From: Pras Date: Wed, 20 Dec 2023 18:10:46 +0100 Subject: [PATCH 06/15] update crud for child --- backend/src/app.js | 26 ++++++++++++-------------- backend/src/models/ChildManager.js | 6 +++--- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/backend/src/app.js b/backend/src/app.js index 4252c41..2edb828 100644 --- a/backend/src/app.js +++ b/backend/src/app.js @@ -25,19 +25,17 @@ const app = express(); // 4. Be sure to only have URLs in the array with domains from which you want to allow requests. // For example: ["http://mysite.com", "http://another-domain.com"] -/* -const cors = require("cors"); - -app.use( - cors({ - origin: [ - process.env.FRONTEND_URL, // keep this one, after checking the value in `backend/.env` - "http://mysite.com", - "http://another-domain.com", - ] - }) -); -*/ +// const cors = require("cors"); + +// app.use( +// cors({ +// origin: [ +// process.env.FRONTEND_URL, // keep this one, after checking the value in `backend/.env` +// "http://mysite.com", +// "http://another-domain.com", +// ], +// }) +// ); /* ************************************************************************* */ @@ -54,7 +52,7 @@ app.use( // Uncomment one or more of these options depending on the format of the data sent by your client: -// app.use(express.json()); +app.use(express.json()); // app.use(express.urlencoded()); // app.use(express.text()); // app.use(express.raw()); diff --git a/backend/src/models/ChildManager.js b/backend/src/models/ChildManager.js index 585cacf..ebd87f0 100644 --- a/backend/src/models/ChildManager.js +++ b/backend/src/models/ChildManager.js @@ -61,14 +61,14 @@ class ChildManager extends AbstractManager { // TODO: Implement the update operation to modify an existing child async update( - id, firstName, lastName, dateOfBirth, walker, nameOfDoctor, allergies, - alimentation + alimentation, + id ) { const [rows] = await this.database.query( `UPDATE ${this.table} SET first_name= ?, last_name= ?, date_of_birth= ?, walker= ?, name_of_doctor= ?, allergies= ?, alimentation= ? WHERE id= ?`, @@ -92,7 +92,7 @@ class ChildManager extends AbstractManager { async delete(id) { const [rows] = await this.database.query( - `DELETE FROM movies where id = ?", [id]`, + `DELETE FROM ${this.table} where id = ?`, [id] ); From a22bd80cf5da41661aea4a1d7b097e50f5228123 Mon Sep 17 00:00:00 2001 From: Paul-DELESQUES Date: Wed, 20 Dec 2023 21:54:27 +0100 Subject: [PATCH 07/15] debug eslint router and table --- backend/src/router.js | 1 - backend/src/tables.js | 1 - 2 files changed, 2 deletions(-) diff --git a/backend/src/router.js b/backend/src/router.js index 8358555..cecc48f 100644 --- a/backend/src/router.js +++ b/backend/src/router.js @@ -18,7 +18,6 @@ router.put("/child/:id", childControllers.edit); router.post("/child", childControllers.add); router.delete("/child/:id", childControllers.destroy); - // parents router.get("/parents", parentsControllers.browse); diff --git a/backend/src/tables.js b/backend/src/tables.js index 62cadf6..3fee59b 100644 --- a/backend/src/tables.js +++ b/backend/src/tables.js @@ -8,7 +8,6 @@ const ParentsManager = require("./models/ParentsManager"); const StructureManager = require("./models/StructureManager"); const ChildManager = require("./models/ChildManager"); - const managers = [ ParentsManager, StructureManager, From 11bc4ed09181a1357b492c395b218018fabd6995 Mon Sep 17 00:00:00 2001 From: Paul-DELESQUES Date: Wed, 20 Dec 2023 22:26:45 +0100 Subject: [PATCH 08/15] add controller + model + routes for table documents --- .../src/controllers/documentsController.js | 95 +++++++++++++++++++ backend/src/models/DocumentsManager.js | 93 ++++++++++++++++++ backend/src/router.js | 8 ++ backend/src/tables.js | 2 + 4 files changed, 198 insertions(+) create mode 100644 backend/src/controllers/documentsController.js create mode 100644 backend/src/models/DocumentsManager.js diff --git a/backend/src/controllers/documentsController.js b/backend/src/controllers/documentsController.js new file mode 100644 index 0000000..cb6ac81 --- /dev/null +++ b/backend/src/controllers/documentsController.js @@ -0,0 +1,95 @@ +// Import access to database tables +const tables = require("../tables"); + +// The B of BREAD - Browse (Read All) operation +const browse = async (req, res, next) => { + try { + // Fetch all items from the database + const document = await tables.documents.readAll(); + + // Respond with the documents in JSON format + res.json(document); + } catch (err) { + // Pass any errors to the error-handling middleware + next(err); + } +}; + +// The R of BREAD - Read operation +const read = async (req, res, next) => { + try { + // Fetch a specific item from the database based on the provided ID + const document = await tables.documents.read(req.params.id); + + // If the item is not found, respond with HTTP 404 (Not Found) + // Otherwise, respond with the item in JSON format + if (document == null) { + res.sendStatus(404); + } else { + res.json(document); + } + } catch (err) { + // Pass any errors to the error-handling middleware + next(err); + } +}; + +// The E of BREAD - Edit (Update) operation +const edit = async (req, res, next) => { + try { + const { id } = req.params; + const document = req.body; + const [result] = await tables.documents.update({ id, ...document }); + + if (result.affectedRows === 0) { + res.sendStatus(404); + } else { + res.sendStatus(204); + } + } catch (err) { + res.sendStatus(500); + next(err); + } +}; + +// The A of BREAD - Add (Create) operation +const add = async (req, res, next) => { + // Extract the item data from the request body + const document = req.body; + try { + // Insert the documents into the database + const insertId = await tables.documents.create(document); + + // Respond with HTTP 201 (Created) and the ID of the newly inserted item + res.status(201).json({ insertId }); + } catch (err) { + // Pass any errors to the error-handling middleware + next(err); + } +}; + +// The D of BREAD - Destroy (Delete) operation +const destroy = async (req, res, next) => { + const { id } = req.params; + try { + const [result] = await tables.documents.delete(id); + + if (result.affectedRows === 0) { + res.sendStatus(404); + } else { + res.sendStatus(204); + } + } catch (err) { + res.sendStatus(500); + next(err); + } +}; + +// Ready to export the controller functions +module.exports = { + browse, + read, + edit, + add, + destroy, +}; diff --git a/backend/src/models/DocumentsManager.js b/backend/src/models/DocumentsManager.js new file mode 100644 index 0000000..240b23d --- /dev/null +++ b/backend/src/models/DocumentsManager.js @@ -0,0 +1,93 @@ +const AbstractManager = require("./AbstractManager"); + +class DocumentsManager extends AbstractManager { + constructor() { + // Call the constructor of the parent class (AbstractManager) + // and pass the table name "item" as configuration + super({ table: "documents" }); + } + + // The C of CRUD - Create operation + + async create({ + reservationFolderId, + documentTypeId, + added, + uploadDate, + fileName, + storagePath, + type, + origin, + }) { + // Execute the SQL INSERT query to add a new item to the "item" table + const [rows] = await this.database.query( + `INSERT INTO ${this.table} (reservation_folder_id, document_type_id, added, upload_date, file_name, storage_path, type, origin) VALUES (?,?,?,?,?,?,?,?)`, + [ + reservationFolderId, + documentTypeId, + added, + uploadDate, + fileName, + storagePath, + type, + origin, + ] + ); + + // Return the ID of the newly inserted item + return rows.insertId; + } + + // The Rs of CRUD - Read operations + + async read(id) { + // Execute the SQL SELECT query to retrieve a specific item by its ID + const [rows] = await this.database.query( + `SELECT * FROM ${this.table} WHERE id = ?`, + [id] + ); + + // Return the first row of the rows, which represents the item + return rows[0]; + } + + async readAll() { + // Execute the SQL SELECT query to retrieve all items from the "item" table + const [rows] = await this.database.query(`SELECT * FROM ${this.table}`); + + // Return the array of items + return rows; + } + + // The U of CRUD - Update operation + // TODO: Implement the update operation to modify an existing item + + async update({ + documentTypeId, + added, + uploadDate, + fileName, + storagePath, + type, + origin, + }) { + const [rows] = await this.database.query( + ` UPDATE ${this.table} SET document_type_id = ?, added = ?, upload_date = ?, file_name = ?, storage_path = ?, type = ?, origin = ?`, + [documentTypeId, added, uploadDate, fileName, storagePath, type, origin] + ); + return [rows]; + } + + // The D of CRUD - Delete operation + // TODO: Implement the delete operation to remove an item by its ID + + async delete(id) { + const [rows] = await this.database.query( + `DELETE FROM ${this.table} WHERE id = ?`, + [id] + ); + return [rows]; + } +} + +module.exports = DocumentsManager; diff --git a/backend/src/router.js b/backend/src/router.js index cecc48f..83c1ff7 100644 --- a/backend/src/router.js +++ b/backend/src/router.js @@ -10,6 +10,7 @@ const router = express.Router(); const childControllers = require("./controllers/childControllers"); const parentsControllers = require("./controllers/parentsController"); const structuresControllers = require("./controllers/stucturesControllers"); +const documentsControllers = require("./controllers/documentsController"); // child router.get("/child", childControllers.browse); @@ -34,6 +35,13 @@ router.post("/structures", structuresControllers.add); router.put("/structures/:id", structuresControllers.edit); router.delete("/structures/:id", structuresControllers.destroy); +// documents + +router.get("/documents", documentsControllers.browse); +router.get("/documents/:id", documentsControllers.read); +router.post("/documents", documentsControllers.add); +router.put("/documents/:id", documentsControllers.edit); +router.delete("/documents/:id", documentsControllers.destroy); /* ************************************************************************* */ module.exports = router; diff --git a/backend/src/tables.js b/backend/src/tables.js index 3fee59b..bade718 100644 --- a/backend/src/tables.js +++ b/backend/src/tables.js @@ -7,11 +7,13 @@ const ParentsManager = require("./models/ParentsManager"); const StructureManager = require("./models/StructureManager"); const ChildManager = require("./models/ChildManager"); +const DocumentsManager = require("./models/DocumentsManager"); const managers = [ ParentsManager, StructureManager, ChildManager, + DocumentsManager, // Add other managers here ]; From e460d7a955bf24758133b529cc943bc4746a8744 Mon Sep 17 00:00:00 2001 From: Charles Proust Date: Wed, 20 Dec 2023 23:29:58 +0100 Subject: [PATCH 09/15] add users, assignments, disponibilities - controller, manager, router --- backend/database/schema.sql | 12 +- backend/src/app.js | 2 +- .../src/controllers/assignmentsControllers.js | 81 ++++++++++ .../controllers/disponibilitiesControllers.js | 87 ++++++++++ backend/src/controllers/itemControllers.js | 67 -------- backend/src/controllers/usersControllers.js | 77 +++++++++ backend/src/models/AssignmentsManager.js | 50 ++++++ backend/src/models/DisponibilitiesManager.js | 63 ++++++++ backend/src/models/ItemManager.js | 59 ------- backend/src/models/UsersManager.js | 84 ++++++++++ backend/src/router.js | 40 +++-- backend/src/tables.js | 8 +- backend/tests/items/manager.spec.js | 37 ----- backend/tests/items/routes.spec.js | 149 ------------------ backend/tests/setup.js | 16 -- 15 files changed, 486 insertions(+), 346 deletions(-) create mode 100644 backend/src/controllers/assignmentsControllers.js create mode 100644 backend/src/controllers/disponibilitiesControllers.js delete mode 100644 backend/src/controllers/itemControllers.js create mode 100644 backend/src/controllers/usersControllers.js create mode 100644 backend/src/models/AssignmentsManager.js create mode 100644 backend/src/models/DisponibilitiesManager.js delete mode 100644 backend/src/models/ItemManager.js create mode 100644 backend/src/models/UsersManager.js delete mode 100644 backend/tests/items/manager.spec.js delete mode 100644 backend/tests/items/routes.spec.js delete mode 100644 backend/tests/setup.js diff --git a/backend/database/schema.sql b/backend/database/schema.sql index 3ad52c2..e554412 100644 --- a/backend/database/schema.sql +++ b/backend/database/schema.sql @@ -39,7 +39,7 @@ create table parents ( phone_number varchar(15), email varchar(100), profession varchar(100), - constraint fk_parents_users foreign key (user_id) references users(id) ON DELETE CASCADE + constraint fk_parents_users foreign key (user_id) references users(id) ON DELETE CASCADE ON UPDATE CASCADE ); create table child ( @@ -52,7 +52,7 @@ create table child ( name_of_doctor varchar(100), allergies text, alimentation enum('All', 'Vegan', 'Vegetarian', 'Halal', 'Kosher'), - constraint fk_child_parents foreign key (parents_id) references parents(id) ON DELETE CASCADE + constraint fk_child_parents foreign key (parents_id) references parents(id) ON DELETE CASCADE ON UPDATE CASCADE ); create table structures ( @@ -70,7 +70,7 @@ create table structures ( welcomes text, experiences text, prices decimal(10,2), - constraint fk_structures_users foreign key (user_id) references users(id) ON DELETE CASCADE + constraint fk_structures_users foreign key (user_id) references users(id) ON DELETE CASCADE ON UPDATE CASCADE ); create table employees ( @@ -82,6 +82,7 @@ create table employees ( max_children_capacity int, constraint fk_employees_structures foreign key (structure_id) references structures(id) ON DELETE CASCADE + ON UPDATE CASCADE ); create table documents ( @@ -122,6 +123,7 @@ create table employees_disponibilities ( number_of_places int, constraint fk_employees_disponibilities_employees foreign key (employee_id) references employees(id) ON DELETE CASCADE + ON UPDATE CASCADE ); create table employees_assignments ( @@ -130,7 +132,9 @@ create table employees_assignments ( employee_id int, constraint fk_employees_assignements_employees foreign key (employee_id) references employees(id) ON DELETE CASCADE +ON UPDATE CASCADE ); alter table documents -add constraint fk_documents_reservation foreign key (reservation_folder_id) references reservation(id); \ No newline at end of file +add constraint fk_documents_reservation foreign key (reservation_folder_id) references reservation(id) ON DELETE CASCADE +ON UPDATE CASCADE; \ No newline at end of file diff --git a/backend/src/app.js b/backend/src/app.js index 4252c41..1f07560 100644 --- a/backend/src/app.js +++ b/backend/src/app.js @@ -54,7 +54,7 @@ app.use( // Uncomment one or more of these options depending on the format of the data sent by your client: -// app.use(express.json()); +app.use(express.json()); // app.use(express.urlencoded()); // app.use(express.text()); // app.use(express.raw()); diff --git a/backend/src/controllers/assignmentsControllers.js b/backend/src/controllers/assignmentsControllers.js new file mode 100644 index 0000000..1361c6b --- /dev/null +++ b/backend/src/controllers/assignmentsControllers.js @@ -0,0 +1,81 @@ +const tables = require("../tables"); + +// B + +const browse = async (req, res, next) => { + try { + const assignements = await tables.employees_assignments.readAll(); + res.json(assignements); + } catch (err) { + next(err); + } +}; + +// R +const read = async (req, res, next) => { + try { + const assignement = await tables.employees_assignments.read(req.params.id); + if (assignement == null) { + res.sendStatus(404); + } else { + res.json(assignement); + } + } catch (err) { + next(err); + } +}; + +// E +const edit = async (req, res, next) => { + try { + const { id } = req.params; + const assignement = req.body; + const [result] = await tables.employees_assignments.update({ + id, + ...assignement, + }); + + if (result.affectedRows === 0) { + res.sendStatus(404); + } else { + res.sendStatus(204); + } + } catch (err) { + res.sendStatus(500); + next(err); + } +}; + +// A +const add = async (req, res, next) => { + const assignement = req.body; + try { + const insertId = await tables.employees_assignments.create(assignement); + res.status(201).json({ insertId }); + } catch (err) { + next(err); + } +}; + +// D +const destroy = async (req, res, next) => { + try { + const [result] = await tables.employees_assignments.delete(req.params.id); + if (result.affectedRows) { + res.sendStatus(204); + } else { + res.sendStatus(404); + } + } catch (err) { + res.status(500).json({ message: "Couldn't delete" }); + next(); + } +}; + +module.exports = { + browse, + read, + edit, + add, + destroy, +}; diff --git a/backend/src/controllers/disponibilitiesControllers.js b/backend/src/controllers/disponibilitiesControllers.js new file mode 100644 index 0000000..faa9b85 --- /dev/null +++ b/backend/src/controllers/disponibilitiesControllers.js @@ -0,0 +1,87 @@ +const tables = require("../tables"); + +// B + +const browse = async (req, res, next) => { + try { + const disponibilities = await tables.employees_disponibilities.readAll(); + res.json(disponibilities); + } catch (err) { + next(err); + } +}; + +// R +const read = async (req, res, next) => { + try { + const disponibility = await tables.employees_disponibilities.read( + req.params.id + ); + if (disponibility == null) { + res.sendStatus(404); + } else { + res.json(disponibility); + } + } catch (err) { + next(err); + } +}; + +// E +const edit = async (req, res, next) => { + try { + const { id } = req.params; + const disponibility = req.body; + const [result] = await tables.employees_disponibilities.update({ + id, + ...disponibility, + }); + + if (result.affectedRows === 0) { + res.sendStatus(404); + } else { + res.sendStatus(204); + } + } catch (err) { + res.sendStatus(500); + next(err); + } +}; + +// A +const add = async (req, res, next) => { + const disponibility = req.body; + try { + const insertId = await tables.employees_disponibilities.create( + disponibility + ); + res.status(201).json({ insertId }); + } catch (err) { + next(err); + } +}; + +// D +const destroy = async (req, res, next) => { + try { + const [result] = await tables.employees_disponibilities.delete( + req.params.id + ); + if (result.affectedRows) { + res.sendStatus(204); + } else { + res.sendStatus(404); + } + } catch (err) { + res.status(500).json({ message: "Couldn't delete" }); + next(); + } +}; + +module.exports = { + browse, + read, + edit, + add, + destroy, +}; diff --git a/backend/src/controllers/itemControllers.js b/backend/src/controllers/itemControllers.js deleted file mode 100644 index fca2dc2..0000000 --- a/backend/src/controllers/itemControllers.js +++ /dev/null @@ -1,67 +0,0 @@ -// Import access to database tables -const tables = require("../tables"); - -// The B of BREAD - Browse (Read All) operation -const browse = async (req, res, next) => { - try { - // Fetch all items from the database - const items = await tables.item.readAll(); - - // Respond with the items in JSON format - res.json(items); - } catch (err) { - // Pass any errors to the error-handling middleware - next(err); - } -}; - -// The R of BREAD - Read operation -const read = async (req, res, next) => { - try { - // Fetch a specific item from the database based on the provided ID - const item = await tables.item.read(req.params.id); - - // If the item is not found, respond with HTTP 404 (Not Found) - // Otherwise, respond with the item in JSON format - if (item == null) { - res.sendStatus(404); - } else { - res.json(item); - } - } catch (err) { - // Pass any errors to the error-handling middleware - next(err); - } -}; - -// The E of BREAD - Edit (Update) operation -// This operation is not yet implemented - -// The A of BREAD - Add (Create) operation -const add = async (req, res, next) => { - // Extract the item data from the request body - const item = req.body; - - try { - // Insert the item into the database - const insertId = await tables.item.create(item); - - // Respond with HTTP 201 (Created) and the ID of the newly inserted item - res.status(201).json({ insertId }); - } catch (err) { - // Pass any errors to the error-handling middleware - next(err); - } -}; - -// The D of BREAD - Destroy (Delete) operation -// This operation is not yet implemented - -// Ready to export the controller functions -module.exports = { - browse, - read, - // edit, - add, - // destroy, -}; diff --git a/backend/src/controllers/usersControllers.js b/backend/src/controllers/usersControllers.js new file mode 100644 index 0000000..891abe6 --- /dev/null +++ b/backend/src/controllers/usersControllers.js @@ -0,0 +1,77 @@ +const tables = require("../tables"); + +// B +const browse = async (req, res, next) => { + try { + const users = await tables.users.readAll(); + res.json(users); + } catch (err) { + next(err); + } +}; + +// R +const read = async (req, res, next) => { + try { + const user = await tables.users.read(req.params.id); + if (user == null) { + res.sendStatus(404); + } else { + res.json(user); + } + } catch (err) { + next(err); + } +}; + +// E +const edit = async (req, res, next) => { + try { + const { id } = req.params; + const user = req.body; + const [result] = await tables.users.update({ id, ...user }); + + if (result.affectedRows === 0) { + res.sendStatus(404); + } else { + res.sendStatus(204); + } + } catch (err) { + res.sendStatus(500); + next(err); + } +}; + +// A +const add = async (req, res, next) => { + const users = req.body; + try { + const insertId = await tables.users.create(users); + res.status(201).json({ insertId }); + } catch (err) { + next(err); + } +}; + +// D +const destroy = async (req, res, next) => { + try { + const [result] = await tables.users.delete(req.params.id); + if (result.affectedRows) { + res.sendStatus(204); + } else { + res.sendStatus(404); + } + } catch (err) { + res.status(500).json({ message: "Couldn't delete" }); + next(); + } +}; + +module.exports = { + browse, + read, + edit, + add, + destroy, +}; diff --git a/backend/src/models/AssignmentsManager.js b/backend/src/models/AssignmentsManager.js new file mode 100644 index 0000000..7907ba3 --- /dev/null +++ b/backend/src/models/AssignmentsManager.js @@ -0,0 +1,50 @@ +const AbstractManager = require("./AbstractManager"); + +class assignmentsManager extends AbstractManager { + constructor() { + super({ table: "employees_assignments" }); + } + + // C + async create({ reservationId }) { + const [rows] = await this.database.query( + `INSERT INTO ${this.table} (reservation_id) VALUES (?)`, + [reservationId] + ); + return rows.insertId; + } + + // R + async read(id) { + const [rows] = await this.database.query( + `SELECT * FROM ${this.table} WHERE id = ?`, + [id] + ); + return rows[0]; + } + + async readAll() { + const [rows] = await this.database.query(`SELECT * FROM ${this.table}`); + return rows; + } + + // U + async update({ reservationId, employeeId, id }) { + const [rows] = await this.database.query( + `UPDATE ${this.table} SET reservation_id=?, employee_id=? WHERE id=?`, + [reservationId, employeeId, id] + ); + return [rows]; + } + + // D + async delete(id) { + const [rows] = await this.database.query( + `DELETE FROM ${this.table} WHERE id = ?`, + [id] + ); + return [rows]; + } +} + +module.exports = assignmentsManager; diff --git a/backend/src/models/DisponibilitiesManager.js b/backend/src/models/DisponibilitiesManager.js new file mode 100644 index 0000000..957d5e1 --- /dev/null +++ b/backend/src/models/DisponibilitiesManager.js @@ -0,0 +1,63 @@ +const AbstractManager = require("./AbstractManager"); + +class disponibilitiesManager extends AbstractManager { + constructor() { + super({ table: "employees_disponibilities" }); + } + + // C + async create({ + employeeId, + availableDate, + startTime, + endTime, + numberOfPlaces, + }) { + const [rows] = await this.database.query( + `INSERT INTO ${this.table} (employee_id, available_date, start_time, end_time, number_of_places) VALUES (?,?,?,?,?)`, + [employeeId, availableDate, startTime, endTime, numberOfPlaces] + ); + return rows.insertId; + } + + // R + async read(id) { + const [rows] = await this.database.query( + `SELECT * FROM ${this.table} WHERE id = ?`, + [id] + ); + return rows[0]; + } + + async readAll() { + const [rows] = await this.database.query(`SELECT * FROM ${this.table}`); + return rows; + } + + // U + async update({ + employeeId, + availableDate, + startTime, + endTime, + numberOfPlaces, + id, + }) { + const [rows] = await this.database.query( + `UPDATE ${this.table} SET employee_id=?, available_date=?, start_time=?, end_time=?, number_of_places=? WHERE id=?`, + [employeeId, availableDate, startTime, endTime, numberOfPlaces, id] + ); + return [rows]; + } + + // D + async delete(id) { + const [rows] = await this.database.query( + `DELETE FROM ${this.table} WHERE id = ?`, + [id] + ); + return [rows]; + } +} + +module.exports = disponibilitiesManager; diff --git a/backend/src/models/ItemManager.js b/backend/src/models/ItemManager.js deleted file mode 100644 index eeeae9f..0000000 --- a/backend/src/models/ItemManager.js +++ /dev/null @@ -1,59 +0,0 @@ -const AbstractManager = require("./AbstractManager"); - -class ItemManager extends AbstractManager { - constructor() { - // Call the constructor of the parent class (AbstractManager) - // and pass the table name "item" as configuration - super({ table: "item" }); - } - - // The C of CRUD - Create operation - - async create(item) { - // Execute the SQL INSERT query to add a new item to the "item" table - const [result] = await this.database.query( - `insert into ${this.table} (title) values (?)`, - [item.title] - ); - - // Return the ID of the newly inserted item - return result.insertId; - } - - // The Rs of CRUD - Read operations - - async read(id) { - // Execute the SQL SELECT query to retrieve a specific item by its ID - const [rows] = await this.database.query( - `select * from ${this.table} where id = ?`, - [id] - ); - - // Return the first row of the result, which represents the item - return rows[0]; - } - - async readAll() { - // Execute the SQL SELECT query to retrieve all items from the "item" table - const [rows] = await this.database.query(`select * from ${this.table}`); - - // Return the array of items - return rows; - } - - // The U of CRUD - Update operation - // TODO: Implement the update operation to modify an existing item - - // async update(item) { - // ... - // } - - // The D of CRUD - Delete operation - // TODO: Implement the delete operation to remove an item by its ID - - // async delete(id) { - // ... - // } -} - -module.exports = ItemManager; diff --git a/backend/src/models/UsersManager.js b/backend/src/models/UsersManager.js new file mode 100644 index 0000000..ab8a660 --- /dev/null +++ b/backend/src/models/UsersManager.js @@ -0,0 +1,84 @@ +const AbstractManager = require("./AbstractManager"); + +class usersManager extends AbstractManager { + constructor() { + super({ table: "users" }); + } + + // C + async create({ + email, + password, + profile, + confirmationInscription, + confirmationDateSent, + createdDate, + lastConnection, + }) { + const [rows] = await this.database.query( + `INSERT INTO ${this.table} (email, password, profile, confirmation_inscription, confirmation_date_sent, created_date, last_connection) VALUES (?,?,?,?,?,?,?)`, + [ + email, + password, + profile, + confirmationInscription, + confirmationDateSent, + createdDate, + lastConnection, + ] + ); + return rows.insertId; + } + + // R + async read(id) { + const [rows] = await this.database.query( + `SELECT * FROM ${this.table} WHERE id = ?`, + [id] + ); + return rows[0]; + } + + async readAll() { + const [rows] = await this.database.query(`SELECT * FROM ${this.table}`); + return rows; + } + + // U + async update({ + email, + password, + profile, + confirmationInscription, + confirmationDateSent, + createdDate, + lastConnection, + id, + }) { + const [rows] = await this.database.query( + `UPDATE ${this.table} SET email=?, password=?, profile=?, confirmation_inscription=?, confirmation_date_sent=?, created_date=?, last_connection=? WHERE id=?`, + [ + email, + password, + profile, + confirmationInscription, + confirmationDateSent, + createdDate, + lastConnection, + id, + ] + ); + return [rows]; + } + + // D + async delete(id) { + const [rows] = await this.database.query( + `DELETE FROM ${this.table} WHERE id = ?`, + [id] + ); + return [rows]; + } +} + +module.exports = usersManager; diff --git a/backend/src/router.js b/backend/src/router.js index 38f375d..7273afb 100644 --- a/backend/src/router.js +++ b/backend/src/router.js @@ -6,17 +6,35 @@ const router = express.Router(); // Define Your API Routes Here /* ************************************************************************* */ -// Import itemControllers module for handling item-related operations -const itemControllers = require("./controllers/itemControllers"); - -// Route to get a list of items -router.get("/items", itemControllers.browse); - -// Route to get a specific item by ID -router.get("/items/:id", itemControllers.read); - -// Route to add a new item -router.post("/items", itemControllers.add); +// Import userControllers module for handling user-related operations +const usersControllers = require("./controllers/usersControllers"); +const assignmentsControllers = require("./controllers/assignmentsControllers"); +const disponibilitiesControllers = require("./controllers/disponibilitiesControllers"); + +// Route to get a list of users +router.get("/users", usersControllers.browse); +router.get("/assignments", assignmentsControllers.browse); +router.get("/disponibilities", disponibilitiesControllers.browse); + +// Route to get a specific user by ID +router.get("/users/:id", usersControllers.read); +router.get("/assignments/:id", assignmentsControllers.read); +router.get("/disponibilities/:id", disponibilitiesControllers.read); + +// Route to add a new user +router.post("/users", usersControllers.add); +router.post("/assignments", assignmentsControllers.add); +router.post("/disponibilities", disponibilitiesControllers.add); + +// Route to edit a user +router.put("/users/:id", usersControllers.edit); +router.put("/assignments/:id", assignmentsControllers.edit); +router.put("/disponibilities/:id", disponibilitiesControllers.edit); + +// Route to destroy user +router.delete("/users/:id", usersControllers.destroy); +router.delete("/assignments/:id", assignmentsControllers.destroy); +router.delete("/disponibilities/:id", disponibilitiesControllers.destroy); /* ************************************************************************* */ diff --git a/backend/src/tables.js b/backend/src/tables.js index 66d032c..38cd72b 100644 --- a/backend/src/tables.js +++ b/backend/src/tables.js @@ -3,10 +3,14 @@ /* ************************************************************************* */ // Import the manager modules responsible for handling data operations on the tables -const ItemManager = require("./models/ItemManager"); +const UsersManager = require("./models/UsersManager"); +const AssignmentsManager = require("./models/AssignmentsManager"); +const DisponibilitiesManager = require("./models/DisponibilitiesManager"); const managers = [ - ItemManager, + UsersManager, + AssignmentsManager, + DisponibilitiesManager, // Add other managers here ]; diff --git a/backend/tests/items/manager.spec.js b/backend/tests/items/manager.spec.js deleted file mode 100644 index 612a9f6..0000000 --- a/backend/tests/items/manager.spec.js +++ /dev/null @@ -1,37 +0,0 @@ -// Import required dependencies -const { database, tables } = require("../setup"); - -// Test suite for the create method of ItemManager -describe("Create item", () => { - it("should create an item successfully", async () => { - // Define a sample item for testing - const testItem = { - title: "Sample Item", - }; - - // Send a create request to the item table with a test item - const insertId = await tables.item.create(testItem); - - // Check if the newly added item exists in the database - const [rows] = await database.query( - "select * from item where id = ?", - insertId - ); - - const foundItem = rows[0]; - - // Assertions - expect(foundItem).toBeDefined(); - expect(foundItem.title).toBe(testItem.title); - }); - - it("should throw when passing invalid object", async () => { - // Thx https://jestjs.io/docs/asynchronous#asyncawait - - // Send a create request to the item table with an empty object - const promise = tables.item.create({}); - - // Assertions - await expect(promise).rejects.toThrow(); - }); -}); diff --git a/backend/tests/items/routes.spec.js b/backend/tests/items/routes.spec.js deleted file mode 100644 index d539c04..0000000 --- a/backend/tests/items/routes.spec.js +++ /dev/null @@ -1,149 +0,0 @@ -// Import required dependencies -const { app, request, tables } = require("../setup"); - -// Test suite for the GET /api/items route -describe("GET /api/items", () => { - it("should fetch items successfully", async () => { - // Define a sample item for testing - const testItem = { - title: "Sample Item", - }; - - // Create a sample item in the database - const insertId = await tables.item.create(testItem); - - // Send a GET request to the /api/items endpoint - const response = await request(app).get("/api/items"); - - // Assertions - expect(response.status).toBe(200); - expect(response.body).toBeInstanceOf(Array); - - // Check if the created item is present in the response - const foundItem = response.body.find((item) => item.id === insertId); - - // Assertions - expect(foundItem).toBeInstanceOf(Object); - expect(foundItem.title).toBe(testItem.title); - }); -}); - -// Test suite for the GET /api/items/:id route -describe("GET /api/items/:id", () => { - it("should fetch a single item successfully", async () => { - // Define a sample item for testing - const testItem = { - title: "Sample Item", - }; - - // Create a sample item in the database - const insertId = await tables.item.create(testItem); - - // Send a GET request to the /api/items/:id endpoint - const response = await request(app).get(`/api/items/${insertId}`); - - // Assertions - expect(response.status).toBe(200); - expect(response.body).toBeInstanceOf(Object); - expect(response.body.id).toBe(insertId); - expect(response.body.title).toBe(testItem.title); - }); - - it("should return 404 for non-existent item", async () => { - // Send a GET request to the /api/items/:id endpoint with an invalid ID - const response = await request(app).get("/api/items/0"); - - // Assertions - expect(response.status).toBe(404); - expect(response.body).toEqual({}); - }); -}); - -// Test suite for the POST /api/items route -// Doesn't pass: maybe something to change in app config :/ -// Hint: enabling log could help ;) -describe("POST /api/items", () => { - it("should add a new item successfully", async () => { - // Define a sample item for testing - const testItem = { - title: "Sample Item", - }; - - // Send a POST request to the /api/items endpoint with a test item - const response = await request(app).post("/api/items").send(testItem); - - // Assertions - expect(response.status).toBe(201); - expect(response.body).toBeInstanceOf(Object); - expect(response.body.insertId).toEqual(expect.any(Number)); - - // Check if the newly added item exists in the database - const foundItem = await tables.item.read(response.body.insertId); - - // Assertions - expect(foundItem).toBeDefined(); - expect(foundItem.title).toBe(testItem.title); - }); -}); - -// TODO: implement PUT and DELETE routes - -/* -// Test suite for the PUT /api/items/:id route -describe("PUT /api/items/:id", () => { - it("should update an existing item successfully", async () => { - // Define a sample item for testing - const testItem = { - title: "Sample Item", - }; - - // Create a sample item in the database - const insertId = await tables.item.create(testItem); - - // Define an updated item object - const updatedItem = { - title: "Updated Item", - }; - - // Send a PUT request to the /api/items/:id endpoint with updated data - const response = await request(app) - .put(`/api/items/${insertId}`) - .send(updatedItem); - - // Assertions - expect(response.status).toBe(204); - - // Check if the item has been updated in the database - const foundItem = await tables.item.read(insertId); - - // Assertions - expect(foundItem).toBeDefined(); - expect(foundItem.title).toBe(updatedItem.title); - }); -}); - -// Test suite for the DELETE /api/items/:id route -describe("DELETE /api/items/:id", () => { - it("should delete an existing item successfully", async () => { - // Define a sample item for testing - const testItem = { - title: "Sample Item", - }; - - // Create a sample item in the database - const insertId = await tables.item.create(testItem); - - // Send a DELETE request to the /api/items/:id endpoint - const response = await request(app).delete(`/api/items/${insertId}`); - - // Assertions - expect(response.status).toBe(204); - - // Check if the item has been deleted from the database - const foundItem = await tables.item.read(insertId); - - // Assertions - expect(foundItem).toBeUndefined(); - }); -}); -*/ diff --git a/backend/tests/setup.js b/backend/tests/setup.js deleted file mode 100644 index 73be7c0..0000000 --- a/backend/tests/setup.js +++ /dev/null @@ -1,16 +0,0 @@ -/* eslint import/no-extraneous-dependencies: ["error", {"devDependencies": true}] */ - -// Load environment variables from .env file -require("dotenv").config(); - -const request = require("supertest"); - -const app = require("../src/app"); -const tables = require("../src/tables"); -const database = require("../database/client"); - -afterAll((done) => { - database.end().then(done); -}); - -module.exports = { app, database, request, tables }; From 0b68649c178b6a698f7ec11c67a2bed421f9a33b Mon Sep 17 00:00:00 2001 From: Paul-DELESQUES <145282675+Paul-DELESQUES@users.noreply.github.com> Date: Thu, 21 Dec 2023 00:04:18 +0100 Subject: [PATCH 10/15] Update router.js delete unnecessary line --- backend/src/router.js | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/src/router.js b/backend/src/router.js index 2cee283..695371c 100644 --- a/backend/src/router.js +++ b/backend/src/router.js @@ -6,7 +6,6 @@ const router = express.Router(); // Define Your API Routes Here /* ************************************************************************* */ - // Import Controllers module for handling all-related operations const usersControllers = require("./controllers/usersControllers"); const assignmentsControllers = require("./controllers/assignmentsControllers"); From f31ab4b13bdded9a0cdca9d99d4f1d298ca8a27d Mon Sep 17 00:00:00 2001 From: Pras Date: Thu, 21 Dec 2023 12:15:06 +0100 Subject: [PATCH 11/15] update reservation --- backend/src/controllers/childControllers.js | 27 ++++++--------------- backend/src/models/ChildManager.js | 6 ++--- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/backend/src/controllers/childControllers.js b/backend/src/controllers/childControllers.js index d413257..fb147f4 100644 --- a/backend/src/controllers/childControllers.js +++ b/backend/src/controllers/childControllers.js @@ -37,30 +37,19 @@ const read = async (req, res, next) => { // The E of BREAD - Edit (Update) operation // This operation is not yet implemented const edit = async (req, res, next) => { - const { id } = req.params; - const firstName = req.body.first_name; - const lastName = req.body.last_name; - const dateOfBirth = req.body.date_of_birth; - const { walker } = req.body; - const { allergies } = req.body; - const { alimentation } = req.body; try { - const childResult = await tables.child.update( - id, - firstName, - lastName, - dateOfBirth, - walker, - allergies, - alimentation - ); - - if (childResult.affectedRows === 0) { + const child = req.body; + const { id } = req.params; + const [result] = await tables.child.update({ ...child, id }); + if (result.affectedRows === 0) { res.sendStatus(404); } else { res.sendStatus(204); } + next(); } catch (err) { + console.error(err); + res.status(500); next(err); } }; @@ -77,7 +66,7 @@ const add = async (req, res, next) => { // Respond with HTTP 201 (Created) and the ID of the newly inserted child res.status(201).json({ insertId }); } catch (err) { - res.status(500).json({ message: "hello fredo" }); + res.status(500).json({ message: "Added a baby" }); next(err); } }; diff --git a/backend/src/models/ChildManager.js b/backend/src/models/ChildManager.js index ebd87f0..f713536 100644 --- a/backend/src/models/ChildManager.js +++ b/backend/src/models/ChildManager.js @@ -60,7 +60,7 @@ class ChildManager extends AbstractManager { // The U of CRUD - Update operation // TODO: Implement the update operation to modify an existing child - async update( + async update({ firstName, lastName, dateOfBirth, @@ -68,8 +68,8 @@ class ChildManager extends AbstractManager { nameOfDoctor, allergies, alimentation, - id - ) { + id, + }) { const [rows] = await this.database.query( `UPDATE ${this.table} SET first_name= ?, last_name= ?, date_of_birth= ?, walker= ?, name_of_doctor= ?, allergies= ?, alimentation= ? WHERE id= ?`, [ From 4e7f1eeb359f07bdcdfcb32bdace929765c10913 Mon Sep 17 00:00:00 2001 From: Pras Date: Thu, 21 Dec 2023 13:15:00 +0100 Subject: [PATCH 12/15] update table reservation and child --- .../src/controllers/reservationControllers.js | 54 ++++------ backend/src/models/ChildManager.js | 4 +- backend/src/models/ReservationManager.js | 98 +++++++++++++++++++ backend/src/router.js | 8 ++ backend/src/tables.js | 2 + 5 files changed, 130 insertions(+), 36 deletions(-) create mode 100644 backend/src/models/ReservationManager.js diff --git a/backend/src/controllers/reservationControllers.js b/backend/src/controllers/reservationControllers.js index dd480cb..8aa5573 100644 --- a/backend/src/controllers/reservationControllers.js +++ b/backend/src/controllers/reservationControllers.js @@ -5,7 +5,7 @@ const tables = require("../tables"); const browse = async (req, res, next) => { try { // Fetch all reservation from the database - const reservation = await tables.reservations.readAll(); + const reservation = await tables.reservation.readAll(); // Respond with the reservation in JSON format res.json(reservation); @@ -18,11 +18,11 @@ const browse = async (req, res, next) => { // The R of BREAD - Read operation const read = async (req, res, next) => { try { - // Fetch a specific reservation from the database based on the provided ID + // Fetch a specific item from the database based on the provided ID const reservation = await tables.reservation.read(req.params.id); - // If the reservation is not found, respond with HTTP 404 (Not Found) - // Otherwise, respond with the reservation in JSON format + // If the item is not found, respond with HTTP 404 (Not Found) + // Otherwise, respond with the item in JSON format if (reservation == null) { res.sendStatus(404); } else { @@ -35,71 +35,57 @@ const read = async (req, res, next) => { }; // The E of BREAD - Edit (Update) operation -// This operation is not yet implemented const edit = async (req, res, next) => { - const { id } = req.params; - const firstName = req.body.first_name; - const lastName = req.body.last_name; - const dateOfBirth = req.body.date_of_birth; - const { walker } = req.body; - const { allergies } = req.body; - const { alimentation } = req.body; try { - const reservationResult = await tables.reservation.update( - id, - firstName, - lastName, - dateOfBirth, - walker, - allergies, - alimentation - ); + const { id } = req.params; + const reservation = req.body; + const [result] = await tables.reservation.update({ id, ...reservation }); - if (reservationResult.affectedRows === 0) { + if (result.affectedRows === 0) { res.sendStatus(404); } else { res.sendStatus(204); } } catch (err) { + res.sendStatus(500); next(err); } }; // The A of BREAD - Add (Create) operation const add = async (req, res, next) => { - // Extract the reservation data from the request body + // Extract the item data from the request body const reservation = req.body; - try { // Insert the reservation into the database const insertId = await tables.reservation.create(reservation); - // Respond with HTTP 201 (Created) and the ID of the newly inserted reservation + // Respond with HTTP 201 (Created) and the ID of the newly inserted item res.status(201).json({ insertId }); } catch (err) { - res.status(500).json({ message: "Error with server" }); + res.status(500).json({ message: "Can't add any reservation" }); next(err); } }; // The D of BREAD - Destroy (Delete) operation -// This operation is not yet implemented const destroy = async (req, res, next) => { + const { id } = req.params; try { - const [result] = await tables.reservation.delete(req.params.id); + const [result] = await tables.reservation.delete(id); - if (result.affectedRows) { - res.sendStatus(204); - } else { + if (result.affectedRows === 0) { res.sendStatus(404); + } else { + res.sendStatus(204); } } catch (err) { - res.status(500).json({ message: "Error with server" }); - next(); + res.status(500).json({ message: "Couldn't delete" }); + next(err); } }; -// Ready to export the controller functions +// Ready to export the controller function module.exports = { browse, read, diff --git a/backend/src/models/ChildManager.js b/backend/src/models/ChildManager.js index f713536..4e35861 100644 --- a/backend/src/models/ChildManager.js +++ b/backend/src/models/ChildManager.js @@ -46,7 +46,7 @@ class ChildManager extends AbstractManager { ); // Return the first row of the result, which represents the child - return [rows]; + return rows[0]; } async readAll() { @@ -54,7 +54,7 @@ class ChildManager extends AbstractManager { const [rows] = await this.database.query(`SELECT * FROM ${this.table}`); // Return the array of items - return [rows]; + return rows; } // The U of CRUD - Update operation diff --git a/backend/src/models/ReservationManager.js b/backend/src/models/ReservationManager.js new file mode 100644 index 0000000..9926673 --- /dev/null +++ b/backend/src/models/ReservationManager.js @@ -0,0 +1,98 @@ +const AbstractManager = require("./AbstractManager"); + +class ReservationManager extends AbstractManager { + constructor() { + // Call the constructor of the parent class (AbstractManager) + // and pass the table name "reservation" as configuration + super({ table: "reservation" }); + } + + // The C of CRUD - Create operation + + async create({ + status, + rejectionReason, + reservationDate, + startTime, + endTime, + createdDate, + }) { + // Execute the SQL INSERT query to add a new item to the "reservation" table + const [rows] = await this.database.query( + `INSERT INTO ${this.table} (status, rejection_reason, reservation_date, start_time, end_time, created_date) VALUES (?,?,?,?,?,?)`, + [ + status, + rejectionReason, + reservationDate, + startTime, + endTime, + createdDate, + ] + ); + + // Return the ID of the newly inserted reservation + return rows.insertId; + } + + // The Rs of CRUD - Read operations + + async read(id) { + // Execute the SQL SELECT query to retrieve a specific item by its ID + const [rows] = await this.database.query( + `SELECT * FROM ${this.table} WHERE id = ?`, + [id] + ); + + // Return the first row of the rows, which represents the item + return rows[0]; + } + + async readAll() { + // Execute the SQL SELECT query to retrieve all items from the "item" table + const [rows] = await this.database.query(`SELECT * FROM ${this.table}`); + + // Return the array of items + return rows; + } + + // The U of CRUD - Update operation + // TODO: Implement the update operation to modify an existing reservation + + async update({ + status, + rejectionReason, + reservationDate, + startTime, + endTime, + createdDate, + id, + }) { + const [rows] = await this.database.query( + ` UPDATE ${this.table} SET status = ?, rejection_reason = ?, reservation_date = ?, start_time = ?, end_time = ?, created_date = ? WHERE id = ?`, + [ + status, + rejectionReason, + reservationDate, + startTime, + endTime, + createdDate, + id, + ] + ); + return [rows]; + } + + // The D of CRUD - Delete operation + // TODO: Implement the delete operation to remove a reservation by its ID + + async delete(id) { + const [rows] = await this.database.query( + `DELETE FROM ${this.table} where id = ?`, + [id] + ); + + return [rows]; + } +} + +module.exports = ReservationManager; diff --git a/backend/src/router.js b/backend/src/router.js index cecc48f..5103101 100644 --- a/backend/src/router.js +++ b/backend/src/router.js @@ -10,6 +10,7 @@ const router = express.Router(); const childControllers = require("./controllers/childControllers"); const parentsControllers = require("./controllers/parentsController"); const structuresControllers = require("./controllers/stucturesControllers"); +const reservationControllers = require("./controllers/reservationControllers"); // child router.get("/child", childControllers.browse); @@ -34,6 +35,13 @@ router.post("/structures", structuresControllers.add); router.put("/structures/:id", structuresControllers.edit); router.delete("/structures/:id", structuresControllers.destroy); +// reservation + +router.get("/reservation", reservationControllers.browse); +router.get("/reservation/:id", reservationControllers.read); +router.put("/reservation/:id", reservationControllers.edit); +router.post("/reservation", reservationControllers.add); +router.delete("/reservation/:id", reservationControllers.destroy); /* ************************************************************************* */ module.exports = router; diff --git a/backend/src/tables.js b/backend/src/tables.js index 3fee59b..214a8ef 100644 --- a/backend/src/tables.js +++ b/backend/src/tables.js @@ -7,11 +7,13 @@ const ParentsManager = require("./models/ParentsManager"); const StructureManager = require("./models/StructureManager"); const ChildManager = require("./models/ChildManager"); +const ReservationManager = require("./models/ReservationManager"); const managers = [ ParentsManager, StructureManager, ChildManager, + ReservationManager, // Add other managers here ]; From 1e27b24cf04bc108dd13c2f8cf3e3cd8281145f1 Mon Sep 17 00:00:00 2001 From: Sadjoaldi Date: Thu, 21 Dec 2023 17:08:09 +0100 Subject: [PATCH 13/15] tableau employees done --- backend/src/app.js | 2 +- .../src/controllers/employeesControllers.js | 90 +++++++++++++++++++ backend/src/controllers/itemControllers.js | 67 -------------- backend/src/models/EmployeesManager.js | 66 ++++++++++++++ backend/src/models/ItemManager.js | 59 ------------ backend/src/router.js | 16 ++-- backend/src/tables.js | 5 +- 7 files changed, 168 insertions(+), 137 deletions(-) create mode 100644 backend/src/controllers/employeesControllers.js delete mode 100644 backend/src/controllers/itemControllers.js create mode 100644 backend/src/models/EmployeesManager.js delete mode 100644 backend/src/models/ItemManager.js diff --git a/backend/src/app.js b/backend/src/app.js index 4252c41..1f07560 100644 --- a/backend/src/app.js +++ b/backend/src/app.js @@ -54,7 +54,7 @@ app.use( // Uncomment one or more of these options depending on the format of the data sent by your client: -// app.use(express.json()); +app.use(express.json()); // app.use(express.urlencoded()); // app.use(express.text()); // app.use(express.raw()); diff --git a/backend/src/controllers/employeesControllers.js b/backend/src/controllers/employeesControllers.js new file mode 100644 index 0000000..161436b --- /dev/null +++ b/backend/src/controllers/employeesControllers.js @@ -0,0 +1,90 @@ +// Import access to database tables +const tables = require("../tables"); + +// The B of BREAD - Browse (Read All) operation +const browse = async (req, res, next) => { + try { + const employee = await tables.employees.readAll(); + + res.json(employee); + } catch (err) { + next(err); + } +}; + +// The Read of BREAD +const read = async (req, res, next) => { + try { + const emp = await tables.employees.read(req.params.id); + + if (emp == null) { + res.sendStatus(404); + } else { + res.json(emp); + } + } catch (err) { + next(err); + } +}; + +// The E of BREAD - Edit (Update) operation +const edit = async (req, res, next) => { + try { + const { id } = req.params; + const emply = req.body; + const [result] = await tables.employees.update({ ...emply, id }); + + if (result.affectedRows === 0) { + res.sendStatus(404); + } else { + res.sendStatus(204); + } + } catch (err) { + res.status(500); + next(err); + } +}; + +// The A of BREAD - Add +const add = async (req, res, next) => { + // Extract the item data from the request body + const employees = req.body; + + try { + // Insert the item into the database + const insertId = await tables.employees.create(employees); + + // Respond with HTTP 201 (Created) and the ID of the newly inserted item + res.status(201).json({ insertId }); + } catch (err) { + // Pass any errors to the error-handling middleware + next(err); + } +}; + +// Delete = Destroy + +const destroy = (req, res, next) => { + tables.employees + .delete(req.params.id) + .then(([result]) => { + if (result.rows === 0) { + res.sendStatus(404); + } else { + res.sendStatus(204); + } + }) + .catch((err) => { + next(err); + res.sendStatus(500); + }); +}; + +// Ready to export the controller functions +module.exports = { + browse, + read, + edit, + add, + destroy, +}; diff --git a/backend/src/controllers/itemControllers.js b/backend/src/controllers/itemControllers.js deleted file mode 100644 index fca2dc2..0000000 --- a/backend/src/controllers/itemControllers.js +++ /dev/null @@ -1,67 +0,0 @@ -// Import access to database tables -const tables = require("../tables"); - -// The B of BREAD - Browse (Read All) operation -const browse = async (req, res, next) => { - try { - // Fetch all items from the database - const items = await tables.item.readAll(); - - // Respond with the items in JSON format - res.json(items); - } catch (err) { - // Pass any errors to the error-handling middleware - next(err); - } -}; - -// The R of BREAD - Read operation -const read = async (req, res, next) => { - try { - // Fetch a specific item from the database based on the provided ID - const item = await tables.item.read(req.params.id); - - // If the item is not found, respond with HTTP 404 (Not Found) - // Otherwise, respond with the item in JSON format - if (item == null) { - res.sendStatus(404); - } else { - res.json(item); - } - } catch (err) { - // Pass any errors to the error-handling middleware - next(err); - } -}; - -// The E of BREAD - Edit (Update) operation -// This operation is not yet implemented - -// The A of BREAD - Add (Create) operation -const add = async (req, res, next) => { - // Extract the item data from the request body - const item = req.body; - - try { - // Insert the item into the database - const insertId = await tables.item.create(item); - - // Respond with HTTP 201 (Created) and the ID of the newly inserted item - res.status(201).json({ insertId }); - } catch (err) { - // Pass any errors to the error-handling middleware - next(err); - } -}; - -// The D of BREAD - Destroy (Delete) operation -// This operation is not yet implemented - -// Ready to export the controller functions -module.exports = { - browse, - read, - // edit, - add, - // destroy, -}; diff --git a/backend/src/models/EmployeesManager.js b/backend/src/models/EmployeesManager.js new file mode 100644 index 0000000..56389b3 --- /dev/null +++ b/backend/src/models/EmployeesManager.js @@ -0,0 +1,66 @@ +const AbstractManager = require("./AbstractManager"); + +class EmployeesManager extends AbstractManager { + constructor() { + super({ table: "employees" }); + } + + // Create + async create({ + structureId, + firstName, + lastName, + qualification, + maxChildrenCapacity, + }) { + const [rows] = await this.database.query( + `INSERT INTO ${this.table} (structure_id, first_name,last_name,qualification,max_children_capacity) VALUES (?,?,?,?,?)`, + [structureId, firstName, lastName, qualification, maxChildrenCapacity] + ); + + return rows.insertId; + } + + // Read + + async read(id) { + const [rows] = await this.database.query( + `SELECT * FROM ${this.table} WHERE id = ?`, + [id] + ); + + return rows[0]; + } + + async readAll() { + const [rows] = await this.database.query(`SELECT * FROM ${this.table}`); + + return rows; + } + + // Update + async update({ + firstName, + lastName, + qualification, + maxChildrenCapacity, + id, + }) { + const [rows] = await this.database.query( + `UPDATE ${this.table} SET first_name = ?, last_name = ?, qualification = ?, max_children_capacity = ? WHERE id = ?`, + [firstName, lastName, qualification, maxChildrenCapacity, id] + ); + return [rows]; + } + + // Delete + async delete(id) { + const [rows] = await this.database.query( + `DELETE FROM ${this.table} WHERE id = ?`, + [id] + ); + return [rows]; + } +} + +module.exports = EmployeesManager; diff --git a/backend/src/models/ItemManager.js b/backend/src/models/ItemManager.js deleted file mode 100644 index eeeae9f..0000000 --- a/backend/src/models/ItemManager.js +++ /dev/null @@ -1,59 +0,0 @@ -const AbstractManager = require("./AbstractManager"); - -class ItemManager extends AbstractManager { - constructor() { - // Call the constructor of the parent class (AbstractManager) - // and pass the table name "item" as configuration - super({ table: "item" }); - } - - // The C of CRUD - Create operation - - async create(item) { - // Execute the SQL INSERT query to add a new item to the "item" table - const [result] = await this.database.query( - `insert into ${this.table} (title) values (?)`, - [item.title] - ); - - // Return the ID of the newly inserted item - return result.insertId; - } - - // The Rs of CRUD - Read operations - - async read(id) { - // Execute the SQL SELECT query to retrieve a specific item by its ID - const [rows] = await this.database.query( - `select * from ${this.table} where id = ?`, - [id] - ); - - // Return the first row of the result, which represents the item - return rows[0]; - } - - async readAll() { - // Execute the SQL SELECT query to retrieve all items from the "item" table - const [rows] = await this.database.query(`select * from ${this.table}`); - - // Return the array of items - return rows; - } - - // The U of CRUD - Update operation - // TODO: Implement the update operation to modify an existing item - - // async update(item) { - // ... - // } - - // The D of CRUD - Delete operation - // TODO: Implement the delete operation to remove an item by its ID - - // async delete(id) { - // ... - // } -} - -module.exports = ItemManager; diff --git a/backend/src/router.js b/backend/src/router.js index 38f375d..2005ca2 100644 --- a/backend/src/router.js +++ b/backend/src/router.js @@ -7,17 +7,17 @@ const router = express.Router(); /* ************************************************************************* */ // Import itemControllers module for handling item-related operations -const itemControllers = require("./controllers/itemControllers"); -// Route to get a list of items -router.get("/items", itemControllers.browse); +const employeesControllers = require("./controllers/employeesControllers"); -// Route to get a specific item by ID -router.get("/items/:id", itemControllers.read); - -// Route to add a new item -router.post("/items", itemControllers.add); +// Route for employees +router.get("/employees", employeesControllers.browse); +router.get("/employees/:id", employeesControllers.read); +router.put("/employees/:id", employeesControllers.edit); +router.post("/employees", employeesControllers.add); +router.delete("/employees/:id", employeesControllers.destroy); +// Route for documents /* ************************************************************************* */ module.exports = router; diff --git a/backend/src/tables.js b/backend/src/tables.js index 66d032c..41468dc 100644 --- a/backend/src/tables.js +++ b/backend/src/tables.js @@ -3,10 +3,11 @@ /* ************************************************************************* */ // Import the manager modules responsible for handling data operations on the tables -const ItemManager = require("./models/ItemManager"); + +const EmployeesManager = require("./models/EmployeesManager"); const managers = [ - ItemManager, + EmployeesManager, // Add other managers here ]; From fa630f5a4bf2f0f9e9c71a63eae6c218bca75152 Mon Sep 17 00:00:00 2001 From: Paul-DELESQUES <145282675+Paul-DELESQUES@users.noreply.github.com> Date: Thu, 21 Dec 2023 17:23:39 +0100 Subject: [PATCH 14/15] Update router.js delete uncessary line --- backend/src/router.js | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/src/router.js b/backend/src/router.js index 2923f12..6de78e1 100644 --- a/backend/src/router.js +++ b/backend/src/router.js @@ -17,7 +17,6 @@ const reservationControllers = require("./controllers/reservationControllers"); const documentsControllers = require("./controllers/documentsController"); const employeesControllers = require("./controllers/employeesControllers"); - // users router.get("/users", usersControllers.browse); router.get("/users/:id", usersControllers.read); From 838ad3ee9c9ffe7b028d3fba577c173000e95e95 Mon Sep 17 00:00:00 2001 From: Paul-DELESQUES <145282675+Paul-DELESQUES@users.noreply.github.com> Date: Thu, 21 Dec 2023 17:23:56 +0100 Subject: [PATCH 15/15] Update tables.js delete uncessary line --- backend/src/tables.js | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/src/tables.js b/backend/src/tables.js index 666855a..8c9d62c 100644 --- a/backend/src/tables.js +++ b/backend/src/tables.js @@ -14,7 +14,6 @@ const AssignmentsManager = require("./models/AssignmentsManager"); const DisponibilitiesManager = require("./models/DisponibilitiesManager"); const EmployeesManager = require("./models/EmployeesManager"); - const managers = [ ParentsManager, StructureManager,