mirror of
https://github.com/headporter81/ss-front-react.git
synced 2026-12-06 07:41:11 +09:00
feat : 자료실 글 삭제 버튼 추가 ([삭제] → 확인 → 목록으로)
SpecialSource Frontend (React) CD / deploy (push) Successful in 14s
SpecialSource Frontend (React) CD / deploy (push) Successful in 14s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
eac57c04e7
commit
eaca07da53
4 files changed
+52
-4
No files matched your search
@@ -286,7 +286,12 @@ export default function BbsTerminal() {
|
||||
/>
|
||||
)}
|
||||
{state.screen === "mediaPost" && state.token && state.postId !== null && (
|
||||
<MediaDetail id={state.postId} token={state.token} onError={onApiError} />
|
||||
<MediaDetail
|
||||
id={state.postId}
|
||||
token={state.token}
|
||||
onError={onApiError}
|
||||
onDeleted={() => dispatch({ screen: "media", rev: state.rev + 1 })}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,12 +1,33 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { API_URL, fetchMediaPost } from "../api";
|
||||
import { API_URL, deleteMediaPost, fetchMediaPost } from "../api";
|
||||
import type { MediaPost } from "../types";
|
||||
import { STATUS } from "./MediaList";
|
||||
import styles from "./bbs.module.css";
|
||||
|
||||
/** 자료실 글 보기: 파일마다 <video>/<img>. 파일 주소의 토큰은 1시간 유효 → 오래 열어 두었으면 "L" 후 다시 열기 */
|
||||
export default function MediaDetail({ id, token, onError }: { id: number; token: string; onError: (e: unknown) => void }) {
|
||||
interface Props {
|
||||
id: number;
|
||||
token: string;
|
||||
onError: (e: unknown) => void;
|
||||
onDeleted: () => void; // 삭제 성공 → 목록으로
|
||||
}
|
||||
|
||||
export default function MediaDetail({ id, token, onError, onDeleted }: Props) {
|
||||
const [post, setPost] = useState<MediaPost | null>(null);
|
||||
const [confirming, setConfirming] = useState(false); // [삭제] 한 번 누르면 "정말?" 확인 단계
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
const remove = async () => {
|
||||
setBusy(true);
|
||||
try {
|
||||
await deleteMediaPost(token, id);
|
||||
onDeleted();
|
||||
} catch (e) {
|
||||
onError(e);
|
||||
setBusy(false);
|
||||
setConfirming(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 받는 중이면 5초마다 다시 조회 → 끝나면 파일이 나타남
|
||||
useEffect(() => {
|
||||
@@ -70,7 +91,22 @@ export default function MediaDetail({ id, token, onError }: { id: number; token:
|
||||
<a className={styles.accent} href={post.sourceUrl} target="_blank" rel="noreferrer">
|
||||
원본 보기 ↗
|
||||
</a>{" "}
|
||||
· <b>L</b>=목록 · <b>M</b>=메인
|
||||
· <b>L</b>=목록 · <b>M</b>=메인 ·{" "}
|
||||
{confirming ? (
|
||||
<>
|
||||
<span className={styles.error}>파일까지 지워집니다. 정말 삭제할까요?</span>{" "}
|
||||
<button type="button" className={styles.linkBtn} onClick={remove} disabled={busy}>
|
||||
{busy ? "[삭제중...]" : "[예]"}
|
||||
</button>{" "}
|
||||
<button type="button" className={styles.linkBtn} onClick={() => setConfirming(false)} disabled={busy}>
|
||||
[아니오]
|
||||
</button>
|
||||
</>
|
||||
) : (
|
||||
<button type="button" className={styles.linkBtn} onClick={() => setConfirming(true)}>
|
||||
[삭제]
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
|
||||
@@ -59,6 +59,10 @@
|
||||
.rule { border: none; border-top: 1px dashed var(--bbs-dim); margin: 0.6em 0; }
|
||||
.footer { color: var(--bbs-dim); margin-top: 0.6em; }
|
||||
.footer b { color: var(--bbs-highlight); }
|
||||
/* 글자처럼 보이는 버튼 (자료실 [삭제] 등) */
|
||||
.linkBtn { background: none; border: none; padding: 0; font: inherit; color: var(--bbs-accent); cursor: pointer; }
|
||||
.linkBtn:hover { color: var(--bbs-highlight); }
|
||||
.linkBtn:disabled { opacity: 0.5; cursor: wait; }
|
||||
|
||||
/* 메인 메뉴: 마우스를 올리면 반전 막대 */
|
||||
.menu { list-style: none; margin: 0; padding: 0; }
|
||||
|
||||
Reference in new issue
Block a user