-
Notifications
You must be signed in to change notification settings - Fork 1
✨ feat: 내 가게 정보 등록/편집 (사장님) 페이지 구현 #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 17 commits
da0ed9c
30150a9
d559612
59443ec
6a988f5
aed820f
a8560f4
bfc885e
8507490
227eb0b
efd29d8
51e2779
898f9c7
1894800
656933e
235320a
0a54c45
9dfb840
c700f54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,301 @@ | ||||||||||||||||||||||
| import { useNavigate } from 'react-router-dom'; | ||||||||||||||||||||||
| import { useCallback, useContext, useEffect, useState } from 'react'; | ||||||||||||||||||||||
| import Close from '@/assets/icons/close.svg'; | ||||||||||||||||||||||
| import { ADDRESS_OPTIONS, CATEGORY_OPTIONS } from '@/constants/dropdownOptions'; | ||||||||||||||||||||||
| import { getShop, postShop, putShop, type ShopRequest } from '@/api/shopApi'; | ||||||||||||||||||||||
| import { getPresignedUrl, uploadImageToS3 } from '@/api/imageApi'; | ||||||||||||||||||||||
| import Input from '@/components/common/Input'; | ||||||||||||||||||||||
| import Dropdown from '@/components/common/Dropdown'; | ||||||||||||||||||||||
| import ImageInput from '@/components/common/ImageInput'; | ||||||||||||||||||||||
| import Button from '@/components/common/Button'; | ||||||||||||||||||||||
| import Modal from '@/components/common/Modal'; | ||||||||||||||||||||||
| import { AuthContext } from '@/context/AuthContext'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| type Category = (typeof CATEGORY_OPTIONS)[number]; | ||||||||||||||||||||||
| type Address1 = (typeof ADDRESS_OPTIONS)[number]; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| interface StoreEditForm extends Omit<ShopRequest, 'category' | 'address1'> { | ||||||||||||||||||||||
| category: Category | null; | ||||||||||||||||||||||
| address1: Address1 | null; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| type ModalType = 'success' | 'warning' | 'auth'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export default function StoreEdit() { | ||||||||||||||||||||||
| return <div>내 가게 정보 등록/편집</div>; | ||||||||||||||||||||||
| const navigate = useNavigate(); | ||||||||||||||||||||||
| const { isLoggedIn } = useContext(AuthContext); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const shopId = localStorage.getItem('shopId'); | ||||||||||||||||||||||
| const isEditMode = !!shopId; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const [edit, setEdit] = useState<StoreEditForm>({ | ||||||||||||||||||||||
| name: '', | ||||||||||||||||||||||
| category: null, | ||||||||||||||||||||||
| address1: null, | ||||||||||||||||||||||
| address2: '', | ||||||||||||||||||||||
| description: '', | ||||||||||||||||||||||
| originalHourlyPay: 0, | ||||||||||||||||||||||
| imageUrl: '', | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const [isModalOpen, setIsModalOpen] = useState(false); | ||||||||||||||||||||||
| const [modalContent, setModalContent] = useState(''); | ||||||||||||||||||||||
| const [modalType, setModalType] = useState<ModalType>('success'); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // 로그아웃 처리 및 등록 수정 모드 | ||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||
| const userId = localStorage.getItem('userId'); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (!userId) { | ||||||||||||||||||||||
| setModalType('auth'); | ||||||||||||||||||||||
| setModalContent('로그인이 필요합니다.'); | ||||||||||||||||||||||
| setIsModalOpen(true); | ||||||||||||||||||||||
| return; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (isEditMode && !shopId) { | ||||||||||||||||||||||
|
||||||||||||||||||||||
| setModalType('warning'); | ||||||||||||||||||||||
| setModalContent('가게 정보를 찾을 수 없습니다.'); | ||||||||||||||||||||||
| setIsModalOpen(true); | ||||||||||||||||||||||
| return; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (!isEditMode) return; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const fetchShopInfo = async () => { | ||||||||||||||||||||||
| try { | ||||||||||||||||||||||
| const shopInfo = await getShop(shopId); | ||||||||||||||||||||||
| setEdit({ | ||||||||||||||||||||||
| name: shopInfo.item.name ?? '', | ||||||||||||||||||||||
| category: shopInfo.item.category ?? null, | ||||||||||||||||||||||
| address1: shopInfo.item.address1 ?? null, | ||||||||||||||||||||||
| address2: shopInfo.item.address2 ?? '', | ||||||||||||||||||||||
| description: shopInfo.item.description ?? '', | ||||||||||||||||||||||
| originalHourlyPay: shopInfo.item.originalHourlyPay ?? 0, | ||||||||||||||||||||||
| imageUrl: shopInfo.item.imageUrl ?? '', | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
||||||||||||||||||||||
| setEdit({ | |
| name: shopInfo.item.name ?? '', | |
| category: shopInfo.item.category ?? null, | |
| address1: shopInfo.item.address1 ?? null, | |
| address2: shopInfo.item.address2 ?? '', | |
| description: shopInfo.item.description ?? '', | |
| originalHourlyPay: shopInfo.item.originalHourlyPay ?? 0, | |
| imageUrl: shopInfo.item.imageUrl ?? '', | |
| }); | |
| setEdit(shopInfo.item); |
💬 이렇게 줄일 수 있을 것 같아요~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 좋네요! 바꾸겠습니다
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❗ 이 부분은 진우님께도 피드백 드린 부분인데 Nav 컴포넌트가 페이지 바깥에 있어서 h-screen 같은 스타일을 사용하면 실제 화면 크기보다 높이가 더 높아져 불필요한 스크롤이 생겨버립니다! 수정 부탁드려요~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 수정했습니다!
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <h2 className="text-h3/25 font-bold text-black md:text-h1"> | |
| <h2 className="text-h3/25 font-bold text-black md:text-h1/24"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
h1/24 이부분은 28인것 같습니다! 100%로 나온 부분이라
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오우 오타가 났네요 24가 아니라 34나 35가 맞을 것 같습니다!
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| : Number(edit.originalHourlyPay).toLocaleString() | |
| : edit.originalHourlyPay.toLocaleString() |
💬 originalHourlyPay가 원래 number형이라 이대로 써도 될 것 같습니다~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 알겠습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ 저희 로컬스토리지에 shopId가 있나요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아 이건 제가 편집 모드 들어가기 위해서 조회 부분에서 생성해서 가져오는 식으로 해서 있었습니다.