Skip to content

Commit

Permalink
Feature Toggle API Changes and Integrated to Note Operation Screens |…
Browse files Browse the repository at this point in the history
… SIS-148 (#60)

* START_DATE and END_DATE Fields Changes in Feature Toggle API Has Been Integrated to Feature Toggle Listing Page

* MIDTERM_NOTE_OPERATIONS, FINAL_NOTE_OPERATIONS and RESIT_NOTE_OPERATIONS Enums Have Been Added to FeatureToggleName.js File

* Feature Toggle Controller Has Been Integrated to Teacher My Lessons Page

* Feature Toggle Controller Has Been Integrated to Teacher Lesson Notes Page
  • Loading branch information
agitrubard authored Mar 27, 2022
1 parent 10a6df7 commit 7a86995
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 8 deletions.
16 changes: 13 additions & 3 deletions pages/officer/operation/university/feature-toggle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ export default function FeatureToggleList({isPagePermissionSuccess, operationUse
scope="col"
className="select-none px-6 py-3 tracking-wider"
>
OTOMATİK ETKİNLEŞTİRİLME TARİHİ
BAŞLAMA TARİHİ
</th>
<th
scope="col"
className="select-none px-6 py-3 tracking-wider"
>
STATÜSÜ
BİTİŞ TARİHİ
</th>
</tr>
</thead>
Expand Down Expand Up @@ -101,7 +101,17 @@ export default function FeatureToggleList({isPagePermissionSuccess, operationUse
<div className="ml-4">
<div
className="font-phenomenaLight text-xl text-sis-darkblue">
{featureToggle.date}
{featureToggle.startDate}
</div>
</div>
</div>
</td>
<td className="px-2 py-4 whitespace-nowrap">
<div className="flex items-center">
<div className="ml-4">
<div
className="font-phenomenaLight text-xl text-sis-darkblue">
{featureToggle.endDate}
</div>
</div>
</div>
Expand Down
9 changes: 8 additions & 1 deletion pages/teacher/lesson/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import UnauthorizedAccessPage from "../../401";
import TeacherLessonController from "../../../public/api/teacher/lesson/TeacherLessonController";
import LessonCompulsoryOrElective from "../../../public/constants/lesson/LessonCompulsoryOrElective";
import LessonStatus from "../../../public/constants/lesson/LessonStatus";
import FeatureToggleController from "../../../public/api/university/FeatureToggleController";
import FeatureToggleName from "../../../public/constants/university/FeatureToggleName";

export async function getServerSideProps(context) {
const teacherId = SisTeacherStorage.getNumberWithContext(context);
Expand All @@ -17,18 +19,21 @@ export async function getServerSideProps(context) {
}
}

const noteOperationsToggleData = await FeatureToggleController.isFeatureToggleEnabled(FeatureToggleName.NOTE_OPERATIONS);

const lessonsData = await TeacherLessonController.getTeacherLessonsByTeacherId(teacherId);
if (lessonsData.success) {
return {
props: {
isPagePermissionSuccess: true,
isNoteOperationsFeatureToggleEnabled: noteOperationsToggleData.response.isFeatureToggleEnabled,
lessons: lessonsData.response
}
}
}
}

export default function TeacherLessonsList({isPagePermissionSuccess, lessons}) {
export default function TeacherLessonsList({isPagePermissionSuccess, isNoteOperationsFeatureToggleEnabled, lessons}) {

if (!isPagePermissionSuccess) {
return (
Expand Down Expand Up @@ -144,6 +149,8 @@ export default function TeacherLessonsList({isPagePermissionSuccess, lessons}) {
</td>
{(
lesson.lessonResponse.status === LessonStatus.ACTIVE
&&
isNoteOperationsFeatureToggleEnabled
?
<td className="ml-10 px-6 py-4 text-right font-phenomenaBold text-xl">
<a href={`/teacher/lesson/note/${lesson.lessonResponse.lessonId}`}
Expand Down
22 changes: 19 additions & 3 deletions pages/teacher/lesson/note/[lessonId]/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import {useRouter} from "next/router";
import ProcessNotification from "../../../../../public/notifications/process";
import SuccessNotification from "../../../../../public/notifications/success";
import FailNotification from "../../../../../public/notifications/fail";
import FeatureToggleController from "../../../../../public/api/university/FeatureToggleController";
import FeatureToggleName from "../../../../../public/constants/university/FeatureToggleName";
import PageNotFound from "../../../../404";

export async function getServerSideProps(context) {
const teacherId = SisTeacherStorage.getNumberWithContext(context);
Expand All @@ -20,15 +23,21 @@ export async function getServerSideProps(context) {
}
}

const noteOperationsToggleData = await FeatureToggleController.isFeatureToggleEnabled(FeatureToggleName.NOTE_OPERATIONS);
const midtermNoteToggleData = await FeatureToggleController.isFeatureToggleEnabled(FeatureToggleName.MIDTERM_NOTE_OPERATIONS);
const finalNoteToggleData = await FeatureToggleController.isFeatureToggleEnabled(FeatureToggleName.FINAL_NOTE_OPERATIONS);
const resitNoteToggleData = await FeatureToggleController.isFeatureToggleEnabled(FeatureToggleName.RESIT_NOTE_OPERATIONS);

const {lessonId} = context.query;
const studentsLessonNotesData = await StudentLessonNoteController.getAllStudentsLessonNotesByLessonId(lessonId);
if (studentsLessonNotesData.success) {
return {
props: {
isPagePermissionSuccess: true,
isMidtermNoteFeatureToggleEnabled: false, // TODO: Midterm Note Feature Toggle Controls
isFinalNoteFeatureToggleEnabled: false, // TODO: Final Note Feature Toggle Controls
isResitNoteFeatureToggleEnabled: false, // TODO: Resit Note Feature Toggle Controls
isNoteOperationsFeatureToggleEnabled: noteOperationsToggleData.response.isFeatureToggleEnabled,
isMidtermNoteFeatureToggleEnabled: midtermNoteToggleData.response.isFeatureToggleEnabled,
isFinalNoteFeatureToggleEnabled: finalNoteToggleData.response.isFeatureToggleEnabled,
isResitNoteFeatureToggleEnabled: resitNoteToggleData.response.isFeatureToggleEnabled,
operationUserId: teacherId,
studentsLessonNotes: studentsLessonNotesData.response
}
Expand All @@ -39,6 +48,7 @@ export async function getServerSideProps(context) {
export default function TeacherLessonNotesList({
isPagePermissionSuccess,
operationUserId,
isNoteOperationsFeatureToggleEnabled,
isMidtermNoteFeatureToggleEnabled,
isFinalNoteFeatureToggleEnabled,
isResitNoteFeatureToggleEnabled,
Expand All @@ -51,6 +61,12 @@ export default function TeacherLessonNotesList({
)
}

if (!isNoteOperationsFeatureToggleEnabled) {
return (
<PageNotFound user="teacher"/>
)
}


const router = useRouter();

Expand Down
20 changes: 19 additions & 1 deletion public/constants/university/FeatureToggleName.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,34 @@ const getAll = [
{
enum: 'NOTE_OPERATIONS',
tr: 'Not İşlemleri'
},
{
enum: 'MIDTERM_NOTE_OPERATIONS',
tr: 'Vize Not İşlemleri'
},
{
enum: 'FINAL_NOTE_OPERATIONS',
tr: 'Final Not İşlemleri'
},
{
enum: 'RESIT_NOTE_OPERATIONS',
tr: 'Bütünleme Not İşlemleri'
}
]

const LESSON_REGISTRATION_OPERATIONS = 'LESSON_REGISTRATION_OPERATIONS';
const NOTE_OPERATIONS = 'NOTE_OPERATIONS';
const MIDTERM_NOTE_OPERATIONS = 'MIDTERM_NOTE_OPERATIONS';
const FINAL_NOTE_OPERATIONS = 'FINAL_NOTE_OPERATIONS';
const RESIT_NOTE_OPERATIONS = 'RESIT_NOTE_OPERATIONS';

const FeatureToggleName = {
getAll,
LESSON_REGISTRATION_OPERATIONS,
NOTE_OPERATIONS
NOTE_OPERATIONS,
MIDTERM_NOTE_OPERATIONS,
FINAL_NOTE_OPERATIONS,
RESIT_NOTE_OPERATIONS
};

export default FeatureToggleName;

0 comments on commit 7a86995

Please sign in to comment.