Skip to content

Commit

Permalink
Merge pull request #945 from 42organization/GGFE-173-보관함-프로필-이미지띠-배경색-모달
Browse files Browse the repository at this point in the history
[GGFE-173] 보관함 프로필 이미지띠 배경색 모달
  • Loading branch information
hyobb109 authored Aug 22, 2023
2 parents 7be909e + e17faf0 commit 11d5d01
Show file tree
Hide file tree
Showing 32 changed files with 494 additions and 123 deletions.
2 changes: 1 addition & 1 deletion components/Layout/MainPageProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const MainPageProfile = () => {
>
<PlayerImage
src={user.userImageUri}
styleName={'mainPageProfile'}
styleName={`mainPageProfile ${user.edge.toLowerCase()}`}
size={18}
/>
</Link>
Expand Down
5 changes: 3 additions & 2 deletions components/Layout/MenuBar/MenuBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ const MenuProfile = () => {
snsNotiOpt: 'SLACK',
tierImageUri: '',
tierName: '',
edge: '',
edge: 'BASIC',
backgroundType: 'BASIC',
});

/* const getProfile = useAxiosGet({
Expand Down Expand Up @@ -73,7 +74,7 @@ const MenuProfile = () => {
>
<PlayerImage
src={user.userImageUri}
styleName={'menuProfile'}
styleName={`menuProfile ${user.edge.toLowerCase()}`}
size={18}
/>
</Link>
Expand Down
8 changes: 7 additions & 1 deletion components/PlayerImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ export default function PlayerImage({
}: PlayerImageProps) {
const [imgError, setImgError] = useState(false);
const imgSrc = !src || imgError ? fallBack : src;
const [parentStyle, childStyle] = styleName.split(' ');

return (
<div className={styles[styleName]}>
<div
className={`${styles[parentStyle]} ${
childStyle ? styles[childStyle] : ''
}`}
>
<div>
<Image
src={imgSrc}
Expand Down
1 change: 0 additions & 1 deletion components/modal/ModalProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export default function ModalProvider() {
const closeModalHandler = (e: React.MouseEvent) => {
if (modalName?.split('-')[0] === 'FIXED') return;
if (e.target instanceof HTMLDivElement && e.target.id === 'modalOutside') {
console.log(isAttended);
if (modalName === 'MATCH-CANCEL') setReloadMatch(true);
else if (modalName === 'EVENT-ANNOUNCEMENT' && !isAttended) {
setModal({ modalName: 'EVENT-WELCOME' });
Expand Down
23 changes: 18 additions & 5 deletions components/modal/modalType/StoreModal.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { useRecoilValue } from 'recoil';
import { modalState } from 'utils/recoil/modal';
import CoinChangeModal from 'components/modal/statChange/CoinChangeModal';
import ChangeIdColorModal from 'components/modal/store/inventory/ChangeIdColorModal';
import EditMegaphoneModal from 'components/modal/store/inventory/EditMegaphoneModal';
import NewMegaphoneModal from 'components/modal/store/inventory/NewMegaphoneModal';
import StoreManualModal from 'components/modal/store/StoreManualModal';
import UserCoinHistoryModal from 'components/modal/store/UserCoinHistoryModal';
import BuyModal from 'components/modal/store/purchase/BuyModal';
import GiftModal from 'components/modal/store/purchase/GiftModal';
import NoCoinModal from 'components/modal/store/purchase/NoCoinModal';
import StoreManualModal from 'components/modal/store/StoreManualModal';
import UserCoinHistoryModal from 'components/modal/store/UserCoinHistoryModal';
import ChangeIdColorModal from 'components/modal/store/inventory/ChangeIdColorModal';
import NewMegaphoneModal from 'components/modal/store/inventory/NewMegaphoneModal';
import EditMegaphoneModal from 'components/modal/store/inventory/EditMegaphoneModal';
import ChangeProfileEdgeModal from 'components/modal/store/inventory/ChangeProfileEdgeModal';
import ChangeProfileBackgroundModal from 'components/modal/store/inventory/ChangeProfileBackgroundModal';
import GachaModal from 'components/modal/store/inventory/GachaModal';

export default function StoreModal() {
const {
Expand All @@ -18,6 +21,7 @@ export default function StoreModal() {
totalCoin,
priceTag,
useItemInfo,
randomItem,
} = useRecoilValue(modalState);

const content: { [key: string]: JSX.Element | null } = {
Expand All @@ -35,6 +39,15 @@ export default function StoreModal() {
'USE-ITEM-MEGAPHONE': useItemInfo ? (
<NewMegaphoneModal {...useItemInfo} />
) : null,
'USE-ITEM-PROFILE_BAND': useItemInfo ? (
<ChangeProfileEdgeModal {...useItemInfo} />
) : null,
'USE-ITEM-PROFILE_BACKGROUND': useItemInfo ? (
<ChangeProfileBackgroundModal {...useItemInfo} />
) : null,
'USE-ITEM-GACHA': randomItem ? (
<GachaModal randomItem={randomItem} />
) : null,
'EDIT-ITEM-MEGAPHONE': useItemInfo ? (
<EditMegaphoneModal {...useItemInfo} />
) : null,
Expand Down
73 changes: 73 additions & 0 deletions components/modal/store/inventory/ChangeProfileBackgroundModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { useResetRecoilState, useSetRecoilState } from 'recoil';
import { modalState } from 'utils/recoil/modal';
import { UseItemRequest } from 'types/inventoryTypes';
import { ItemCautionContainer } from './ItemCautionContainer';
import {
ModalButtonContainer,
ModalButton,
} from 'components/modal/ModalButton';
import { Modal } from 'types/modalTypes';
import styles from 'styles/modal/store/InventoryModal.module.scss';
import GachaBall from './GachaBall';
import { mockInstance } from 'utils/mockAxios';
import { errorState } from 'utils/recoil/error';

type ChangeProfileBackgroundModalProps = UseItemRequest;

// TODO : 주의사항 구체화 필요
const caution = [
'색상은 랜덤으로 결정됩니다.',
'아이템을 사용한 후에는 취소가 불가능합니다.',
];

// 랜덤 프로필 이미지띠 변경
export default function ChangeProfileBackgroundModal({
receiptId,
}: ChangeProfileBackgroundModalProps) {
const resetModal = useResetRecoilState(modalState);
const setModal = useSetRecoilState<Modal>(modalState);
const setError = useSetRecoilState<string>(errorState);

const gachaAction = async () => {
const data: UseItemRequest = {
receiptId: receiptId,
};
try {
const res = await mockInstance.patch('/users/background', data);
// api 테스트용 -> 나중에 지우기
console.log(`프로필 배경색: ${res.data}`);
// 가챠 애니메이션 모달
setModal({
modalName: 'USE-ITEM-GACHA',
randomItem: 'background',
});
} catch (error) {
setError('HB05');
}
};

return (
<div className={styles.container}>
<div className={styles.title}>프로필 배경색 변경</div>
<div className={styles.phrase}>
<div className={styles.section}>
<div className={styles.sectionTitle}></div>
<GachaBall />
</div>
<ItemCautionContainer caution={caution} />
<ModalButtonContainer>
<ModalButton
style='negative'
value='취소'
onClick={() => resetModal()}
/>
<ModalButton
style='positive'
value='뽑기'
onClick={() => gachaAction()}
/>
</ModalButtonContainer>
</div>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default function ChangeProfileEdgeModal({
// 가챠 애니메이션 모달
setModal({
modalName: 'USE-ITEM-GACHA',
randomItem: 'edge',
});
} catch (error) {
setError('HB04');
Expand Down
41 changes: 41 additions & 0 deletions components/modal/store/inventory/EdgePreview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import PlayerImage from 'components/PlayerImage';
import styles from 'styles/modal/store/EdgePreview.module.scss';

const edgeColorList = [
'BASIC',
'EDGE1',
'EDGE2',
'EDGE3',
'EDGE4',
'EDGE5',
'EDGE6',
'EDGE7',
'EDGE8',
'EDGE9',
'EDGE10',
'EDGE11',
'EDGE12',
'EDGE13',
'EDGE14',
'EDGE15',
'EDGE16',
];

export function EdgePreview() {
return (
<div className={styles.container}>
<div className={styles.preview}>
{edgeColorList.map((color) => (
<div key={color}>
<div>{color}</div>
<PlayerImage
src='/image/fallBackSrc.jpeg'
styleName={`mainProfile ${color.toLowerCase()}`}
size={30}
/>
</div>
))}
</div>
</div>
);
}
18 changes: 10 additions & 8 deletions components/modal/store/inventory/GachaModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ import {
ModalButtonContainer,
ModalButton,
} from 'components/modal/ModalButton';
import styles from 'styles/modal/store/GachaModal.module.scss';
// import styles from 'styles/modal/store/GachaModal.module.scss';

export default function GachaModal() {
// 미리보기에 사용할 예정
import { EdgePreview } from 'components/modal/store/inventory/EdgePreview';

type GachaModalProps = {
randomItem: string;
};

export default function GachaModal({ randomItem }: GachaModalProps) {
const user = useRecoilValue(userState);
const resetModal = useResetRecoilState(modalState);
return (
<div>
{/* TODO: 뽑기 당첨 애니메이션 적용 */}
<div className={styles.randomBox}>
<div className={styles.capsule}></div>
</div>
{/* TODO: 애니메이션이 끝나면 미리보기 결과와 확인 버튼 보이도록 하기 */}
{/* 이미지띠 미리보기용 임시 컴포넌트입니다 */}
{randomItem === 'edge' ? <EdgePreview /> : null}
<ModalButtonContainer>
<ModalButton
style='positive'
Expand Down
8 changes: 6 additions & 2 deletions components/rank/topRank/RankListItemMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function RankListItemMain({
user,
rank,
}: RankListItemMainProps) {
const { intraId, userImageUri, tierImageUri } = user || {};
const { intraId, userImageUri, tierImageUri, edge } = user || {};
const Mode = useRecoilValue(colorToggleSelector);
const renderLink = intraId !== 'intraId';

Expand All @@ -41,7 +41,11 @@ export default function RankListItemMain({
<Link href={`users/detail?intraId=${intraId}`}>
<PlayerImage
src={userImageUri}
styleName={rank === 1 ? 'ranktropybig' : 'ranktropy'}
styleName={
rank === 1
? `ranktropybig ${edge.toLowerCase()}`
: `ranktropy ${edge.toLowerCase()}`
}
size={50}
/>
<div className={`${styles.tierImageId}`}>
Expand Down
3 changes: 3 additions & 0 deletions components/rank/topRank/RankListMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,18 @@ const dummyRankList: userImages[] = [
intraId: 'intraId',
tierImageUri: '',
userImageUri: '',
edge: 'BASIC',
},
{
intraId: 'intraId',
tierImageUri: '',
userImageUri: '',
edge: 'BASIC',
},
{
intraId: 'intraId',
tierImageUri: '',
userImageUri: '',
edge: 'BASIC',
},
];
6 changes: 5 additions & 1 deletion components/user/BasicProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ export default function BasicProfile({ profileId }: ProfileProps) {
></span>
</div>
{intraId && (
<PlayerImage src={userImageUri} styleName={'mainProfile'} size={30} />
<PlayerImage
src={userImageUri}
styleName={`mainProfile ${edge.toLowerCase()}`}
size={30}
/>
)}
<div className={styles.idContainer}>
<div className={styles.ranktier}>
Expand Down
2 changes: 2 additions & 0 deletions hooks/users/useBasicProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const useBasicProfile = ({ profileId }: UseBasicProfileProps) => {
tierImageUri,
tierName,
edge,
backgroundType,
},
setProfile,
] = useRecoilState(profileState);
Expand Down Expand Up @@ -64,6 +65,7 @@ const useBasicProfile = ({ profileId }: UseBasicProfileProps) => {
tierImageUri,
tierName,
edge,
backgroundType,
};
};

Expand Down
18 changes: 18 additions & 0 deletions hooks/users/useProfileColorMode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useEffect } from 'react';
import { useSetRecoilState, useResetRecoilState } from 'recoil';
import { colorModeState } from 'utils/recoil/colorMode';
import { BackgroundColor } from 'types/colorModeTypes';

