-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* refactor :불필요한 페이지 삭제 * refactor: 헤더에 토큰 추가 방식 변경 * feat: 기능 요구사항 구현 * feat: 추가 기능 구현
- Loading branch information
Showing
15 changed files
with
376 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,23 @@ | ||
interface Headers { | ||
'Content-Type': string; | ||
[key: string]: string; | ||
} | ||
|
||
export const postApi = async (url: string, data?: {}, contentType?: string) => { | ||
await fetch(`${process.env.REACT_APP_API_DEFAULT + url}`, { | ||
const userToken = localStorage.getItem('userToken'); | ||
const headers: Headers = { | ||
'Content-type': `${contentType || 'application/json'}`, | ||
}; | ||
|
||
if (userToken) { | ||
headers['Authorization'] = `Bearer ${userToken}`; | ||
} | ||
|
||
const response = await fetch(`${process.env.REACT_APP_API_DEFAULT + url}`, { | ||
method: 'POST', | ||
headers: { | ||
'Content-type': `${contentType || 'application/json'}`, | ||
Authorization: `Bearer ${localStorage.getItem('userToken') || ''}`, | ||
}, | ||
headers: headers, | ||
body: JSON.stringify(data), | ||
}); | ||
|
||
return response; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { useState } from 'react'; | ||
import styled from 'styled-components'; | ||
import Flex from '../Flex'; | ||
|
||
interface CheckboxProps { | ||
id: number; | ||
isAlreadyChecked: boolean; | ||
label: string; | ||
onChecked: (checked: boolean, id: number) => void; | ||
} | ||
|
||
const Checkbox = ({ | ||
id, | ||
isAlreadyChecked, | ||
label, | ||
onChecked, | ||
}: CheckboxProps) => { | ||
const [isChecked, setIsChecked] = useState(isAlreadyChecked); | ||
|
||
const updateCheckedMembers = () => { | ||
const updatedChecked = !isChecked; | ||
console.log(updatedChecked); | ||
setIsChecked(updatedChecked); | ||
onChecked(updatedChecked, id); | ||
}; | ||
|
||
return ( | ||
<CheckboxWrapper key={id}> | ||
<Label htmlFor={label}> | ||
<Flex $justifyContent="space-between" width="100%"> | ||
<span>{label}</span> | ||
<CheckboxInput | ||
type="checkbox" | ||
id={label} | ||
checked={isChecked} | ||
onChange={updateCheckedMembers} | ||
/> | ||
</Flex> | ||
</Label> | ||
</CheckboxWrapper> | ||
); | ||
}; | ||
|
||
const CheckboxWrapper = styled(Flex)` | ||
border-bottom: 1px solid #c6c6c6; | ||
margin-bottom: 20px; | ||
&:last-child { | ||
border-bottom: none; | ||
margin-bottom: 0; | ||
} | ||
`; | ||
|
||
const Label = styled.label` | ||
cursor: pointer; | ||
display: flex; | ||
align-items: center; | ||
width: 100%; | ||
`; | ||
|
||
const CheckboxInput = styled.input` | ||
-webkit-appearance: none; | ||
appearance: none; | ||
width: 1.6em; | ||
height: 1.6em; | ||
border-radius: 0.15em; | ||
margin-right: 0.5em; | ||
border: 0.15em solid ${({ theme }) => theme.color.primary}; | ||
background-color: ${({ theme }) => theme.color.white}; | ||
outline: none; | ||
cursor: pointer; | ||
&:checked { | ||
border-color: transparent; | ||
background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M5.707 7.293a1 1 0 0 0-1.414 1.414l2 2a1 1 0 0 0 1.414 0l4-4a1 1 0 0 0-1.414-1.414L7 8.586 5.707 7.293z'/%3e%3c/svg%3e"); | ||
background-size: 100% 100%; | ||
background-position: 50%; | ||
background-repeat: no-repeat; | ||
background-color: ${({ theme }) => theme.color.primary}; | ||
} | ||
`; | ||
|
||
export default Checkbox; |
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
Oops, something went wrong.