diff --git a/api/userInfo.ts b/api/userInfo.ts index 5df2eda..fa3c978 100644 --- a/api/userInfo.ts +++ b/api/userInfo.ts @@ -34,4 +34,13 @@ export const makeLikedRooms = async (id: number) => { 'Content-Type': 'application/json', }, }); +} + +export const makeDisLikedRooms = async (id: number) => { + return await fetchData(`/api/v1/rooms/${id}/disLiked`, { + method: 'DELETE', + headers: { + 'Content-Type': 'application/json', + }, + }); } \ No newline at end of file diff --git a/components/Input/Input.tsx b/components/Input/Input.tsx index 9438862..f681250 100644 --- a/components/Input/Input.tsx +++ b/components/Input/Input.tsx @@ -21,7 +21,7 @@ function Input({ placeholder, register, type, error, maxLength, disabled, fixedW } return type; }, [type, isPasswordShow]); - const [inputValue, setInputValue] = useState('' as string); + const [inputValue, setInputValue] = useState(fixedWord || '' as string); const togglePasswordVisibility = () => { setIsPasswordShow((state) => !state); diff --git a/components/ProfileCard/index.tsx b/components/ProfileCard/index.tsx index 931ebad..35e025a 100644 --- a/components/ProfileCard/index.tsx +++ b/components/ProfileCard/index.tsx @@ -11,12 +11,14 @@ import Vector from '@/public/icons/Vector 115.svg'; import { useRouter } from 'next/router'; import useModal from '@/hooks/useModal.ts'; import { signOut } from 'next-auth/react'; +import { User } from '@/public/types/user'; interface ProfileCardProps { name: string; age: number; gender: 'Male' | 'Female'; imageSrc: string; + userInfo: User } interface ListItemProps { @@ -25,9 +27,10 @@ interface ListItemProps { route: string; index: number; onclick?: () => void; + } -export default function ProfileCard({ name, age, gender, imageSrc }: ProfileCardProps) { +export default function ProfileCard({ name, age, gender, imageSrc, userInfo }: ProfileCardProps) { const { register } = useForm({ mode: 'onChange' }); const [showModal, setShowModal] = useState(false); const [hoveredIndex, setHoveredIndex] = useState(null); @@ -39,6 +42,7 @@ export default function ProfileCard({ name, age, gender, imageSrc }: ProfileCard setShowModal(true); return; } + debugger; router.push(route); }; @@ -50,7 +54,7 @@ export default function ProfileCard({ name, age, gender, imageSrc }: ProfileCard custom: true, customHeader: true, }, - children: , + children: , }); }; diff --git a/components/RoomCard/RoomCard.tsx b/components/RoomCard/RoomCard.tsx index 352eb50..d58d108 100644 --- a/components/RoomCard/RoomCard.tsx +++ b/components/RoomCard/RoomCard.tsx @@ -10,11 +10,12 @@ import Camera from '@/public/icons/camera.svg'; import styles from '@/pages/room/room.module.scss'; import { useRouter } from 'next/router'; import Card from '../Card/Card'; -import { makeLikedRooms } from '@/api/userInfo'; +import { makeLikedRooms, makeDisLikedRooms } from '@/api/userInfo'; interface CardProps { room: RoomSearch; onClick?: () => void; + isLikedRooms?: boolean; } interface UserInfoProps { @@ -81,12 +82,12 @@ const Photo = ({ photos, onClick }: PhotoProps) => { ); }; -const Footer = ({ room }: CardProps) => { +const Footer = ({ room, isLikedRooms }: CardProps) => { const roomType = room.roomInfo.roomType === ROOM_TYPE.ONE_ROOM ? '1bed flats' : ''; - const [isLiked, setIsLiked] = useState(false); + const [isLiked, setIsLiked] = useState(false || isLikedRooms); const handleLikeClick = async () => { try { - await makeLikedRooms(room?.id); + !isLiked ? await makeLikedRooms(room?.id) : await makeDisLikedRooms(room?.id); setIsLiked(!isLiked); } catch (error) { console.error('[ERROR] in Liked Clicked', error); @@ -125,12 +126,12 @@ const Footer = ({ room }: CardProps) => { ); }; -export default function RoomCard({ room, onClick }: CardProps) { +export default function RoomCard({ room, onClick, isLikedRooms }: CardProps) { return ( } content={} - footer={