Merge pull request 'feat: enhance department handling by adding degree level and formatting labels' (#58) from feat/adding-degre-level-and-formatting-label into dev

Reviewed-on: #58
This commit is contained in:
pangestu 2026-08-30 13:35:39 +08:00
commit 1fe2b30156
12 changed files with 69 additions and 35 deletions

View File

@ -10,7 +10,7 @@ class DepartmentService
{
public function getAllForSelect(): Collection
{
return Department::select(['id', 'code', 'name'])->get();
return Department::select(['id', 'code', 'name', 'degree_level'])->get();
}
public function paginated(int $perPage = 25, string $search = ''): LengthAwarePaginator

View File

@ -11,21 +11,21 @@ public function run(): void
{
Department::insert([
[
'code' => 'SI',
'code' => 'SI-S1',
'name' => 'Sistem Informasi',
'degree_level' => 'S1',
'created_at' => now(),
'updated_at' => now(),
],
[
'code' => 'TI',
'code' => 'TI-S1',
'name' => 'Teknik Industri',
'degree_level' => 'S1',
'created_at' => now(),
'updated_at' => now(),
],
[
'code' => 'BD',
'code' => 'BD-S1',
'name' => 'Bisnis Digital',
'degree_level' => 'S1',
'created_at' => now(),

View File

@ -31,6 +31,7 @@ import type {
Announcement,
AnnouncementDepartment,
} from '@/types/announcement';
import { formatDepartmentLabel } from '@/types/department';
import { createAnnouncementColumns } from './columns';
type Props = {
@ -64,7 +65,7 @@ export default function AnnouncementIndex({
label: 'Jurusan',
options: departments.map((department) => ({
value: String(department.id),
label: department.name,
label: formatDepartmentLabel(department),
})),
},
];
@ -255,7 +256,7 @@ function AnnouncementFields({
key={department.id}
value={String(department.id)}
>
{department.name}
{formatDepartmentLabel(department)}
</SelectItem>
))}
</SelectContent>

View File

@ -27,9 +27,10 @@ import {
update,
} from '@/routes/admin/manage/courses';
import type { Course } from '@/types/course';
import { formatDepartmentLabel } from '@/types/department';
import { createCourseColumns } from './columns';
type Department = { id: number; name: string };
type Department = { id: number; name: string; degree_level: string | null };
type Props = {
courses: {
@ -62,7 +63,7 @@ export default function CourseIndex({
label: 'Jurusan',
options: departments.map((department) => ({
value: String(department.id),
label: department.name,
label: formatDepartmentLabel(department),
})),
},
];
@ -256,7 +257,7 @@ function CreateForm({
key={dept.id}
value={String(dept.id)}
>
{dept.name}
{formatDepartmentLabel(dept)}
</SelectItem>
))}
</SelectContent>
@ -362,7 +363,7 @@ function EditForm({
key={dept.id}
value={String(dept.id)}
>
{dept.name}
{formatDepartmentLabel(dept)}
</SelectItem>
))}
</SelectContent>

View File

@ -24,8 +24,9 @@ import { PhoneInput } from '@/components/ui/phone-input';
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
import { Textarea } from '@/components/ui/textarea';
import { index, store } from '@/routes/admin/users/lecturers';
import { formatDepartmentLabel } from '@/types/department';
type Department = { id: number; name: string };
type Department = { id: number; name: string; degree_level: string | null };
type Props = {
departments: Department[];
@ -283,8 +284,8 @@ export default function LecturerCreate({ departments }: Props) {
onValueChange={
setSelectedDepartments
}
itemToStringLabel={(dept) =>
dept.name
itemToStringLabel={
formatDepartmentLabel
}
isItemEqualToValue={(a, b) =>
a.id === b.id
@ -297,11 +298,13 @@ export default function LecturerCreate({ departments }: Props) {
(dept) => (
<ComboboxChip
key={dept.id}
aria-label={
dept.name
}
aria-label={formatDepartmentLabel(
dept,
)}
>
{dept.name}
{formatDepartmentLabel(
dept,
)}
</ComboboxChip>
),
)}
@ -326,7 +329,9 @@ export default function LecturerCreate({ departments }: Props) {
key={dept.id}
value={dept}
>
{dept.name}
{formatDepartmentLabel(
dept,
)}
</ComboboxItem>
))}
</ComboboxList>

View File

@ -24,8 +24,9 @@ import { PhoneInput } from '@/components/ui/phone-input';
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
import { Textarea } from '@/components/ui/textarea';
import { index, update } from '@/routes/admin/users/lecturers';
import { formatDepartmentLabel } from '@/types/department';
type Department = { id: number; name: string };
type Department = { id: number; name: string; degree_level: string | null };
type User = {
id: number;
@ -41,7 +42,11 @@ type User = {
} | null;
lecturer: {
lecturer_number: string;
departments: { id: number; name: string }[];
departments: {
id: number;
name: string;
degree_level: string | null;
}[];
} | null;
};
@ -318,8 +323,8 @@ export default function LecturerEdit({ user, departments }: Props) {
onValueChange={
setSelectedDepartments
}
itemToStringLabel={(dept) =>
dept.name
itemToStringLabel={
formatDepartmentLabel
}
isItemEqualToValue={(a, b) =>
a.id === b.id
@ -332,11 +337,13 @@ export default function LecturerEdit({ user, departments }: Props) {
(dept) => (
<ComboboxChip
key={dept.id}
aria-label={
dept.name
}
aria-label={formatDepartmentLabel(
dept,
)}
>
{dept.name}
{formatDepartmentLabel(
dept,
)}
</ComboboxChip>
),
)}
@ -361,7 +368,9 @@ export default function LecturerEdit({ user, departments }: Props) {
key={dept.id}
value={dept}
>
{dept.name}
{formatDepartmentLabel(
dept,
)}
</ComboboxItem>
))}
</ComboboxList>

View File

@ -19,10 +19,11 @@ import {
update_user_status,
exportMethod as exportLecturers,
} from '@/routes/admin/users/lecturers';
import { formatDepartmentLabel } from '@/types/department';
import type { Lecturer } from './columns';
import { createLecturerColumns } from './columns';
type Department = { id: number; name: string };
type Department = { id: number; name: string; degree_level: string | null };
type Props = {
lecturers: {
@ -61,7 +62,7 @@ export default function LecturerIndex({
label: 'Jurusan',
options: departments.map((department) => ({
value: String(department.id),
label: department.name,
label: formatDepartmentLabel(department),
})),
},
];

View File

@ -28,8 +28,9 @@ import {
} from '@/components/ui/select';
import { Textarea } from '@/components/ui/textarea';
import { index, store } from '@/routes/admin/users/students';
import { formatDepartmentLabel } from '@/types/department';
type Department = { id: number; name: string };
type Department = { id: number; name: string; degree_level: string | null };
type Lecturer = {
id: number;
lecturer_number: string;
@ -289,7 +290,9 @@ export default function StudentCreate({ departments, lecturers }: Props) {
key={dept.id}
value={String(dept.id)}
>
{dept.name}
{formatDepartmentLabel(
dept,
)}
</SelectItem>
))}
</SelectContent>

View File

@ -28,8 +28,9 @@ import {
} from '@/components/ui/select';
import { Textarea } from '@/components/ui/textarea';
import { index, update } from '@/routes/admin/users/students';
import { formatDepartmentLabel } from '@/types/department';
type Department = { id: number; name: string };
type Department = { id: number; name: string; degree_level: string | null };
type Lecturer = {
id: number;
lecturer_number: string;
@ -336,7 +337,9 @@ export default function StudentEdit({ user, departments, lecturers }: Props) {
key={dept.id}
value={String(dept.id)}
>
{dept.name}
{formatDepartmentLabel(
dept,
)}
</SelectItem>
))}
</SelectContent>

View File

@ -21,10 +21,11 @@ import {
exportMethod as exportStudents,
index as studentsIndex,
} from '@/routes/admin/users/students';
import { formatDepartmentLabel } from '@/types/department';
import { createStudentColumns } from './columns';
import type { Student } from './columns';
type Department = { id: number; name: string };
type Department = { id: number; name: string; degree_level: string | null };
type StatusOption = { value: string; label: string };
type Props = {
@ -70,7 +71,7 @@ export default function StudentIndex({
label: 'Jurusan',
options: departments.map((department) => ({
value: String(department.id),
label: department.name,
label: formatDepartmentLabel(department),
})),
},
{

View File

@ -2,6 +2,7 @@ export type AnnouncementDepartment = {
id: number;
code: string;
name: string;
degree_level: string | null;
};
export type AnnouncementCreator = {

View File

@ -10,3 +10,12 @@ export type Department = {
created_at: string;
updated_at: string;
};
export function formatDepartmentLabel(department: {
name: string;
degree_level?: string | null;
}): string {
return department.degree_level
? `${department.name} (${department.degree_level})`
: department.name;
}