Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion src/app/(home)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { motion, AnimatePresence } from "framer-motion";
import Image from "next/image";
import Lenis from "@studio-freight/lenis";
import { useMediaQuery } from "react-responsive";
import TypewriterText from "../components/animation/typewriterText";
import TypewriterText from "../components/animation/TypewriterText";

const slides = [
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/(pages)/(workform)/apply/[formId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default function Apply() {
await queryClient.invalidateQueries({ queryKey: ["formDetail", formId] });

toast.success("지원이 완료되었습니다.");
router.push("/my-workform");
router.push(`/work/${formId}`);
},

onError: (error) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ContentSection from "@/app/components/layout/ContentSection";
import useWidth from "@/hooks/useWidth";
import ScrollTopButton from "@/app/components/button/default/ScrollTopButton";
import SamllLoadingSpinner from "@/app/components/loading-spinner/SmallLoadingSpinner";
import LoadingSpinner from "@/app/components/loading-spinner/LoadingSpinner";

export default function CommentsSection() {
const [currentPage, setCurrentPage] = useState(1);
Expand Down Expand Up @@ -43,6 +44,10 @@ export default function CommentsSection() {
window.scrollTo(0, 0);
};

if (isLoading) {
return <LoadingSpinner />;
}

if (error) {
return (
<div className="flex h-[calc(100vh-300px)] items-center justify-center">
Expand Down
16 changes: 14 additions & 2 deletions src/app/(pages)/mypage/components/sections/PostsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import ScrollTopButton from "@/app/components/button/default/ScrollTopButton";
import BoardPostItem from "@/app/components/card/board/BoardPostItem";
import DotLoadingSpinner from "@/app/components/loading-spinner/DotLoadingSpinner";
import SamllLoadingSpinner from "@/app/components/loading-spinner/SmallLoadingSpinner";
import LoadingSpinner from "@/app/components/loading-spinner/LoadingSpinner";
import { useUser } from "@/hooks/queries/user/me/useUser";

export default function PostsSection() {
const { orderBy } = useMySortStore();
Expand All @@ -36,7 +38,7 @@ export default function PostsSection() {
limit: postsPerPage,
orderBy: orderBy.posts,
});

const { user } = useUser();
useEffect(() => {
if (inView && hasNextPage && !isFetchingNextPage) {
fetchNextPage();
Expand All @@ -51,6 +53,10 @@ export default function PostsSection() {
);
}

if (isLoading) {
return <LoadingSpinner />;
}

return (
<div className="flex flex-col items-center">
{/* 메인 콘텐츠 영역 */}
Expand All @@ -70,7 +76,13 @@ export default function PostsSection() {
{data.pages.map((page) => (
<React.Fragment key={page.nextCursor}>
{page.data.map((post) => (
<BoardPostItem post={post} key={post.id} />
<BoardPostItem
post={post}
key={post.id}
isAuthor={!!(post.writer.id === user?.id)}
limit={postsPerPage}
orderBy={orderBy.posts}
/>
))}
</React.Fragment>
))}
Expand Down
8 changes: 8 additions & 0 deletions src/app/(pages)/mypage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import CommentsSection from "./components/sections/CommentsSection";
import ScrapsSection from "./components/sections/ScrapsSection";
import { userRoles } from "@/constants/userRoles";
import { useUser } from "@/hooks/queries/user/me/useUser";
import toast from "react-hot-toast";
import { useRouter } from "next/navigation";

export default function MyPage() {
const searchParams = useSearchParams();
const currentTab = searchParams.get("tab") || "posts";
const router = useRouter();
const { user } = useUser();
const isApplicant = user?.role === userRoles.APPLICANT;

Expand All @@ -19,5 +22,10 @@ export default function MyPage() {
...(isApplicant && { scrap: <ScrapsSection /> }),
}[currentTab];

if (!user) {
toast.error("로그인이 필요한 페이지입니다.");
// router.push("/login");
}

return TabContent;
}
12 changes: 8 additions & 4 deletions src/app/components/button/dropdown/KebabDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ const KebabDropdown = ({ options, className = "" }: KebabDropdownProps) => {
<div ref={dropdownRef} className={cn("relative inline-block text-left", className)}>
<button
type="button"
onClick={() => setIsOpen(!isOpen)}
className="rounded-full hover:bg-grayscale-50"
onClick={(e) => {
setIsOpen(!isOpen);
e.stopPropagation();
}}
className="rounded-full transition-transform hover:scale-125 hover:bg-grayscale-50"
aria-label="메뉴 더보기"
>
<BsThreeDotsVertical className="text-sm text-grayscale-200 lg:text-xl" />
<BsThreeDotsVertical className="text-md text-grayscale-200 lg:text-xl" />
</button>

{isOpen && (
Expand All @@ -42,7 +45,8 @@ const KebabDropdown = ({ options, className = "" }: KebabDropdownProps) => {
<button
type="button"
key={`${index}-${option.label}`}
onClick={() => {
onClick={(e) => {
e.stopPropagation();
option.onClick();
setIsOpen(false);
}}
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/card/board/BoardComment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const BoardComment = ({

return (
<Link href={`work-talk/${postId}`}>
<div className="relative flex h-[202px] w-[327px] flex-col gap-2 rounded-[16px] border border-line-200 bg-grayscale-50 p-6 shadow-md md:w-[600px] lg:h-[264px] lg:w-full">
<div className="relative flex h-[202px] w-[327px] flex-col gap-2 rounded-[16px] border border-line-200 bg-grayscale-50 p-6 shadow-md transition-transform hover:scale-105 md:w-[600px] lg:h-[264px] lg:w-full">
{/* Post Section */}
<div className="flex w-full flex-col gap-4 border-b border-line-100 pb-2 lg:pb-4">
<div className="flex items-center gap-[6px] lg:gap-2">
Expand Down
59 changes: 58 additions & 1 deletion src/app/components/card/board/BoardPostItem.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,63 @@
"use client";
import { PostListType } from "@/types/response/post";
import { formatLocalDate } from "@/utils/workDayFormatter";
import Image from "next/image";
import Link from "next/link";
import KebabDropdown from "../../button/dropdown/KebabDropdown";
import { useRouter } from "next/navigation";
import useModalStore from "@/store/modalStore";
import { useDeleteComment } from "@/hooks/queries/post/comment/useDeleteComment";
import { useQueryClient } from "@tanstack/react-query";

const BoardPostItem = ({
post,
isAuthor,
limit,
orderBy,
}: {
post: PostListType;
isAuthor: boolean;
limit: number;
orderBy: string;
}) => {
const router = useRouter();
const deleteComment = useDeleteComment(String(post.id));
const queryClient = useQueryClient();
const { openModal, closeModal } = useModalStore();

const handleDelete = () => {
openModal("customForm", {
isOpen: true,
title: "게시글을 삭제할까요?",
content: "삭제된 게시글은 복구할 수 없습니다.",
confirmText: "삭제하기",
cancelText: "취소",
onConfirm: () => {
deleteComment.mutate(undefined, {
onSuccess: async () => {
await queryClient.invalidateQueries({ queryKey: ["post"] });
await queryClient.invalidateQueries({ queryKey: ["myPosts", { limit, orderBy }] });
closeModal();
},
});
},
onCancel: () => {
closeModal();
},
});
};

const dropdownOptions = [
{
label: "수정하기",
onClick: () => router.push(`/work-talk/${post.id}/edit`),
},
{
label: "삭제하기",
onClick: handleDelete,
},
];

const BoardPostItem = ({ post }: { post: PostListType }) => {
return (
<Link
href={`/work-talk/${post.id}`}
Expand Down Expand Up @@ -48,6 +102,9 @@ const BoardPostItem = ({ post }: { post: PostListType }) => {
</div>
</div>
</div>
<div className="absolute right-3 top-6 size-9 text-center" onClick={(e) => e.stopPropagation()}>
{isAuthor && <KebabDropdown options={dropdownOptions} />}
</div>
</div>
</Link>
);
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/card/cardList/AlbaListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ const AlbaListItem = ({
<BsThreeDotsVertical className="h-6 w-6" />
</button>
{showDropdown && (
<div className="absolute right-0 top-8 z-10 w-32 rounded-lg border border-grayscale-200 bg-white py-2 shadow-lg">
<div className="absolute right-0 top-8 z-10 w-32 overflow-hidden rounded-lg border border-grayscale-200 bg-white shadow-lg">
{isApplicant ? (
<>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ const post = {
createdAt: new Date(),
};
export const Default: Story = {
args: { post },
args: { post, isAuthor: true, limit: 10, orderBy: "최신순" },
};
Loading