Skip to content

Commit

Permalink
fix: mypage 프로필 이미지 api 수정중
Browse files Browse the repository at this point in the history
  • Loading branch information
eun-hak committed Jun 3, 2024
1 parent ba885bd commit 0511ae2
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 53 deletions.
9 changes: 9 additions & 0 deletions src/api/auth/auth.patch.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,12 @@ export const changepassword = async ({

return response;
};

export const memberimage = async (imageData: FormData) => {
const response = await patchRequest<ICommon<null>, FormData>(
'members/image',
imageData
);

return response;
};
41 changes: 0 additions & 41 deletions src/firebase/firebasedb.ts

This file was deleted.

8 changes: 1 addition & 7 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,13 @@ export default function App({ Component, pageProps }: AppProps) {
return (
<MockProvider>
<QueryProvider>
<Script
strategy="beforeInteractive"
src={`https://openapi.map.naver.com/openapi/v3/maps.js?ncpClientId=${process.env.NEXT_PUBLIC_NAVER_MAP_CLIENT_ID}`}></Script>
<QueryClientProvider client={queryClient}>
<Component {...pageProps} />
<ReactQueryDevtools initialIsOpen={false} />
</QueryClientProvider>
<Script
strategy="beforeInteractive"
src={`https://openapi.map.naver.com/openapi/v3/maps.js?ncpClientId=${process.env.NEXT_PUBLIC_NAVER_MAP_CLIENT_ID}`}></Script>
<AuthorizationProvider>
<QueryClientProvider client={queryClient}>
<Component {...pageProps} />
<ReactQueryDevtools initialIsOpen={false} />
</QueryClientProvider>
</AuthorizationProvider>
</QueryProvider>
Expand Down
18 changes: 15 additions & 3 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
'use client';
import { userinfo } from '@/api/auth/auth.get.api';
import Footer from '@/components/footer/Footer';
import MainPageIndex from '@/components/home/MainPageIndex';
import MainContainer from '@/components/shared/MainContainer';
import React from 'react';
import { useMember, useSetMember } from '@/store/user';
import React, { useEffect } from 'react';
import { useQuery } from 'react-query';

const Index = () => {
const member = useMember();
const { data: memberData } = useQuery({ queryKey: ['userinfo'], queryFn: userinfo });
const setmember = useSetMember();
useEffect(() => {
console.log(memberData);
setmember(memberData?.data);
}, [memberData, setmember]);
console.log(member);

const index = () => {
return (
<MainContainer>
<MainPageIndex />
Expand All @@ -13,4 +25,4 @@ const index = () => {
);
};

export default index;
export default Index;
11 changes: 9 additions & 2 deletions src/pages/mypage/changeprofile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Link from 'next/link';
import { useMember } from '@/store/user';
import { getTitleFromDescription, jobPosition } from '@/constant/jobPosition';
import { BackArrow } from '@/components/backarrow/BackArrow';
import { memberimage } from '@/api/auth/auth.patch.api';
// import { useQuery } from 'react-query'; // Uncomment when useQuery is available

export default function Profile() {
Expand All @@ -28,9 +29,15 @@ export default function Profile() {
// console.log(formData);

// };

console.log(member.imageUrl);
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
if (event.target.files && event.target.files.length > 0) {
const file = event.target.files[0];
const formData = new FormData();
formData.append('images', file);
console.log(formData);
memberimage(formData);

setSelectedFile(event.target.files[0]);
const reader = new FileReader();
reader.onload = function (e) {
Expand Down Expand Up @@ -67,7 +74,7 @@ export default function Profile() {
) : (
<img
className="w-24 h-24 rounded-full"
src="/mypage/profilechange/ProfileImage.svg"
src={member.imageUrl}
alt="Profile Picture"
/>
)}
Expand Down

0 comments on commit 0511ae2

Please sign in to comment.