Skip to content

Commit

Permalink
Merge branch 'main' into feat/#68
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaeunnn committed Aug 14, 2024
2 parents b87d249 + cbca73b commit db830f4
Show file tree
Hide file tree
Showing 48 changed files with 623 additions and 201 deletions.
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"react-scripts": "^5.0.1",
"react-swipeable": "^7.0.1",
"recoil": "^0.7.7",
"recoil-persist": "^5.1.0",
"request": "^2.88.2",
"source-map": "^0.7.4",
"styled-components": "^6.1.11",
Expand Down
10 changes: 10 additions & 0 deletions src/apis/deleteShareGroup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { authInstance } from './instance';

export async function deleteShareGroup(shareGroupId: number): Promise<void> {
try {
await authInstance().delete(`/shareGroups/${shareGroupId}`);
} catch (error) {
console.error('Error deleting share group:', error);
throw error;
}
}
22 changes: 22 additions & 0 deletions src/apis/getMembers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
emailResponse,
marketingResponse,
deleteResponse,
samplePhotoResponse,
} from '../recoil/types/members';
import axios from 'axios';

Expand Down Expand Up @@ -81,3 +82,24 @@ export const deleteUser = async (memberId: number) => {
}
}
};

// 샘플 사진 업로드 여부 조회 (GET)
export const getHasSamplePhoto = async () => {
try {
const response =
await authInstance().get<samplePhotoResponse>(`/members/samplePhoto`);
const { status, code, message, data } = response.data;

if (status === 200) {
return data.hasSamplePhoto;
} else {
throw new Error(`Error ${code}: ${message}`);
}
} catch (err: unknown) {
if (axios.isAxiosError(err)) {
throw new Error(`Axios error: ${err.message}`);
} else {
throw new Error('샘플 사진 업로드 여부 조회 중 오류 발생.');
}
}
};
29 changes: 29 additions & 0 deletions src/apis/getMyInviteCode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { authInstance } from './instance';

interface IInviteCode {
inviteCode: string;
inviteUrl: string;
}

export async function getMyInviteCode({
shareGroupId,
}: {
shareGroupId: number;
}): Promise<IInviteCode> {
try {
const response = await authInstance().get(
`/shareGroups/${shareGroupId}/invite`,
);
if (response.status === 200) {
return {
inviteCode: response.data.inviteCode,
inviteUrl: response.data.inviteUrl,
};
} else {
throw new Error('Failed to fetch invite code');
}
} catch (error) {
console.error('Error fetching invite code:', error);
throw error;
}
}
59 changes: 59 additions & 0 deletions src/apis/getMyShareGroup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { ApiResponse } from 'recoil/types/notice';
import { authInstance } from './instance';

interface IShareGroupInfo {
shareGroupId: number;
name: string;
image: string;
memberCount: number;
inviteUrl: string;
createdAt: string;
}

interface profile {
profileId: number; // 프로필 id
name: string; // 프로필 이름
image: string; // URL 형식
memberId: number; // 해당 프로필로 참여한 회원의 id. 생략할지 고민중
}

interface IShareGroupMember {
shareGroupId: number;
name: string;
image: string;
memberCount: number;
inviteUrl: string;
createdAt: string;
profileInfoList: profile[];
}

// eslint-disable-next-line prettier/prettier
export async function getMyShareGroup(): Promise<IShareGroupInfo[]> {
try {
const response = await authInstance().get('/shareGroups/my');
if (response.status === 200) {
return response.data.data.shareGroupInfoList;
} else {
throw new Error('Failed to fetch share group');
}
} catch (error) {
console.error('Error fetching share group:', error);
throw error;
}
}

export async function getShareGroupMembers(
shareGroupId: number,
): Promise<IShareGroupMember> {
try {
const response = await authInstance().get(`/shareGroups/${shareGroupId}`);
if (response.status === 200) {
return response.data.data;
} else {
throw new Error('Failed to fetch share group members');
}
} catch (error) {
console.error('Error fetching share group members:', error);
throw error;
}
}
8 changes: 3 additions & 5 deletions src/apis/postPhotoUpload.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { PostApiResponse } from 'recoil/types/notice';
import { authInstance } from './instance';
interface requestProp {
shareGroupId: number;
shareGroupId?: number;
photoUrlList: string[];
}

