-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from Garodden/feature/front_user
Feat: User 프론트 백엔드 연동 작업
- Loading branch information
Showing
6 changed files
with
83 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import Header from "@/components/Layout/Header.jsx"; | ||
import {Avatar, AvatarImage, AvatarFallback} from "@/components/ui/avatar.jsx"; | ||
import {useState} from "react"; | ||
import {useEffect, useState} from "react"; | ||
import {Link} from "react-router-dom"; | ||
import {Tabs, TabsList, TabsTrigger, TabsContent} from "@/components/ui/tabs"; | ||
import { Input } from "@/components/ui/input"; | ||
|
@@ -9,6 +9,8 @@ import { Button } from "@/components/ui/button"; | |
import FollowInfo from "@/components/FollowInfo"; | ||
import MyResumes from "@/components/MyResumes"; | ||
import { anchorScrollCallback } from "@/utils/common"; | ||
import { saveProfileReqParam } from "@/utils/Parameter"; | ||
import { fetchUserProfile, saveProfile } from "@/utils/API"; | ||
|
||
const MyPage = () => { | ||
//Mypage, UserPage는 유저 정보를 통해 pageOwner인지 판단한 후 구별이 가능 | ||
|
@@ -23,11 +25,36 @@ const MyPage = () => { | |
const [location, setLocation] = useState('Location'); | ||
const [description, setDescription] = useState('Description'); | ||
const [username, setUsername] = useState('Username'); | ||
const [file, setFile] = useState(null); | ||
|
||
useEffect(() =>{ | ||
fetchUserProfile("[email protected]") | ||
.then(async (userInfo) => { | ||
setUsername(userInfo.realName); | ||
setIdentity(userInfo.identity); | ||
setLocation(userInfo.location); | ||
setDescription(userInfo.description); | ||
|
||
//user Profile image 설정 | ||
setProfilePic(`data:image/png;base64,${userInfo.image}`); | ||
}); | ||
},[]); | ||
|
||
const toggleEditing = () => { | ||
setEditing(!editing); | ||
}; | ||
|
||
//프로필 변경 사항 저장 API | ||
const doSaveProfile = () =>{ | ||
const reqParam = saveProfileReqParam("[email protected]", identity, location, description, file); | ||
|
||
saveProfile(reqParam) | ||
.then((response) => { | ||
console.log(response); | ||
toggleEditing(); | ||
}); | ||
} | ||
|
||
const handleProfilePicChange = (event) => { | ||
const file = event.target.files[0]; | ||
const reader = new FileReader(); | ||
|
@@ -53,7 +80,7 @@ const MyPage = () => { | |
<strong>{username}</strong> | ||
<div className="flex gap-2 text-black/65"> | ||
<Link to="/findPassword">비밀번호 변경</Link> | ||
<Link to="">회원 탈퇴</Link> | ||
<Link to="/resign">회원 탈퇴</Link> | ||
</div> | ||
</div> | ||
<div className="flex flex-col gap-4"> | ||
|
@@ -63,8 +90,8 @@ const MyPage = () => { | |
<Input className="w-full mt-2" maxLength={100} type="text" value={identity} onChange={e => setIdentity(e.target.value)}/> | ||
<Input className="w-full" maxLength={50} type="text" value={location} onChange={e => setLocation(e.target.value)}/> | ||
<Textarea className="w-full resize-none" maxLength={2000} value={description} onChange={e => setDescription(e.target.value)}/> | ||
<Input type="file" onChange={handleProfilePicChange}/> | ||
<Button onClick={toggleEditing} variant="ghost" className="text-black text-opacity-40"> | ||
<Input type="file" accept=".png" onChange={(ev) => { handleProfilePicChange(ev); setFile(ev.target.files[0])}}/> | ||
<Button onClick={doSaveProfile} variant="ghost" className="text-black text-opacity-40"> | ||
Save Changes | ||
</Button> | ||
</>) : | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,20 +3,25 @@ import {useNavigate} from "react-router-dom"; | |
import {GlobalContext} from ".."; | ||
import {Button} from "@/components/ui/button"; | ||
import {Input} from "@/components/ui/input"; | ||
import { AlertDialog, AlertDialogTrigger, AlertDialogContent,AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogCancel, AlertDialogAction } from "@/components/ui/alert-dialog"; | ||
import LabelSection from "@/components/Layout/LabelSection"; | ||
import { withdrawReqParam } from "@/utils/Parameter"; | ||
import { logout, withdraw } from "@/utils/API"; | ||
|
||
const Resign = () => { | ||
const { setLogin } = useContext(GlobalContext); | ||
const navigate = useNavigate(); | ||
const [currentPassword, setCurrentPassword] = useState(''); | ||
|
||
const handleResign = () => { | ||
if (window.confirm("정말로 회원을 탈퇴하시겠습니까?")) { | ||
// 회원 탈퇴 로직을 실행 | ||
alert("회원 탈퇴가 완료되었습니다."); | ||
setLogin(false); | ||
//가데이터 | ||
const reqParam = withdrawReqParam("[email protected]", currentPassword, true); | ||
|
||
withdraw(reqParam) | ||
.then((response) => { | ||
alert("회원탈퇴에 성공했습니다. 그동안 저희 서비스를 이용해주셔서 감사합니다."); | ||
logout(); | ||
navigate("/login"); | ||
} | ||
}); | ||
}; | ||
|
||
// Navigate to mypage | ||
|
@@ -33,9 +38,24 @@ const Resign = () => { | |
<Input id="cur_pwd" type="password" placeholder="current password" | ||
value={currentPassword} onChange={(e => setCurrentPassword(e.target.value))}/> | ||
</LabelSection> | ||
<Button className="bg-[#6866EB] mt-4 w-full hover:bg-violet-600" onClick={handleResign}> | ||
<div>탈퇴하기</div> | ||
</Button> | ||
<AlertDialog> | ||
<AlertDialogTrigger asChild> | ||
<Button className="bg-[#6866EB] mt-4 w-full hover:bg-violet-600">탈퇴하기</Button> | ||
</AlertDialogTrigger> | ||
<AlertDialogContent> | ||
<AlertDialogHeader> | ||
<AlertDialogTitle>정말 회원 탈퇴하시겠어요?</AlertDialogTitle> | ||
<AlertDialogDescription> | ||
회원 탈퇴 이후엔 되돌릴 수 없어요. 신중하게 선택해주세요. 정말 탈퇴하시겠어요? | ||
</AlertDialogDescription> | ||
</AlertDialogHeader> | ||
<AlertDialogFooter> | ||
<AlertDialogCancel>취소</AlertDialogCancel> | ||
<AlertDialogAction onClick={handleResign}>탈퇴</AlertDialogAction> | ||
</AlertDialogFooter> | ||
</AlertDialogContent> | ||
</AlertDialog> | ||
|
||
<Button className="bg-[#6866EB] mt-4 w-full hover:bg-violet-600" onClick={handleGoBack}> | ||
<div>돌아가기</div> | ||
</Button> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters