-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
650 additions
and
40 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
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
28 changes: 28 additions & 0 deletions
28
src/pages/Goods/components/GoodsModify/components/ModifyCategory.tsx
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import category from '@src/pages/Map/components/BottomSheetComponent/data'; | ||
|
||
export default function ModifyCategory({ | ||
idx, | ||
btn, | ||
onClick, | ||
}: { | ||
idx: number; | ||
btn?: JSX.Element; | ||
onClick?: () => void; | ||
}) { | ||
const { icon, name } = category.filter((item) => item.idx === idx)[0]; | ||
|
||
return ( | ||
<span | ||
className="flex w-fit shrink-0 items-center rounded-md border bg-white px-3 py-2 text-sm" | ||
onClick={onClick} | ||
> | ||
<img className="mr-1 inline-block size-[16px]" src={icon} alt={name} /> | ||
{name} {btn} | ||
</span> | ||
); | ||
} | ||
|
||
ModifyCategory.defaultProps = { | ||
btn: undefined, | ||
onClick: undefined, | ||
}; |
37 changes: 37 additions & 0 deletions
37
src/pages/Goods/components/GoodsModify/components/ModifyHeader.tsx
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import ChevronLeft from '@src/asset/icon/chevronLeft.svg'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { GoodsModifyType } from '@src/pages/Goods/index.d'; | ||
|
||
export default function ModifyHeader({ | ||
curr, | ||
prev, | ||
setIsConfirm, | ||
}: { | ||
curr: GoodsModifyType; | ||
prev: GoodsModifyType; | ||
setIsConfirm: React.Dispatch<React.SetStateAction<boolean>>; | ||
}) { | ||
const navigate = useNavigate(); | ||
|
||
const handleGoingBack = () => { | ||
if (JSON.stringify(curr) === JSON.stringify(prev)) { | ||
// console.log('변동사항 없음'); | ||
navigate(-1); | ||
} else { | ||
// console.log('변동사항 있음'); | ||
setIsConfirm(true); | ||
} | ||
}; | ||
return ( | ||
<div className="absolute left-1/2 top-0 z-50 flex h-[48px] w-full max-w-screen-sm -translate-x-1/2 items-center justify-between bg-white px-4"> | ||
<button onClick={handleGoingBack}> | ||
<img | ||
className="h-12 w-10 cursor-pointer px-1 py-2" | ||
src={ChevronLeft} | ||
alt="뒤로가기" | ||
/> | ||
</button> | ||
</div> | ||
); | ||
} |
86 changes: 86 additions & 0 deletions
86
src/pages/Goods/components/GoodsModify/components/PostCodeModify.tsx
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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { useState } from 'react'; | ||
import DaumPostcodeEmbed, { Address } from 'react-daum-postcode'; | ||
import CloseIcon from '@src/asset/icon/CloseIcon.svg'; | ||
import { GoodsModifyType } from '@src/pages/Goods/index.d'; | ||
|
||
function PostCodeModify({ | ||
address, | ||
setAddress, | ||
setModify, | ||
}: { | ||
address: string; | ||
setAddress: React.Dispatch<React.SetStateAction<string>>; | ||
setModify: React.Dispatch<React.SetStateAction<GoodsModifyType>>; | ||
}) { | ||
const [open, setOpen] = useState(false); | ||
const { kakao } = window; | ||
|
||
const handleComplete = (param: Address) => { | ||
const geocoder = new kakao.maps.services.Geocoder(); | ||
let fullAddress = param.address; | ||
let extraAddress = ''; | ||
|
||
if (param.addressType === 'R') { | ||
if (param.bname !== '') { | ||
extraAddress += param.bname; | ||
} | ||
if (param.buildingName !== '') { | ||
extraAddress += | ||
extraAddress !== '' ? `, ${param.buildingName}` : param.buildingName; | ||
} | ||
fullAddress += extraAddress !== '' ? ` (${extraAddress})` : ''; | ||
} | ||
|
||
geocoder.addressSearch(fullAddress, (result, status) => { | ||
if (status === kakao.maps.services.Status.OK) { | ||
setAddress(fullAddress); | ||
setModify((prev) => ({ | ||
...prev, | ||
coordinate: { | ||
latitude: Number(result[0].y), | ||
longitude: Number(result[0].x), | ||
}, | ||
})); | ||
} | ||
}); | ||
|
||
setOpen(false); | ||
}; | ||
|
||
return ( | ||
<div className="relative"> | ||
<button | ||
data-modal-target="defaultModal" | ||
data-modal-toggle="defaultModal" | ||
className="w-full rounded-md border border-slate-300 p-3 text-right text-sm font-medium focus:border-success focus:outline-none focus:ring-1 focus:ring-success disabled:border-slate-200 disabled:bg-slate-50 disabled:text-slate-500 disabled:shadow-none" | ||
type="button" | ||
onClick={() => setOpen((prev) => !prev)} | ||
value={address} | ||
> | ||
{address || ( | ||
<div className="text-gray-400">서울 성동구 왕십리로2길 20</div> | ||
)} | ||
</button> | ||
{open && ( | ||
<div className="fixed inset-0 z-50 flex items-center justify-center overflow-y-auto overflow-x-hidden outline-none focus:outline-none"> | ||
<div className="fixed left-0 top-0 z-50 h-svh w-screen bg-white"> | ||
<div onClick={() => setOpen(false)}> | ||
<img | ||
src={CloseIcon} | ||
className="ml-auto mr-2 mt-2 w-10 p-2" | ||
alt="닫기" | ||
/> | ||
</div> | ||
</div> | ||
<DaumPostcodeEmbed | ||
style={{ height: 'calc(100svh - 64px)' }} | ||
className="fixed bottom-0 z-50" | ||
onComplete={handleComplete} | ||
/> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export default PostCodeModify; |
Oops, something went wrong.