Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export interface StudentDetailApiResponse {
advisor: string;
major: string;
capstoneCompletion: boolean;
phone: string;
status: SubmissionStatus;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ import { getSubmissionTypeIndex } from '../../schedule/constants';
import { useFile } from '../model';
import * as style from '../styles/FilePreviewPage.css';

import { useGraduationBatchApproval } from '~/admin/entities/graduation-approval/model';
import {
useGraduationBatchApproval,
useGraduationBatchDisapproval,
} from '~/admin/entities/graduation-approval/model';
import { useStudentDetail } from '~/admin/features/studentDetail';
import {
APPROVE_FAILED,
APPROVE_SUCCESS,
DISAPPROVE_FAILED,
DISAPPROVE_SUCCESS,
} from '~/admin/shared/constants/actionTexts';

export default function FilePreviewPage() {
Expand Down Expand Up @@ -52,6 +57,23 @@ export default function FilePreviewPage() {
},
});

const { disapproveGraduationUsers, mutation: disapprovalMutation } =
useGraduationBatchDisapproval({
onSuccess: async () => {
toast.success(DISAPPROVE_SUCCESS);
await refetch();
},
});

const handleCancelApprove = async () => {
const result = await disapproveGraduationUsers([
{ graduationUserId, submissionId: fileId },
]);
if (result.successCount === 0) {
toast.error(DISAPPROVE_FAILED);
}
};