export const postPhotoUpload = async (
requestData: requestProp,
): Promise<{ data: any }> => {
try {
const res = await authInstance().post<PostApiResponse>(
`/photos/upload`,
requestData,
);
const url = requestData.shareGroupId ? '/photos/upload' : '/photos/sample';
const res = await authInstance().post<PostApiResponse>(url, requestData);
const { status, code, message, data } = res.data;
if (status === 200) {
return { data };
Expand Down
1 change: 0 additions & 1 deletion src/apis/postPresignedUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { PostApiResponse } from 'recoil/types/notice';
import { authInstance } from './instance';

interface requestProp {
shareGroupId: number;
photoNameList: string[];
}

Expand Down
Binary file modified src/assets/background/cloud_upper_below.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/samples/emptyProfile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/Common/DropDown/Styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const ExpendLayout = styled.div<LayoutProps>`
position: ${({ noIndexTag }) => (noIndexTag ? 'absolute' : 'relative')};
top: 10%;
left: 2rem;
z-index: 1;
z-index: 2;
`;

export const IconLayout = styled.div`
Expand Down
4 changes: 3 additions & 1 deletion src/components/Header/Styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ export const Layout = styled.div`
padding: 0 1rem;
`;

export const IconLayout = styled.button``;
export const IconLayout = styled.button`
cursor: pointer;
`;
31 changes: 10 additions & 21 deletions src/components/MyPage/MyPageMain.tsx
Original file line number Diff line number Diff line change
@@ -1,53 +1,42 @@
import React, { useEffect, useState } from 'react';
import React, { useState } from 'react';
import * as S from './Styles';
import logoblurred from '../../assets/logo/typo-blurred.png';
import background from 'assets/background/cloudLeft.png';
import { getMyInfo } from 'apis/getMyInfo';

import { useSetRecoilState } from 'recoil';
import { useRecoilValue, useSetRecoilState } from 'recoil';
import {
myPageModalState,
modalMessageState,
modalDataState,
} from 'recoil/states/mypage';

interface responseType {
name: string;
email: string;
image: string;
memberId: number; // memberId 추가
}
import { UserState } from 'recoil/states/enter';

const MyPageMain = () => {
const [data, setData] = useState<responseType>();
const userInfo = useRecoilValue(UserState);
const setModalOpen = useSetRecoilState(myPageModalState);
const setModalMessage = useSetRecoilState(modalMessageState);
const setModalData = useSetRecoilState(modalDataState);

const openLogoutModal = () => {
setModalMessage('로그아웃 하시겠습니까?');
setModalOpen(true);
};

const openWithdrawalModal = () => {
setModalMessage('탈퇴하시겠습니까? 데이터는 복구할 수 없습니다.');
if (data) {
setModalData({ memberId: data.memberId });
if (userInfo) {
setModalData({ memberId: userInfo.memberId });
setModalOpen(true);
} else setModalOpen(true);
};

useEffect(() => {
getMyInfo()
.then((res) => setData(res.data))
.catch((error) => console.error(error));
}, []);
return (
<S.Layout>
<S.Background src={background}></S.Background>
<S.Profile image={data?.image} />
<S.Profile src={userInfo?.image} />
<S.Logo src={logoblurred} />
<S.EmailText>{data?.email}</S.EmailText>
<S.NameText>{data?.name}</S.NameText>
<S.EmailText>{userInfo?.email}</S.EmailText>
<S.NameText>{userInfo?.name}</S.NameText>
<S.LogOutBtn onClick={openLogoutModal} />
<S.OutServiceBtn onClick={openWithdrawalModal} />
<S.BtnText style={{ top: '66%', left: '50%' }} onClick={openLogoutModal}>
Expand Down
5 changes: 2 additions & 3 deletions src/components/MyPage/Styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@ export const ProfileContainer = styled.div`
transform: translate(-50%, -50%);
`;

export const Profile = styled.div<{ image?: string }>`
export const Profile = styled.img`
position: absolute;
width: 35%;
height: 16%;
border-radius: 50%;
top: 35%;
left: 50%;
transform: translate(-50%, -50%);
background-image: ${(props) =>
props.image ? `url(${props.image})` : `url(${I.Profile})`};
object-fit: cover;
`;

export const EmailText = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ const ShareGroupAddButton: React.FC<ShareGroupAddButtonProps> = ({
<S.Cloud />
{showButton && (
<S.RectContainer>
<StyledNavLink to="/join_group">
<StyledNavLink to="join">
<ShareGroupRectButton />
</StyledNavLink>
<StyledNavLink to="/addCount/headCount">
<StyledNavLink to="add/member">
<ShareGroupRectButton add />
</StyledNavLink>
</S.RectContainer>
Expand Down
5 changes: 2 additions & 3 deletions src/components/ShareGroup/ShareGroupCarousel/Styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ export const CarouselTrack = styled.div<{
`;

export const CarouselBlankItem = styled.div<{ isRight?: boolean }>`
height: 200px;
background: red;
margin-right: ${(props) => (props.isRight ? '4rem' : 0)};
margin-left: ${(props) => (props.isRight ? 0 : '4rem')};
margin-right: ${(props) => (props.isRight ? '18%' : 0)};
margin-left: ${(props) => (props.isRight ? 0 : '18%')};
`;

export const Dot = styled.div<{ active: boolean }>`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';
import * as S from './Styles';
import { useNavigate, useParams } from 'react-router-dom';
import defaultProfile from '../../../assets/samples/emptyProfile.png';

interface CarouselItemProps {
profileId: number;
profileId?: number;
active: boolean;
profileImage?: string;
name?: string;
Expand All @@ -22,17 +23,21 @@ const ShareGroupCarouselItem: React.FC<CarouselItemProps> = ({
active={active}
onClick={() =>
navigatte(`/group/detail`, {
state: { shareGroupId: id, profileId: profileId },
state: {
shareGroupId: id,
profileId: profileId,
profileImage: profileImage,
},
})
}
>
<S.SvgContainer>
<S.Folder />
<S.ContentBox>
{profileImage ? (
<S.Img src="https://avatars.githubusercontent.com/u/6400346?v=4" />
<S.Img src={profileImage} />
) : (
<S.Profile />
<S.Img src={defaultProfile} />
)}
<S.Name>{name}</S.Name>
</S.ContentBox>
Expand Down
Loading

0 comments on commit db830f4

Please sign in to comment.