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

Theoretical and Practice Hours Update | SIS-180 #71

Merged
merged 8 commits into from
Apr 24, 2022
151 changes: 112 additions & 39 deletions pages/officer/operation/lesson/information/detail/[id]/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,32 +264,37 @@ export default function LessonDetail({isPagePermissionSuccess, isDataFound, oper

const [departmentId, setDepartmentId] = useState(departmentResponse.departmentId);
const changeDepartmentId = event => {
const departmentId = event.target.value;
setDepartmentId(departmentId);
setDepartmentId(event.target.value);
}

const [name, setName] = useState(lesson.name);
const changeName = event => {
const name = event.target.value;
setName(name);
setName(event.target.value);
}

const [credit, setCredit] = useState(lesson.credit);
const changeCredit = event => {
const credit = event.target.value;
setCredit(credit);
setCredit(event.target.value);
}

const [theoreticalHours, setTheoreticalHours] = useState();
const changeTheoreticalHours = event => {
setTheoreticalHours(event.target.value);
}

const [practiceHours, setPracticeHours] = useState();
const changePracticeHours = event => {
setPracticeHours(event.target.value);
}

const [compulsoryOrElective, setCompulsoryOrElective] = useState(lesson.compulsoryOrElective);
const changeCompulsoryOrElective = event => {
const compulsoryOrElective = event.target.value;
setCompulsoryOrElective(compulsoryOrElective);
setCompulsoryOrElective(event.target.value);
}

const [semester, setSemester] = useState(lesson.semester);
const changeSemester = event => {
const semester = event.target.value;
setSemester(semester);
setSemester(event.target.value);
}

const lessonUpdate = async (event) => {
Expand All @@ -298,7 +303,7 @@ export default function LessonDetail({isPagePermissionSuccess, isDataFound, oper
event.preventDefault();

const lessonId = lesson.lessonId;
const lessonInfo = {departmentId, name, credit, compulsoryOrElective, semester};
const lessonInfo = {departmentId, name, credit, theoreticalHours, practiceHours, compulsoryOrElective, semester};
const lessonData = await LessonController.updateLesson(operationUserId, lessonId, lessonInfo);
if (lessonData.success) {
closeProcessingUpdateNotification();
Expand Down Expand Up @@ -363,25 +368,11 @@ export default function LessonDetail({isPagePermissionSuccess, isDataFound, oper
</h3>
</div>
<div className="grid grid-cols-6 gap-6">
<div className="sm:col-span-3">
<label htmlFor="lessonId"
className="ml-0.5 text-xl text-sis-darkblue font-phenomenaBold">
DERS NUMARASI
</label>
<input
type="text"
name="lessonId"
id="lessonId"
defaultValue={lesson.lessonId}
disabled
className="font-phenomenaRegular text-gray-400 mt-1 focus:ring-sis-yellow focus:border-sis-yellow block w-full shadow-sm sm:text-xl border-gray-300 rounded-md"
/>
</div>

<div className="sm:col-span-3">
<div className="sm:col-span-6">
<label htmlFor="faculty"
className="ml-0.5 text-xl text-sis-darkblue font-phenomenaBold">
FAKÜLTE ADI
FAKÜLTE
</label>
<select
id="faculty"
Expand All @@ -395,10 +386,10 @@ export default function LessonDetail({isPagePermissionSuccess, isDataFound, oper
</select>
</div>

<div className="sm:col-span-3">
<div className="sm:col-span-6">
<label htmlFor="department"
className="ml-0.5 text-xl text-sis-darkblue font-phenomenaBold">
BÖLÜMÜ
BÖLÜM
</label>
<select
onChange={changeDepartmentId}
Expand All @@ -423,8 +414,22 @@ export default function LessonDetail({isPagePermissionSuccess, isDataFound, oper
</select>
</div>

<div className="sm:col-span-1">
<label htmlFor="lessonId"
className="ml-0.5 text-xl text-sis-darkblue font-phenomenaBold">
DERS KODU
</label>
<input
type="text"
name="lessonId"
id="lessonId"
defaultValue={lesson.lessonId}
disabled
className="font-phenomenaRegular text-gray-400 mt-1 focus:ring-sis-yellow focus:border-sis-yellow block w-full shadow-sm sm:text-xl border-gray-300 rounded-md"
/>
</div>

<div className="col-span-6 sm:col-span-3">
<div className="col-span-6 sm:col-span-5">
<label htmlFor="name"
className="ml-0.5 text-xl text-sis-darkblue font-phenomenaBold">
DERSİN ADI
Expand All @@ -443,23 +448,91 @@ export default function LessonDetail({isPagePermissionSuccess, isDataFound, oper
}/>
</div>

<div className="col-span-6 sm:col-span-3">
<div className="col-span-6 sm:col-span-2">
<label htmlFor="credit"
className="ml-0.5 text-xl text-sis-darkblue font-phenomenaBold">
DERSİN KREDİSİ
</label>
<input
onChange={changeCredit}
type="text"
onChange={(e) => {
if (e.target.value.length > 2) {
e.target.value = "99"
}
if (e.target.value >= 99) {
e.target.value = "99"
}
if (e.target.value <= 0) {
e.target.value = "0"
}
changeCredit(e)
}}
type="number"
min={100}
min={0}
name="credit"
id="credit"
required
defaultValue={lesson.credit}
disabled={isLessonPassiveOrDeleted()}
className={isLessonPassiveOrDeleted()
? "font-phenomenaRegular text-gray-400 mt-1 focus:ring-sis-yellow focus:border-sis-yellow w-full shadow-sm sm:text-xl border-gray-300 rounded-md"
: "font-phenomenaRegular text-gray-700 mt-1 focus:ring-sis-yellow focus:border-sis-yellow w-full shadow-sm sm:text-xl border-gray-300 rounded-md"
}/>
required
className="font-phenomenaRegular text-gray-700 mt-1 focus:ring-sis-yellow focus:border-sis-yellow block w-full shadow-sm sm:text-xl border-gray-300 rounded-md"
/>
</div>

<div className="col-span-6 sm:col-span-2">
<label htmlFor="credit"
className="ml-0.5 text-xl text-sis-darkblue font-phenomenaBold">
TEORİK DERS SAATİ
</label>
<input
onChange={(e) => {
if (e.target.value.length > 2) {
e.target.value = "99"
}
if (e.target.value >= 99) {
e.target.value = "99"
}
if (e.target.value <= 0) {
e.target.value = "0"
}
changeTheoreticalHours(e)
}}
type="number"
min={100}
min={0}
name="theoreticalHours"
id="theoreticalHours"
defaultValue={lesson.theoreticalHours}
required
className="font-phenomenaRegular text-gray-700 mt-1 focus:ring-sis-yellow focus:border-sis-yellow block w-full shadow-sm sm:text-xl border-gray-300 rounded-md"
/>
</div>

<div className="col-span-6 sm:col-span-2">
<label htmlFor="credit"
className="ml-0.5 text-xl text-sis-darkblue font-phenomenaBold">
UYGULAMA DERS SAATİ
</label>
<input
onChange={(e) => {
if (e.target.value.length > 2) {
e.target.value = "99"
}
if (e.target.value >= 99) {
e.target.value = "99"
}
if (e.target.value <= 0) {
e.target.value = "0"
}
changePracticeHours(e)
}}
type="number"
min={100}
min={0}
name="practiceHours"
id="practiceHours"
defaultValue={lesson.practiceHours}
required
className="font-phenomenaRegular text-gray-700 mt-1 focus:ring-sis-yellow focus:border-sis-yellow block w-full shadow-sm sm:text-xl border-gray-300 rounded-md"
/>
</div>

<div className="col-span-6 sm:col-span-3">
Expand Down
Loading