const clearHideTimeout = () => {
if (hideTimeoutRef.current !== null) {
clearTimeout(hideTimeoutRef.current);
Expand Down Expand Up @@ -180,9 +202,11 @@ export default function FilePreviewPage() {
name={name}
isApproved={approval ?? false}
onApprove={handleApprove}
onCancelApprove={handleCancelApprove}
onChangeFile={handleNextFile}
canNavigate={canNavigate}
isApproving={approvalMutation.isPending}
isCancellingApprove={disapprovalMutation.isPending}
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,50 @@ interface FilePreviewToolbarProps {
name: string;
isApproved: boolean;
onApprove: () => void;
onCancelApprove: () => void;
onChangeFile: () => void;
canNavigate: boolean;
isApproving: boolean;
isCancellingApprove: boolean;
}

export default function FilePreviewToolbar({
studentId,
name,
isApproved,
onApprove,
onCancelApprove,
onChangeFile,
canNavigate,
isApproving,
isCancellingApprove,
}: FilePreviewToolbarProps) {
return (
<div className={style.toolbar}>
<span className={style.infoItem}>학번: {studentId}</span>
<span className={style.infoItem}>이름: {name}</span>
<Button
type='primary'
onClick={onApprove}
disabled={isApproved || isApproving}
loading={isApproving}
className={style.button}
>
{isApproved ? '승인됨' : '승인'}
</Button>
{isApproved ? (
<Button
type='primary'
danger
onClick={onCancelApprove}
disabled={isCancellingApprove}
loading={isCancellingApprove}
className={style.button}
>
승인 취소
</Button>
) : (
<Button
type='primary'
onClick={onApprove}
disabled={isApproving}
loading={isApproving}
className={style.button}
>
승인
</Button>
)}
<Button
onClick={onChangeFile}
disabled={!canNavigate}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default function UserDetailModal({
advisor,
major,
capstoneCompletion,
phone,
status,
} = studentDetail ?? {};

Expand Down Expand Up @@ -133,9 +134,10 @@ export default function UserDetailModal({
<Descriptions.Item label='기타자격'>
{capstoneCompletion ? '캡스톤 이수' : '캡스톤 미이수'}
</Descriptions.Item>
<Descriptions.Item label='상태' span={2}>
<Descriptions.Item label='상태'>
{getStatusLabel(status)}
</Descriptions.Item>
<Descriptions.Item label='연락처'>{phone}</Descriptions.Item>
</Descriptions>
</Container>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const HEADER_NAMES = {
capstoneCompletion: '캡스톤 이수 여부',
graduationDate: '졸업 예정',
department: '학과',
phone: '연락처',
} as const;

export const MODE_OPTIONS = [
Expand Down Expand Up @@ -53,6 +54,11 @@ export const SINGLE_FIELD_TEXT = {
placeholder: '학과를 입력해주세요',
required: '학과를 입력해주세요',
},
phone: {
label: '연락처',
placeholder: '연락처를 입력해주세요',
required: '연락처를 입력해주세요',
},
submitLabel: '입력',
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const getHeaderIndices = (header: string[]) => {
capstone: idx(HEADER_NAMES.capstoneCompletion, 3),
grad: idx(HEADER_NAMES.graduationDate, 4),
dept: idx(HEADER_NAMES.department, 5),
phone: idx(HEADER_NAMES.phone, 6),
},
};
};
Expand Down Expand Up @@ -69,6 +70,7 @@ export function parseCsv(
capstoneText: (cols[indices.capstone] || '').trim().toLowerCase(),
grad: (cols[indices.grad] || '').trim(),
dept: (cols[indices.dept] || '').trim(),
phone: (cols[indices.phone] || '').trim(),
professorNameToId,
seenStudentIds,
});
Expand Down Expand Up @@ -121,6 +123,7 @@ export async function parseXlsx(
capstoneText: getCell(indices.capstone).toLowerCase(),
grad: getCell(indices.grad),
dept: getCell(indices.dept),
phone: getCell(indices.phone),
professorNameToId,
seenStudentIds,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type ValidateOptions = {
capstoneText: string;
grad: string;
dept: string;
phone: string;
professorNameToId: ProfessorNameToId;
seenStudentIds: Set<string>;
};
Expand All @@ -37,6 +38,7 @@ export const validateStudentRow = ({
capstoneText,
grad,
dept,
phone,
professorNameToId,
seenStudentIds,
}: ValidateOptions): ValidateResult => {
Expand All @@ -47,6 +49,7 @@ export const validateStudentRow = ({
if (!capstoneText) missing.push('capstoneCompletion');
if (!grad) missing.push('graduationDate');
if (!dept) missing.push('department');
if (!phone) missing.push('phone');

if (missing.length > 0) {
return {
Expand Down Expand Up @@ -137,6 +140,7 @@ export const validateStudentRow = ({
capstoneCompletion,
department: dept,
graduationDate,
phone,
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default function StudentAddMultiple({
capstoneCompletion: row.capstoneCompletion,
department: row.department,
graduationDate: row.graduationDate,
phone: row.phone,
}));

const handleSelectSubmit: ButtonProps['onClick'] = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '../types/studentAddModal';

type TextFieldConfig = {
name: 'studentId' | 'name' | 'department';
name: 'studentId' | 'name' | 'department' | 'phone';
rules: FormItemProps['rules'];
placeholder: string;
label: string;
Expand Down Expand Up @@ -41,6 +41,12 @@ const TEXT_FIELD_CONFIGS: TextFieldConfig[] = [
placeholder: SINGLE_FIELD_TEXT.department.placeholder,
label: SINGLE_FIELD_TEXT.department.label,
},
{
name: 'phone',
rules: [{ required: true, message: SINGLE_FIELD_TEXT.phone.required }],
placeholder: SINGLE_FIELD_TEXT.phone.placeholder,
label: SINGLE_FIELD_TEXT.phone.label,
},
];

type FormValues = Omit<
Expand All @@ -49,6 +55,7 @@ type FormValues = Omit<
> & {
capstoneCompletion: CapstoneCompletionOption['value'];
graduationDate: Dayjs | null;
phone: string;
};

export default function StudentAddSingle({
Expand All @@ -73,6 +80,7 @@ export default function StudentAddSingle({
capstoneCompletion: v.capstoneCompletion === 'true',
department: v.department.trim(),
graduationDate: v.graduationDate.format('YYYY-MM'),
phone: v.phone.trim(),
};
onSubmit?.(payload);
form.resetFields();
Expand Down
1 change: 1 addition & 0 deletions apps/graduate/src/shared/types/graduationUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export type GraduationUserCreateRequest = {
capstoneCompletion: boolean;
department: string;
graduationDate: string;
phone: string;
};
Loading