Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M update instructor #58

Open
wants to merge 12 commits into
base: leapcode_w22
Choose a base branch
from
15 changes: 15 additions & 0 deletions api/db/knexDb.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const util = require('util');
require('dotenv').config();

const knex = require('knex') ({
client: 'mysql',
connection: {
host: process.env.CLOUD_DB_IP,
user: process.env.CLOUD_DB_DEV_USERNAME,
password: process.env.CLOUD_DB_DEV_PASSWORD,
database: process.env.CLOUD_DB_NAME,
debug: false
}
});

module.exports = knex;
4 changes: 2 additions & 2 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"dotenv": "^8.2.0",
"express": "~4.16.1",
"faker": "^5.5.2",
"firebase-admin": "^9.9.0",
"firebase-admin": "^4.2.1",
"http-errors": "~1.6.3",
"jade": "~1.11.0",
"jade": "^0.29.0",
"morgan": "~1.9.1",
"mysql2": "^2.2.5",
"nodemon": "^2.0.7"
Expand Down
3 changes: 2 additions & 1 deletion client/src/api/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { saveSeason, loadAllSeason } from "./season";
import { savePartner, loadPartnersAggregated, deletePartner, updatePartner } from "./partner";
import { saveProgram, loadProgramsAggregated, deleteProgram } from "./program";
import { loadAllInstructorsAggregated, saveInstructor, deleteInstructor } from "./instructor";
import { loadAllInstructorsAggregated, saveInstructor, deleteInstructor, updateInstructor } from "./instructor";

export {
saveSeason,
Expand All @@ -12,6 +12,7 @@ export {
loadProgramsAggregated,
loadAllInstructorsAggregated,
saveInstructor,
updateInstructor,
deleteInstructor,
deleteProgram,
deletePartner,
Expand Down
13 changes: 13 additions & 0 deletions client/src/api/instructor 2.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ export const saveInstructor = async (instructorData) => {
}
}

// for updating in sideinfo
export const updateInstructor = async (instructorData) => {
try{
const header = await createToken();
// need to get instructorID for the axios put request.
await axios.put(`/api/instructor/${instructorData.instructorId}`, instructorData, header);
toast(`👍 Instructor ${instructorData.firstName} ${instructorData.lastName} updated successfully!`)
} catch (e) {
console.log(e);
toast(`❌ ${e}`);
}
}

export const deleteInstructor = async (instructorId) => {
try {
const header = await createToken();
Expand Down
13 changes: 13 additions & 0 deletions client/src/api/instructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ export const saveInstructor = async (instructorData) => {
}
}

// for updating in sideinfo
export const updateInstructor = async (instructorId , instructorData) => {
try{
const header = await createToken();
// need to get instructorID for the axios put request.
await axios.put(`/api/instructor/${instructorId}`, instructorData, header);
toast(`👍 Instructor ${instructorData.firstName} ${instructorData.lastName} updated successfully!`)
} catch (e) {
console.log(e);
toast(`❌ ${e}`);
}
}

export const deleteInstructor = async (instructorId) => {
try {
const header = await createToken();
Expand Down
5 changes: 3 additions & 2 deletions client/src/components/AddInstructorManuallyModal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ export default function AddInstructorManuallyModal({handleSubmit}) {
}
}
})

// testing if we need availability id in the object
console.log(parsed);
setFormInput({...formInput, availability: parsed})
};

Expand Down Expand Up @@ -252,7 +253,7 @@ export default function AddInstructorManuallyModal({handleSubmit}) {
<tr>
<th></th>
<th>Mondays</th>
<th>Tuedays</th>
<th>Tuesdays</th>
<th>Wednesdays</th>
<th>Thursdays</th>
<th>Fridays</th>
Expand Down
Loading