From 76059cfc5afe32c88f08aaabc7b7886990db8cec Mon Sep 17 00:00:00 2001
From: rkdgusdnr99 <112935900+rkdgusdnr99@users.noreply.github.com>
Date: Sun, 2 Jun 2024 00:47:00 +0900
Subject: [PATCH 3/8] =?UTF-8?q?=EB=B2=84=ED=8A=BC=20=ED=85=8D=EC=8A=A4?=
=?UTF-8?q?=ED=8A=B8=20=EC=83=89=EC=83=81=20=EC=B4=88=EB=A1=9D=EC=83=89?=
=?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
frontend/src/components/ui/button.tsx | 78 +++++++++++++--------------
1 file changed, 39 insertions(+), 39 deletions(-)
diff --git a/frontend/src/components/ui/button.tsx b/frontend/src/components/ui/button.tsx
index effbb4df..6a6687b4 100644
--- a/frontend/src/components/ui/button.tsx
+++ b/frontend/src/components/ui/button.tsx
@@ -5,51 +5,51 @@ import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@/lib/utils"
const buttonVariants = cva(
- "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-950 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 dark:ring-offset-gray-950 dark:focus-visible:ring-gray-300",
- {
- variants: {
- variant: {
- default: "bg-gray-900 text-gray-50 hover:bg-gray-900/90 dark:bg-gray-50 dark:text-gray-900 dark:hover:bg-gray-50/90",
- destructive:
- "bg-red-500 text-gray-50 hover:bg-red-500/90 dark:bg-red-900 dark:text-gray-50 dark:hover:bg-red-900/90",
- outline:
- "border border-gray-200 bg-white hover:bg-gray-100 hover:text-gray-900 dark:border-gray-800 dark:bg-gray-950 dark:hover:bg-gray-800 dark:hover:text-gray-50",
- secondary:
- "bg-gray-100 text-gray-900 hover:bg-gray-100/80 dark:bg-gray-800 dark:text-gray-50 dark:hover:bg-gray-800/80",
- ghost: "hover:bg-gray-100 hover:text-gray-900 dark:hover:bg-gray-800 dark:hover:text-gray-50",
- link: "text-gray-900 underline-offset-4 hover:underline dark:text-gray-50",
- },
- size: {
- default: "h-10 px-4 py-2",
- sm: "h-9 rounded-md px-3",
- lg: "h-11 rounded-md px-8",
- icon: "h-10 w-10",
- },
- },
- defaultVariants: {
- variant: "default",
- size: "default",
- },
- }
+ "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-950 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 dark:ring-offset-gray-950 dark:focus-visible:ring-gray-300",
+ {
+ variants: {
+ variant: {
+ default: "bg-gray-900 text-green-500 hover:bg-gray-900/90 dark:bg-gray-50 dark:text-gray-900 dark:hover:bg-gray-50/90", // text-gray-50 -> text-green-500
+ destructive:
+ "bg-red-500 text-green-500 hover:bg-red-500/90 dark:bg-red-900 dark:text-gray-50 dark:hover:bg-red-900/90", // text-gray-50 -> text-green-500
+ outline:
+ "border border-gray-200 bg-white text-green-500 hover:bg-gray-100 hover:text-gray-900 dark:border-gray-800 dark:bg-gray-950 dark:hover:bg-gray-800 dark:hover:text-gray-50", // 추가: text-green-500
+ secondary:
+ "bg-gray-100 text-green-500 hover:bg-gray-100/80 dark:bg-gray-800 dark:text-gray-50 dark:hover:bg-gray-800/80", // text-gray-900 -> text-green-500
+ ghost: "text-green-500 hover:bg-gray-100 hover:text-gray-900 dark:hover:bg-gray-800 dark:hover:text-gray-50", // 추가: text-green-500
+ link: "text-green-500 underline-offset-4 hover:underline dark:text-gray-50", // text-gray-900 -> text-green-500
+ },
+ size: {
+ default: "h-10 px-4 py-2",
+ sm: "h-9 rounded-md px-3",
+ lg: "h-11 rounded-md px-8",
+ icon: "h-10 w-10",
+ },
+ },
+ defaultVariants: {
+ variant: "default",
+ size: "default",
+ },
+ }
)
export interface ButtonProps
- extends React.ButtonHTMLAttributes
,
- VariantProps {
- asChild?: boolean
+ extends React.ButtonHTMLAttributes,
+ VariantProps {
+ asChild?: boolean
}
const Button = React.forwardRef(
- ({ className, variant, size, asChild = false, ...props }, ref) => {
- const Comp = asChild ? Slot : "button"
- return (
-
- )
- }
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
+ const Comp = asChild ? Slot : "button"
+ return (
+
+ )
+ }
)
Button.displayName = "Button"
From 8b45a41270c5fdf6df4f2924a157dd7402576870 Mon Sep 17 00:00:00 2001
From: rkdgusdnr99 <112935900+rkdgusdnr99@users.noreply.github.com>
Date: Sun, 2 Jun 2024 00:47:29 +0900
Subject: [PATCH 4/8] =?UTF-8?q?User=20=EC=A0=95=EB=B3=B4=20=EA=B0=80?=
=?UTF-8?q?=EC=A0=B8=EC=98=A4=EA=B8=B0=20session=20->=20repository?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/main/java/hello/aimju/user/service/UserService.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/backend/src/main/java/hello/aimju/user/service/UserService.java b/backend/src/main/java/hello/aimju/user/service/UserService.java
index 902fa420..89f5674d 100644
--- a/backend/src/main/java/hello/aimju/user/service/UserService.java
+++ b/backend/src/main/java/hello/aimju/user/service/UserService.java
@@ -57,7 +57,10 @@ public UserInfoResponseDto getUserInfo(Long userId) {
public UserDetailResponseDto getUserDetail(HttpSession session) {
User user = getUserFromSession(session);
- return new UserDetailResponseDto(user);
+ User curruentUser = userRepository.findById(user.getId())
+ .orElseThrow(() -> new IllegalArgumentException("해당 유저를 찾을 수 없습니다: " + user.getId()));
+
+ return new UserDetailResponseDto(curruentUser);
}
@Transactional
From bc5a50099a5877ba4045d9fdd0010d58e9f7fb3b Mon Sep 17 00:00:00 2001
From: rkdgusdnr99 <112935900+rkdgusdnr99@users.noreply.github.com>
Date: Sun, 2 Jun 2024 01:01:11 +0900
Subject: [PATCH 5/8] =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=8B=9C?=
=?UTF-8?q?=EC=9E=91=200=20->=201?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
frontend/src/app/boards/page.tsx | 104 +++++++++++++------------------
1 file changed, 43 insertions(+), 61 deletions(-)
diff --git a/frontend/src/app/boards/page.tsx b/frontend/src/app/boards/page.tsx
index 948d425f..bbc73445 100755
--- a/frontend/src/app/boards/page.tsx
+++ b/frontend/src/app/boards/page.tsx
@@ -1,28 +1,10 @@
-/**
-* This code was generated by v0 by Vercel.
-* @see https://v0.dev/t/xxZQctyMK7c
-* Documentation: https://v0.dev/docs#integrating-generated-code-into-your-nextjs-app
-*/
-
-/** Add fonts into your Next.js project:
-
-import { Libre_Franklin } from 'next/font/google'
-
-libre_franklin({
- subsets: ['latin'],
- display: 'swap',
-})
-
-To read more about using these font, please visit the Next.js documentation:
-- App Directory: https://nextjs.org/docs/app/building-your-application/optimizing/fonts
-- Pages Directory: https://nextjs.org/docs/pages/building-your-application/optimizing/fonts
-**/
'use client'
-import { Button } from "@/components/ui/button"
-import Link from "next/link"
-import { CardTitle, CardDescription, CardHeader, CardFooter, Card } from "@/components/ui/card"
-import {Header} from "@/components/ui/header";
-import React, {useEffect, useState} from "react";
+import * as React from "react";
+import { Button } from "@/components/ui/button";
+import Link from "next/link";
+import { CardTitle, CardDescription, CardHeader, CardFooter, Card } from "@/components/ui/card";
+import { Header } from "@/components/ui/header";
+import { useEffect, useState } from "react";
import axios from "axios";
import useUserStore from "@/store/useUserStore";
import useBoardStore from '@/store/useBoardStore';
@@ -36,59 +18,59 @@ type Board = {
};
export default function Board() {
- const [currentPage, setCurrentPage] = useState(0);
- const [totalPages, setTotalPages] = useState(0);
+ const [currentPage, setCurrentPage] = useState(1); // 페이지를 1부터 시작
+ const [totalPages, setTotalPages] = useState(1);
const [boards, setBoards] = useState([]);
- const {getState} = useUserStore;
+ const { getState } = useUserStore;
const ownBoard = useBoardStore((state) => state.ownBoard);
const [searchKeyword, setSearchKeyword] = useState('');
- const getBoards = async (page = 0)=>{
+ const getBoards = async (page = 1) => { // 기본값을 1로 설정
try {
let response;
- if(searchKeyword === ''){
- response = await axios.get('/api/boards', {
+ if (searchKeyword === '') {
+ response = await axios.get('/api/boards', {
params: {
- page: page,
+ page: page - 1, // 요청 시 페이지를 0부터 시작하도록 변환
}
});
- }else{
- response = await axios.get('/api/boards', {
+ } else {
+ response = await axios.get('/api/boards', {
params: {
- page: page,
+ page: page - 1,
searchKeyword: searchKeyword
}
});
}
- const boards: Board[] = await response.data.boardLists.map((b: any)=>({
+ const boards: Board[] = await response.data.boardLists.map((b: any) => ({
id: b.id,
title: b.title,
commentNum: b.commentNum,
createdTime: b.createdTime,
username: b.username,
}));
- setTotalPages((response?.data.totalPages ===0 ?0 : response?.data.totalPages-1));
+ setTotalPages((response?.data.totalPages === 0 ? 1 : response?.data.totalPages)); // 페이지를 1부터 시작하도록 설정
setBoards(boards);
setSearchKeyword(searchKeyword);
- } catch (error){
- console.log(error)
+ } catch (error) {
+ console.log(error);
}
};
- const getOwnBoards = async (page = 0) => {
+ const getOwnBoards = async (page = 1) => { // 기본값을 1로 설정
try {
let response;
if (searchKeyword === '') {
response = await axios.get('/api/boards/current-user', {
params: {
- page: page,
+ page: page - 1, // 요청 시 페이지를 0부터 시작하도록 변환
}
});
} else {
response = await axios.get('/api/boards/current-user', {
params: {
- page: page,
+ page: page - 1,
searchKeyword: searchKeyword
}
});
@@ -101,11 +83,11 @@ export default function Board() {
createdTime: b.createdTime,
username: b.username,
}));
- setTotalPages((response?.data.totalPages === 0 ? 0 : response?.data.totalPages - 1));
+ setTotalPages((response?.data.totalPages === 0 ? 1 : response?.data.totalPages)); // 페이지를 1부터 시작하도록 설정
setBoards(boards);
setSearchKeyword(searchKeyword);
} catch (error) {
- console.log(error)
+ console.log(error);
}
};
@@ -124,7 +106,7 @@ export default function Board() {
getBoards(currentPage - 1);
}
setCurrentPage(currentPage - 1);
- }
+ };
const handleNextPage = () => {
if (ownBoard === 1) {
@@ -133,7 +115,7 @@ export default function Board() {
getBoards(currentPage + 1);
}
setCurrentPage(currentPage + 1);
- }
+ };
const handleSearchChange = (e: React.ChangeEvent) => {
setSearchKeyword(e.target.value);
@@ -141,13 +123,13 @@ export default function Board() {
return (
<>
-
+
게시판
>
)
diff --git a/frontend/src/app/page.tsx b/frontend/src/app/page.tsx
index d38e8763..6ceb5490 100755
--- a/frontend/src/app/page.tsx
+++ b/frontend/src/app/page.tsx
@@ -26,6 +26,8 @@ import { CardTitle, CardHeader, CardContent, CardFooter, Card } from "@/componen
import { Header } from "@/components/ui/header";
import React, { useEffect, useState } from "react";
import { TrashIcon } from "lucide-react";
+// @ts-ignore
+import Modal from "react-modal";
type ChatRoom = {
menu: string;
@@ -35,8 +37,10 @@ type ChatRoom = {
export default function Main() {
const [chatRooms, setChatRooms] = useState