-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/user/sign-up
- Loading branch information
Showing
16 changed files
with
417 additions
and
220 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
43 changes: 43 additions & 0 deletions
43
packages/apps/user/src/components/SelectPharm/PharmList.js
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 @@ | ||
export const PharmList = [ | ||
{ | ||
name: '조아 약국', | ||
rate: '4.8', | ||
profileImg: 'https://cdn-icons-png.flaticon.com/512/6743/6743757.png', | ||
distance: '1.2km', | ||
}, | ||
{ | ||
name: '행복약국', | ||
|
||
rate: '4.6', | ||
profileImg: 'https://cdn-icons-png.flaticon.com/512/6743/6743757.png', | ||
distance: '1.7km', | ||
}, | ||
{ | ||
name: '튼튼약국', | ||
|
||
rate: '4.5', | ||
profileImg: 'https://cdn-icons-png.flaticon.com/512/6743/6743757.png', | ||
distance: '2.1km', | ||
}, | ||
{ | ||
name: '비타민약국', | ||
|
||
rate: '4.5', | ||
profileImg: 'https://cdn-icons-png.flaticon.com/512/6743/6743757.png', | ||
distance: '0.7km', | ||
}, | ||
{ | ||
name: '합정 우리 약국', | ||
|
||
rate: '4.9', | ||
profileImg: 'https://cdn-icons-png.flaticon.com/512/6743/6743757.png', | ||
distance: '1.2km', | ||
}, | ||
{ | ||
name: '강남 신소재 약국', | ||
|
||
rate: '4.9', | ||
profileImg: 'https://cdn-icons-png.flaticon.com/512/6743/6743757.png', | ||
distance: '3.7km', | ||
}, | ||
]; |
81 changes: 81 additions & 0 deletions
81
packages/apps/user/src/components/SelectPharm/SelectPharmacy.js
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,81 @@ | ||
import { useCallback, useState } from 'react'; | ||
|
||
import { | ||
Box, | ||
Heading, | ||
Modal, | ||
ModalOverlay, | ||
ModalContent, | ||
ModalHeader, | ||
ModalBody, | ||
ModalCloseButton, | ||
useDisclosure, | ||
VStack, | ||
SimpleGrid, | ||
Select, | ||
} from '@chakra-ui/react'; | ||
|
||
import AppointmentCard from '../AppointmentCard/AppointmentCard.js'; | ||
|
||
import { PharmList } from './PharmList.js'; | ||
|
||
function SelectPharm() { | ||
const { isOpen, onOpen, onClose } = useDisclosure(); | ||
|
||
const [selectedPharmacy, setSelectedPharmacy] = useState(null); | ||
const filteredList = PharmList.filter(item => item.distance <= '2km'); | ||
const handlePharmacy = useCallback( | ||
item => { | ||
setSelectedPharmacy(item); | ||
onOpen(); | ||
}, | ||
[onOpen], | ||
); | ||
|
||
return ( | ||
<VStack width="full" height="full" gap="4"> | ||
<Box width="100%"> | ||
<VStack width="100%" justifyContent="space-between"> | ||
<Heading as="h2" fontSize="24"> | ||
진료가 완료되었습니다 | ||
</Heading> | ||
<Heading as="h3" fontSize="24"> | ||
처방전을 전송할 약국을 선택해주세요 | ||
</Heading> | ||
</VStack> | ||
</Box> | ||
<SimpleGrid columns={2} gap="5" width="full" px="4" overflowY="scroll"> | ||
{filteredList.map((item, idx) => ( | ||
<Box onClick={() => handlePharmacy(item)} key={idx}> | ||
<AppointmentCard data={item} key={idx} /> | ||
</Box> | ||
))} | ||
</SimpleGrid> | ||
|
||
{selectedPharmacy && ( | ||
<Modal isOpen={isOpen} onClose={onClose} isCentered> | ||
<ModalOverlay /> | ||
<ModalContent> | ||
<ModalHeader> | ||
{selectedPharmacy && selectedPharmacy.name} | ||
</ModalHeader> | ||
|
||
<ModalCloseButton /> | ||
<ModalBody> | ||
<Box display="flex" alignItems="center" whiteSpace="nowrap"> | ||
약을 | ||
<Select width="32" ml={2} mr={2}> | ||
<option value="배달수령">배달수령</option> | ||
<option value="직접수령">직접수령</option> | ||
</Select> | ||
하겠습니다. | ||
</Box> | ||
</ModalBody> | ||
</ModalContent> | ||
</Modal> | ||
)} | ||
</VStack> | ||
); | ||
} | ||
|
||
export default SelectPharm; |
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,3 @@ | ||
{ | ||
"main": "SelectPharmacy.js" | ||
} |
32 changes: 32 additions & 0 deletions
32
packages/apps/user/src/components/SelectPharm/test/SelectPharm-specs.js
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,32 @@ | ||
import { BrowserRouter } from 'react-router-dom'; | ||
import { render, fireEvent } from '@testing-library/react'; | ||
|
||
import '@testing-library/jest-dom'; | ||
import SelectPharm from '../SelectPharmacy'; | ||
|
||
jest.mock('../PharmList.js', () => ({ | ||
PharmList: [ | ||
{ name: '조아약국', rate: '4.8', distance: '1km' }, | ||
{ name: '튼튼약국', rate: '4.5', distance: '1.5km' }, | ||
], | ||
})); | ||
|
||
describe('진료 후 약국 선택 페이지', () => { | ||
it('약국 리스트가 잘 뜨는가', () => { | ||
const { getByText } = render(<SelectPharm />, { wrapper: BrowserRouter }); | ||
expect(getByText('조아약국')).toBeInTheDocument(); | ||
expect(getByText('튼튼약국')).toBeInTheDocument(); | ||
}); | ||
|
||
it('약국을 누르면 모달창이 뜨는가', () => { | ||
const { getByText, queryByText } = render(<SelectPharm />, { | ||
wrapper: BrowserRouter, | ||
}); | ||
|
||
expect(queryByText(/배달수령/)).not.toBeInTheDocument(); | ||
|
||
fireEvent.click(getByText('조아약국')); | ||
|
||
expect(queryByText(/배달수령/)).toBeInTheDocument(); | ||
}); | ||
}); |
Oops, something went wrong.