-
Notifications
You must be signed in to change notification settings - Fork 16
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
20 changed files
with
564 additions
and
9 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
3 changes: 3 additions & 0 deletions
3
frontend-monorepo/packages/hanglog-admin/src/assets/svg/close-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions
43
...nd-monorepo/packages/hanglog-admin/src/components/city/CityAddModal/CityAddModal.style.ts
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,43 @@ | ||
import { css } from '@emotion/react'; | ||
|
||
import { Theme } from 'hang-log-design-system'; | ||
|
||
export const wrapperStyling = css({ | ||
width: '400px', | ||
minHeight: '528px', | ||
|
||
'@media screen and (max-width: 600px)': { | ||
width: `calc(100vw - ${Theme.spacer.spacing4})`, | ||
height: `80%`, | ||
}, | ||
}); | ||
|
||
export const formStyling = css({ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: Theme.spacer.spacing4, | ||
width: '80%', | ||
}); | ||
|
||
export const buttonStyling = css({ | ||
width: '100%', | ||
}); | ||
|
||
export const closeButtonStyling = css({ | ||
position: 'absolute', | ||
right: Theme.spacer.spacing4, | ||
top: Theme.spacer.spacing4, | ||
alignSelf: 'flex-end', | ||
|
||
marginBottom: Theme.spacer.spacing1, | ||
|
||
border: 'none', | ||
backgroundColor: 'transparent', | ||
|
||
cursor: 'pointer', | ||
}); | ||
|
||
export const closeIconStyling = css({ | ||
width: '16px', | ||
height: '16px', | ||
}); |
100 changes: 100 additions & 0 deletions
100
frontend-monorepo/packages/hanglog-admin/src/components/city/CityAddModal/CityAddModal.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,100 @@ | ||
import { Button, Flex, Modal, Theme } from 'hang-log-design-system'; | ||
|
||
import { UseAddCityForm } from '@/hooks/city/useAddCityForm'; | ||
|
||
import type { CityFormData } from '@/types/city'; | ||
|
||
import CloseIcon from '@assets/svg/close-icon.svg?react'; | ||
|
||
import NameInput from './NameInput/NameInput'; | ||
import CountryInput from './CountryInput/CountryInput'; | ||
import LatitudeInput from './LatitudeInput/LatitudeInput'; | ||
import LongitudeInput from './LongitudeInput/LongitudeInput'; | ||
|
||
import { | ||
wrapperStyling, | ||
formStyling, | ||
buttonStyling, | ||
closeButtonStyling, | ||
closeIconStyling, | ||
} from './CityAddModal.style'; | ||
|
||
interface CityAddModalProps { | ||
cityId?: number; | ||
initialData?: CityFormData; | ||
isOpen?: boolean; | ||
onClose: () => void; | ||
} | ||
|
||
const CityAddModal = ({ cityId, initialData, isOpen = true, onClose }: CityAddModalProps) => { | ||
const { | ||
cityInformation, | ||
isNameError, | ||
isCountryError, | ||
isLatitudeError, | ||
isLongitudeError, | ||
disableNameError, | ||
disableCountryError, | ||
disableLatitudeError, | ||
disableLongitudeError, | ||
updateInputValue, | ||
handleSubmit, | ||
} = UseAddCityForm({ | ||
initialData, | ||
onSuccess: onClose, | ||
}); | ||
|
||
return ( | ||
<> | ||
<Modal | ||
css={wrapperStyling} | ||
isOpen={isOpen} | ||
closeModal={onClose} | ||
isBackdropClosable={false} | ||
hasCloseButton={false} | ||
> | ||
<button | ||
type="button" | ||
aria-label="모달 닫기 버튼" | ||
onClick={onClose} | ||
css={closeButtonStyling} | ||
> | ||
<CloseIcon css={closeIconStyling} /> | ||
</button> | ||
<form css={formStyling} onSubmit={handleSubmit} noValidate> | ||
<Flex styles={{ direction: 'column', gap: Theme.spacer.spacing3, align: 'stretch' }}> | ||
<NameInput | ||
value={cityInformation.name} | ||
isError={isNameError} | ||
updateInputValue={updateInputValue} | ||
disableError={disableNameError} | ||
/> | ||
<CountryInput | ||
value={cityInformation.country} | ||
isError={isCountryError} | ||
updateInputValue={updateInputValue} | ||
disableError={disableCountryError} | ||
/> | ||
<LatitudeInput | ||
value={cityInformation.latitude} | ||
isError={isLatitudeError} | ||
updateInputValue={updateInputValue} | ||
disableError={disableLatitudeError} | ||
/> | ||
<LongitudeInput | ||
value={cityInformation.longitude} | ||
isError={isLongitudeError} | ||
updateInputValue={updateInputValue} | ||
disableError={disableLongitudeError} | ||
/> | ||
</Flex> | ||
<Button css={buttonStyling} variant="primary"> | ||
도시 {cityId ? '수정하기' : '추가하기'} | ||
</Button> | ||
</form> | ||
</Modal> | ||
</> | ||
); | ||
}; | ||
|
||
export default CityAddModal; |
40 changes: 40 additions & 0 deletions
40
...epo/packages/hanglog-admin/src/components/city/CityAddModal/CountryInput/CountryInput.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,40 @@ | ||
import type { ChangeEvent } from 'react'; | ||
import { memo } from 'react'; | ||
|
||
import { Input } from 'hang-log-design-system'; | ||
|
||
import type { CityFormData } from '@/types/city'; | ||
|
||
import { CITY_COUNTRY_MAX_LENGTH } from '@/constants/ui'; | ||
|
||
interface CountryInputProps { | ||
value: string; | ||
isError: boolean; | ||
updateInputValue: <K extends keyof CityFormData>(key: K, value: CityFormData[K]) => void; | ||
disableError: () => void; | ||
} | ||
|
||
const CountryInput = ({ isError, value, updateInputValue, disableError }: CountryInputProps) => { | ||
const handleCountryChange = (event: ChangeEvent<HTMLInputElement>) => { | ||
disableError(); | ||
|
||
updateInputValue('country', event.target.value); | ||
}; | ||
|
||
return ( | ||
<Input | ||
label="나라" | ||
id="country" | ||
name="country" | ||
maxLength={CITY_COUNTRY_MAX_LENGTH} | ||
value={value} | ||
placeholder="나라를 입력해 주세요" | ||
supportingText={isError ? '도시의 나라를 입력해 주세요' : undefined} | ||
isError={isError} | ||
required | ||
onChange={handleCountryChange} | ||
/> | ||
); | ||
}; | ||
|
||
export default memo(CountryInput); |
42 changes: 42 additions & 0 deletions
42
...o/packages/hanglog-admin/src/components/city/CityAddModal/LatitudeInput/LatitudeInput.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,42 @@ | ||
import type { ChangeEvent } from 'react'; | ||
import { memo } from 'react'; | ||
|
||
import { Input } from 'hang-log-design-system'; | ||
|
||
import type { CityFormData } from '@/types/city'; | ||
|
||
import { CITY_LATITUDE_MAX, CITY_LATITUDE_MIN } from '@/constants/ui'; | ||
|
||
interface LatitudeInputProps { | ||
value: number; | ||
isError: boolean; | ||
updateInputValue: <K extends keyof CityFormData>(key: K, value: CityFormData[K]) => void; | ||
disableError: () => void; | ||
} | ||
|
||
const LatitudeInput = ({ isError, value, updateInputValue, disableError }: LatitudeInputProps) => { | ||
const handleLatitudeChange = (event: ChangeEvent<HTMLInputElement>) => { | ||
disableError(); | ||
|
||
updateInputValue('latitude', Number(event.target.value)); | ||
}; | ||
|
||
return ( | ||
<Input | ||
type="number" | ||
label="위도" | ||
id="latitude" | ||
name="latitude" | ||
value={value} | ||
placeholder="0.0" | ||
min={CITY_LATITUDE_MIN} | ||
max={CITY_LATITUDE_MAX} | ||
supportingText={isError ? '도시의 위도를 입력해 주세요' : undefined} | ||
isError={isError} | ||
required | ||
onChange={handleLatitudeChange} | ||
/> | ||
); | ||
}; | ||
|
||
export default memo(LatitudeInput); |
47 changes: 47 additions & 0 deletions
47
...packages/hanglog-admin/src/components/city/CityAddModal/LongitudeInput/LongitudeInput.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,47 @@ | ||
import type { ChangeEvent } from 'react'; | ||
import { memo } from 'react'; | ||
|
||
import { Input } from 'hang-log-design-system'; | ||
|
||
import type { CityFormData } from '@/types/city'; | ||
|
||
import { CITY_LONGITUDE_MAX, CITY_LONGITUDE_MIN } from '@/constants/ui'; | ||
|
||
interface LongitudeInputProps { | ||
value: number; | ||
isError: boolean; | ||
updateInputValue: <K extends keyof CityFormData>(key: K, value: CityFormData[K]) => void; | ||
disableError: () => void; | ||
} | ||
|
||
const LongitudeInput = ({ | ||
isError, | ||
value, | ||
updateInputValue, | ||
disableError, | ||
}: LongitudeInputProps) => { | ||
const handleLongitudeChange = (event: ChangeEvent<HTMLInputElement>) => { | ||
disableError(); | ||
|
||
updateInputValue('longitude', Number(event.target.value)); | ||
}; | ||
|
||
return ( | ||
<Input | ||
type="number" | ||
label="경도" | ||
id="longitude" | ||
name="longitude" | ||
value={value} | ||
placeholder="0.0" | ||
min={CITY_LONGITUDE_MIN} | ||
max={CITY_LONGITUDE_MAX} | ||
supportingText={isError ? '도시의 경도를 입력해 주세요' : undefined} | ||
isError={isError} | ||
required | ||
onChange={handleLongitudeChange} | ||
/> | ||
); | ||
}; | ||
|
||
export default memo(LongitudeInput); |
40 changes: 40 additions & 0 deletions
40
...-monorepo/packages/hanglog-admin/src/components/city/CityAddModal/NameInput/NameInput.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,40 @@ | ||
import type { ChangeEvent } from 'react'; | ||
import { memo } from 'react'; | ||
|
||
import { Input } from 'hang-log-design-system'; | ||
|
||
import type { CityFormData } from '@/types/city'; | ||
|
||
import { CITY_NAME_MAX_LENGTH } from '@/constants/ui'; | ||
|
||
interface NameInputProps { | ||
value: string; | ||
isError: boolean; | ||
updateInputValue: <K extends keyof CityFormData>(key: K, value: CityFormData[K]) => void; | ||
disableError: () => void; | ||
} | ||
|
||
const NameInput = ({ isError, value, updateInputValue, disableError }: NameInputProps) => { | ||
const handleTitleChange = (event: ChangeEvent<HTMLInputElement>) => { | ||
disableError(); | ||
|
||
updateInputValue('name', event.target.value); | ||
}; | ||
|
||
return ( | ||
<Input | ||
label="이름" | ||
id="name" | ||
name="name" | ||
maxLength={CITY_NAME_MAX_LENGTH} | ||
value={value} | ||
placeholder="이름을 입력해 주세요" | ||
supportingText={isError ? '도시의 이름을 입력해 주세요' : undefined} | ||
isError={isError} | ||
required | ||
onChange={handleTitleChange} | ||
/> | ||
); | ||
}; | ||
|
||
export default memo(NameInput); |
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
Oops, something went wrong.