function useProfileColorMode(color: BackgroundColor) {
const setColorMode = useSetRecoilState(colorModeState);
const resetColorMode = useResetRecoilState(colorModeState);

useEffect(() => {
setColorMode(color);
return () => {
resetColorMode();
};
}, [color]);
}

export default useProfileColorMode;
4 changes: 2 additions & 2 deletions pages/api/pingpong/items/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ const item5: InventoryItem = {

const item6: InventoryItem = {
receiptId: 6,
itemName: '테스트6',
itemName: '프로필 배경색 변경',
imageUri:
'https://dodo.ac/np/images/thumb/1/17/NH_Balloon.jpg/600px-NH_Balloon.jpg',
purchaserIntra: 'kim_takgu',
itemStatus: 'BEFORE',
// ANCHOR - 추가된 속성. 필요 여부 논의 필요
itemPrice: 1000,
ownerIntra: 'aa',
itemType: 'MEGAPHONE',
itemType: 'PROFILE_BACKGROUND',
createdAt: '2021-08-07',
};

Expand Down
3 changes: 3 additions & 0 deletions pages/api/pingpong/rank/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ export default function handler(
intraId: '1',
userImageUri: '/image/fallBackSrc.jpeg',
tierImageUri: '/image/fallBackSrc.jpeg',
edge: 'EDGE2',
},
{
intraId: '2',
userImageUri: '/image/fallBackSrc.jpeg',
tierImageUri: '/image/fallBackSrc.jpeg',
edge: 'EDGE3',
},
{
intraId: '3',
userImageUri: '/image/fallBackSrc.jpeg',
tierImageUri: '/image/fallBackSrc.jpeg',
edge: 'EDGE4',
},
];

Expand Down
13 changes: 13 additions & 0 deletions pages/api/pingpong/users/background.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { NextApiRequest, NextApiResponse } from 'next';

export default function handler(
req: NextApiRequest,
res: NextApiResponse<string>
) {
const { method } = req;
const { receiptId } = req.body;
if (method === 'PATCH') {
// res.status(204).end();
res.status(200).json(`receiptId : ${receiptId}`);
}
}
Loading

0 comments on commit 11d5d01

Please sign in to comment.