fix: correct curriculum week deletion and include selected course ID
This commit is contained in:
@@ -451,6 +451,7 @@ export function InstructorLayout({ session, route, onNavigate, onLogout, courses
|
|||||||
</div>
|
</div>
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<p className="truncate text-[14px] font-black text-[#111827]">{displayName}</p>
|
<p className="truncate text-[14px] font-black text-[#111827]">{displayName}</p>
|
||||||
|
<p className="mt-1 break-all text-[11px] leading-4 text-[#64748b]">{session.user.email}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
export type CurriculumWeek = {
|
export type CurriculumWeek = {
|
||||||
|
canDelete?: boolean;
|
||||||
week: number;
|
week: number;
|
||||||
title: string;
|
title: string;
|
||||||
tags: string[];
|
tags: string[];
|
||||||
@@ -223,8 +224,10 @@ export async function createInstructorCurriculumMap(
|
|||||||
export async function deleteInstructorCurriculumWeek(
|
export async function deleteInstructorCurriculumWeek(
|
||||||
accessToken: string,
|
accessToken: string,
|
||||||
week: number,
|
week: number,
|
||||||
|
courseId?: string | null,
|
||||||
): Promise<InstructorCurriculumResponse> {
|
): Promise<InstructorCurriculumResponse> {
|
||||||
const response = await fetch(`${LMS_API_BASE_URL}/instructor/curriculum/weeks/${week}`, {
|
const query = courseId ? `?courseId=${encodeURIComponent(courseId)}` : '';
|
||||||
|
const response = await fetch(`${LMS_API_BASE_URL}/instructor/curriculum/weeks/${week}${query}`, {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${accessToken}`,
|
Authorization: `Bearer ${accessToken}`,
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ export function CurriculumPage({ session, selectedCourseId }: { session: AuthSes
|
|||||||
const primaryActionDisabled = saving || !selectedWeek || (activeTab === 'apply' && !selectedGroup);
|
const primaryActionDisabled = saving || !selectedWeek || (activeTab === 'apply' && !selectedGroup);
|
||||||
const selectedTopics = activeTab === 'edit' ? draftTopics : selectedWeek?.topics ?? [];
|
const selectedTopics = activeTab === 'edit' ? draftTopics : selectedWeek?.topics ?? [];
|
||||||
const selectedTopicDetails = activeTab === 'edit' ? draftTopicDetails : selectedWeek?.detail.topicDetails ?? [];
|
const selectedTopicDetails = activeTab === 'edit' ? draftTopicDetails : selectedWeek?.detail.topicDetails ?? [];
|
||||||
const selectedWeekDeletable = Boolean(selectedWeek?.tags.includes('추가'));
|
const selectedWeekDeletable = selectedWeek?.canDelete === true;
|
||||||
const tagOptionLabels = useMemo(() => new Set(tagOptions.map((option) => option.label)), [tagOptions]);
|
const tagOptionLabels = useMemo(() => new Set(tagOptions.map((option) => option.label)), [tagOptions]);
|
||||||
const selectedTagLabel = tagOptionLabels.has(draftTagLabel)
|
const selectedTagLabel = tagOptionLabels.has(draftTagLabel)
|
||||||
? draftTagLabel
|
? draftTagLabel
|
||||||
@@ -580,7 +580,7 @@ export function CurriculumPage({ session, selectedCourseId }: { session: AuthSes
|
|||||||
setError(null);
|
setError(null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const payload = await deleteInstructorCurriculumWeek(session.accessToken, selectedWeek.week);
|
const payload = await deleteInstructorCurriculumWeek(session.accessToken, selectedWeek.week, selectedCourseId);
|
||||||
applyPayload(payload, { selectProgress: true });
|
applyPayload(payload, { selectProgress: true });
|
||||||
showToast({
|
showToast({
|
||||||
title: '주차가 삭제되었습니다.',
|
title: '주차가 삭제되었습니다.',
|
||||||
|
|||||||
Reference in New Issue
Block a user