From 2d00cba280928a9da85831eade08a05f70038f89 Mon Sep 17 00:00:00 2001 From: aminalakhsham Date: Sat, 5 Oct 2019 16:45:50 +0300 Subject: [PATCH 1/3] fix teacher profile bug --- client/src/components/common/TeacherTable/index.js | 3 ++- client/src/components/pages/TeacherProfile/index.js | 1 + server/database/config/build.sql | 1 - server/database/config/fakedata.sql | 8 ++++---- server/database/quieres/subjectPage.js | 1 + server/database/quieres/teacherProfile.js | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/client/src/components/common/TeacherTable/index.js b/client/src/components/common/TeacherTable/index.js index 4a7a099..21bd28f 100644 --- a/client/src/components/common/TeacherTable/index.js +++ b/client/src/components/common/TeacherTable/index.js @@ -14,6 +14,7 @@ export default class TeacherTable extends React.Component { }, } = this.props; axios.get(`/api/v1/student/${id}`).then(res => { + console.log(res); this.setState({ data: res.data }); }); } @@ -38,7 +39,7 @@ export default class TeacherTable extends React.Component { first_name: firstName, last_name: lastName, subject_name: subjectName, - teacher_id: id, + user_id: id, subject_id: subjectId, class: classId, }) => ( diff --git a/client/src/components/pages/TeacherProfile/index.js b/client/src/components/pages/TeacherProfile/index.js index a2e5b38..e19ffde 100644 --- a/client/src/components/pages/TeacherProfile/index.js +++ b/client/src/components/pages/TeacherProfile/index.js @@ -22,6 +22,7 @@ class TeacherProfile extends Component { }, } = this.props; axios.get(`/api/v1/profile/teacher/${id}`).then(result => { + console.log(result); this.setState({ data: result.data[0] }); }); } diff --git a/server/database/config/build.sql b/server/database/config/build.sql index 7b7f7f5..f4a0b31 100644 --- a/server/database/config/build.sql +++ b/server/database/config/build.sql @@ -24,7 +24,6 @@ CREATE TABLE teacher( bio text, image_url text, mobile INTEGER, - email VARCHAR(255), interest text, FOREIGN KEY (user_id) REFERENCES "user"(id) ); diff --git a/server/database/config/fakedata.sql b/server/database/config/fakedata.sql index d136077..9cba0ba 100644 --- a/server/database/config/fakedata.sql +++ b/server/database/config/fakedata.sql @@ -21,10 +21,10 @@ VALUES INSERT INTO teacher (first_name,last_name,user_id, bio, image_url, mobile, email, interest) VALUES - ('Ahmed','Ghareb',5, 'Hi Iam Ahmed Ghareb Iam a teacher in Gaza Primary School you can contact me', 'https://cdn4.iconfinder.com/data/icons/BRILLIANT/accounting/png/400/executive.png',0599542154,'ahm-214@gmail.com','Reading novels'), - ('Ali','Taha',6, 'Hi Iam Ali Taha Iam a teacher in Gaza Primary School you can contact me', 'https://cdn4.iconfinder.com/data/icons/BRILLIANT/accounting/png/400/executive.png',0599542154,'ahm-214@gmail.com','Reading novels'), - ('Arwa','Omar',7, 'Hi Iam Arwa Omar Iam a teacher in Gaza Primary School you can contact me', 'https://cdn4.iconfinder.com/data/icons/BRILLIANT/accounting/png/400/executive.png',0599542154,'ahm-214@gmail.com','Reading novels'), - ('Hala','salah',8, 'Hi Iam Hala Salah Iam a teacher in Gaza Primary School you can contact me', 'https://cdn4.iconfinder.com/data/icons/BRILLIANT/accounting/png/400/executive.png',0599542154,'ahm-214@gmail.com','Reading novels'); + ('Ahmed','Ghareb',5, 'Hi Iam Ahmed Ghareb Iam a teacher in Gaza Primary School you can contact me', 'https://cdn4.iconfinder.com/data/icons/BRILLIANT/accounting/png/400/executive.png',0599542154,'Reading novels'), + ('Ali','Taha',6, 'Hi Iam Ali Taha Iam a teacher in Gaza Primary School you can contact me', 'https://cdn4.iconfinder.com/data/icons/BRILLIANT/accounting/png/400/executive.png',0599542154,'Reading novels'), + ('Arwa','Omar',7, 'Hi Iam Arwa Omar Iam a teacher in Gaza Primary School you can contact me', 'https://cdn4.iconfinder.com/data/icons/BRILLIANT/accounting/png/400/executive.png',0599542154,'Reading novels'), + ('Hala','salah',8, 'Hi Iam Hala Salah Iam a teacher in Gaza Primary School you can contact me', 'https://cdn4.iconfinder.com/data/icons/BRILLIANT/accounting/png/400/executive.png',0599542154,'Reading novels'); INSERT INTO student (student_name,class,parent_id) diff --git a/server/database/quieres/subjectPage.js b/server/database/quieres/subjectPage.js index e674013..48f8475 100644 --- a/server/database/quieres/subjectPage.js +++ b/server/database/quieres/subjectPage.js @@ -4,6 +4,7 @@ const subject = (id) => { const sql = { text: ` select subject_teacher.teacher_id , + teacher.user_id , teacher.last_name , teacher.first_name , subject_teacher.subject_id , diff --git a/server/database/quieres/teacherProfile.js b/server/database/quieres/teacherProfile.js index 657e0aa..3a9ac27 100644 --- a/server/database/quieres/teacherProfile.js +++ b/server/database/quieres/teacherProfile.js @@ -1,7 +1,7 @@ const connection = require('../config/connection'); const getTeacherProfile = (id) => connection.query( - 'select first_name, last_name, bio, image_url, mobile, teacher.email, interest from teacher inner join "user" on teacher.user_id="user".id where "user".id=$1 ', + 'select first_name, last_name, bio, image_url, mobile, "user".email, interest from teacher inner join "user" on teacher.user_id="user".id where teacher.user_id=$1 ', [id], ); From f58e9bf452cf12feed277513c4489e5dc90efa0f Mon Sep 17 00:00:00 2001 From: aminalakhsham Date: Sat, 5 Oct 2019 16:46:23 +0300 Subject: [PATCH 2/3] fix teacher profile bug --- client/src/components/common/TeacherTable/index.js | 1 - client/src/components/pages/TeacherProfile/index.js | 1 - 2 files changed, 2 deletions(-) diff --git a/client/src/components/common/TeacherTable/index.js b/client/src/components/common/TeacherTable/index.js index 21bd28f..fb12b36 100644 --- a/client/src/components/common/TeacherTable/index.js +++ b/client/src/components/common/TeacherTable/index.js @@ -14,7 +14,6 @@ export default class TeacherTable extends React.Component { }, } = this.props; axios.get(`/api/v1/student/${id}`).then(res => { - console.log(res); this.setState({ data: res.data }); }); } diff --git a/client/src/components/pages/TeacherProfile/index.js b/client/src/components/pages/TeacherProfile/index.js index e19ffde..a2e5b38 100644 --- a/client/src/components/pages/TeacherProfile/index.js +++ b/client/src/components/pages/TeacherProfile/index.js @@ -22,7 +22,6 @@ class TeacherProfile extends Component { }, } = this.props; axios.get(`/api/v1/profile/teacher/${id}`).then(result => { - console.log(result); this.setState({ data: result.data[0] }); }); } From d52493452ed9e5c82c05af4167842f557dc0a9a9 Mon Sep 17 00:00:00 2001 From: aminalakhsham Date: Sat, 5 Oct 2019 16:51:48 +0300 Subject: [PATCH 3/3] fix test --- server/database/config/fakedata.sql | 2 +- test/routes/subjecrPage.test.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/server/database/config/fakedata.sql b/server/database/config/fakedata.sql index 9cba0ba..8c9dc56 100644 --- a/server/database/config/fakedata.sql +++ b/server/database/config/fakedata.sql @@ -19,7 +19,7 @@ VALUES (0127893456, 4); INSERT INTO teacher - (first_name,last_name,user_id, bio, image_url, mobile, email, interest) + (first_name,last_name,user_id, bio, image_url, mobile, interest) VALUES ('Ahmed','Ghareb',5, 'Hi Iam Ahmed Ghareb Iam a teacher in Gaza Primary School you can contact me', 'https://cdn4.iconfinder.com/data/icons/BRILLIANT/accounting/png/400/executive.png',0599542154,'Reading novels'), ('Ali','Taha',6, 'Hi Iam Ali Taha Iam a teacher in Gaza Primary School you can contact me', 'https://cdn4.iconfinder.com/data/icons/BRILLIANT/accounting/png/400/executive.png',0599542154,'Reading novels'), diff --git a/test/routes/subjecrPage.test.js b/test/routes/subjecrPage.test.js index ea0c37e..748d075 100644 --- a/test/routes/subjecrPage.test.js +++ b/test/routes/subjecrPage.test.js @@ -9,6 +9,7 @@ test('Test subject Page', (t) => { const expected = { teacher_id: 1, last_name: 'Ghareb', + user_id: 5, first_name: 'Ahmed', subject_id: 1, subject_name: 'English',