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 @@ -167,7 +167,7 @@ export default function ScheduleForm({
};
} else {
// 새로운 캘린더 블록 생성 및 일정 추가
const nextSequence = await getSequence(token);
const nextSequence = await getSequence();
if (!nextSequence) return;
requestBody = {
type: 7,
Expand Down
12 changes: 4 additions & 8 deletions src/app/admin/components/home-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,7 @@ const HomeMenu = () => {
const router = useRouter();
async function handleLogout() {
try {
const response = await fetch("api/logout", {
method: "GET",
credentials: "include",
});

if (response.ok) {
alert("로그아웃 성공");
}
// 인증 관련 데이터 제거
} catch (error) {
console.error("로그아웃 중 오류 발생:", error);
}
Expand Down Expand Up @@ -58,6 +51,9 @@ const HomeMenu = () => {
<li className="p-2">
<button onClick={handleLogout}>Logout</button>
</li>
<li className="p-2">
<Link href={ClientRoute.LOGIN}>Login</Link>
</li>
</ul>
</div>
)}
Expand Down
77 changes: 28 additions & 49 deletions src/app/admin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,6 @@ export interface Block {

function Admin() {
useEffect(() => {
const setVisitor = async () => {
const adminApis = await adminApiInstance;
if (!adminApis) {
alert("로그인이 필요합니다");
if (typeof window !== "undefined") {
window.location.href = "/login";
return;
}
}
const response = await adminApis.getVisitor();
if (!response) return;
if (!response.ok) {
sessionStorage.removeItem("token");
// alert("방문자 조회 실패");
} else {
const infor = await response.json();
setShowToday(infor.data.today);
setShowRealTime(infor.data.realTime);
setShowTotal(infor.data.total);
}
};
// setVisitor()
// .then()
// .catch((e) => console.log(e));
getBlocks().then();
}, []);
useEffect(() => {
Expand Down Expand Up @@ -187,31 +163,34 @@ function Admin() {
{blocks === undefined || blocks.length == 0 ? (
<EmptyBlock />
) : (
blocks.map((block, index) => (
<BasicBlock
key={block.id}
id={block.id}
type={block.type}
title={block.title || "제목 없음"}
sequence={block.sequence}
style={block.style}
subText01={block.subText01}
subText02={block.subText02}
url={block.url}
imgUrl={block.imgUrl}
dateStart={block.dateStart}
dateEnd={block.dateEnd}
openYn={block.openYn}
keepYn={block.keepYn}
dateCreate={block.dateCreate}
dateUpdate={block.dateUpdate}
index={index}
dragStart={dragStart}
dragEnter={dragEnter}
drop={drop}
isAdmin={isAdmin}
/>
))
blocks.map((block, index) => {
console.log(block);
return (
<BasicBlock
key={block.id}
id={block.id}
type={block.type}
title={block.title || "제목 없음"}
sequence={block.sequence}
style={block.style}
subText01={block.subText01}
subText02={block.subText02}
url={block.url}
imgUrl={block.imgUrl}
dateStart={block.dateStart}
dateEnd={block.dateEnd}
openYn={block.openYn}
keepYn={block.keepYn}
dateCreate={block.dateCreate}
dateUpdate={block.dateUpdate}
index={index}
dragStart={dragStart}
dragEnter={dragEnter}
drop={drop}
isAdmin={isAdmin}
/>
);
})
)}
</div>
<PreviewModal
Expand Down
34 changes: 15 additions & 19 deletions src/app/intro/components/basicblock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,25 +121,18 @@ export default function BasicBlock({
}

async function deleteHandler() {
const token = sessionStorage.getItem("token");
if (!token) {
alert("인증 토큰이 없습니다.");
return;
}
console.log(id);
try {
const response = await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/api/link/delete`,
{
method: "POST",
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
id: id,
}),
const response = await fetch(`/api/link/delete`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
);
body: JSON.stringify({
id: id,
}),
});
if (!response.ok) {
alert("삭제 실패");
} else {
Expand Down Expand Up @@ -215,7 +208,10 @@ export default function BasicBlock({
{isAdmin ? (
<div className="ml-auto flex items-center space-x-2">
<ToggleButton />
<button onClick={toggleMenu} className="hover:bg-slate-200">
<button
onClick={toggleMenu}
className="relative hover:bg-slate-200"
>
<Image
src="/assets/icons/icon_menu_dot.png"
alt="menu_dot"
Expand All @@ -224,7 +220,7 @@ export default function BasicBlock({
className="ml-1 mt-[6px]"
/>
{isOpen && (
<div className="absolute mt-2 w-48 rounded-lg border border-gray-200 bg-white shadow-lg">
<div className="absolute mt-2 w-48 -translate-x-[90%] transform rounded-lg border border-gray-200 bg-white shadow-lg">
<ul className="py-1">
<li className="border-b px-4 py-2 font-bold hover:bg-slate-200">
상단에 고정
Expand Down