-
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.
Merge pull request #67 from TUK-MoreView/feat/project-management
Feat/project management
- Loading branch information
Showing
14 changed files
with
407 additions
and
102 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import basicApi from '..'; | ||
|
||
export const getProjectList = async (memberId) => { | ||
try { | ||
const response = await basicApi.get(`api/project/${memberId}`); | ||
return response.data; | ||
} catch (error) { | ||
console.error(error); | ||
throw error; | ||
} | ||
}; | ||
|
||
export const postFile = async (file) => { | ||
const formData = FormData(); | ||
formData.append('file', file); | ||
try { | ||
const response = await basicApi.post(`file`, formData, { | ||
headers: { | ||
'Content-Type': 'multipart/form-data', | ||
}, | ||
}); | ||
return response.data; | ||
} catch (error) { | ||
console.error(error); | ||
throw error; | ||
} | ||
}; | ||
|
||
export const postProject = async (title, file) => { | ||
try { | ||
const data = { | ||
name: title, | ||
thumbnailUrl: file, | ||
memberId: 8, | ||
}; | ||
const response = await basicApi.post('api/project', data, { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
return response.data; | ||
} catch (error) { | ||
console.error(error); | ||
throw error; | ||
} | ||
}; |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,49 @@ | ||
import styled from 'styled-components'; | ||
import SubmitBtn from './atom/SubmitBtn'; | ||
|
||
function LoginFormContainer({ | ||
email, | ||
password, | ||
setEmail, | ||
setPassword, | ||
LoginHandle, | ||
}) { | ||
return ( | ||
<Container> | ||
<InputBox | ||
placeholder="์ด๋ฉ์ผ" | ||
type="id" | ||
value={email} | ||
onChange={(e) => setEmail(e.target.value)} | ||
required | ||
/> | ||
<InputBox | ||
placeholder="๋น๋ฐ๋ฒํธ" | ||
type="password" | ||
value={password} | ||
onChange={(e) => setPassword(e.target.value)} | ||
required | ||
/> | ||
<SubmitBtn type="submit" onClick={LoginHandle} /> | ||
</Container> | ||
); | ||
} | ||
|
||
export default LoginFormContainer; | ||
|
||
const Container = styled.form` | ||
width: 308px; | ||
height: 221px; | ||
margin-top: 52px; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 32px; | ||
`; | ||
|
||
const InputBox = styled.input` | ||
width: 308px; | ||
height: 48px; | ||
padding: 0 18px; | ||
border: 1px solid #6b7684; | ||
border-radius: 8px; | ||
`; |
This file was deleted.
Oops, something went wrong.
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,23 @@ | ||
import styled from 'styled-components'; | ||
|
||
function SubmitBtn({ type, onClick }) { | ||
return ( | ||
<SubmitButton type={type} onClick={onClick}> | ||
๋ก๊ทธ์ธ | ||
</SubmitButton> | ||
); | ||
} | ||
|
||
export default SubmitBtn; | ||
|
||
const SubmitButton = styled.button` | ||
width: 308px; | ||
height: 48px; | ||
background-color: #3182f6; | ||
border: none; | ||
border-radius: 8px; | ||
color: white; | ||
&:hover { | ||
background-color: #1b64da; | ||
} | ||
`; |
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,97 @@ | ||
import styled from 'styled-components'; | ||
import { useRecoilState } from 'recoil'; | ||
import { useState } from 'react'; | ||
import CancelBtn from './atom/CancelBtn'; | ||
import { CreateProjectModalState } from '../../store/modalState'; | ||
import { postFile, postProject } from '../../apis/Project/ProjectController'; | ||
|
||
function CreateProjectModal() { | ||
const [modalValue, setModalValue] = useRecoilState(CreateProjectModalState); | ||
const [title, setTitle] = useState(''); | ||
const [file, setFile] = useState(null); | ||
|
||
if (!modalValue) { | ||
return null; | ||
} | ||
|
||
const CancelHandler = () => { | ||
setModalValue(false); | ||
}; | ||
|
||
const handleSummit = async () => { | ||
if (file) { | ||
try { | ||
const fileUrl = await postFile(file); | ||
await postProject(title, fileUrl); | ||
setTitle(''); | ||
setFile(null); | ||
setModalValue(false); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} else { | ||
console.warn('No file selected'); | ||
} | ||
}; | ||
|
||
return ( | ||
<ModalBackdrop> | ||
<ModalBox> | ||
<CancelPostion> | ||
<CancelBtn CancelHandler={CancelHandler} /> | ||
</CancelPostion> | ||
<MainTitle>ํ๋ก์ ํธ ๋ง๋ค๊ธฐ</MainTitle> | ||
<input | ||
placeholder="์ด๋ฆ์ ์ง์ด์ฃผ์ธ์" | ||
type="text" | ||
value={title} | ||
onChange={(e) => setTitle(e.target.value)} | ||
/> | ||
<input | ||
id="thumbnail" | ||
type="file" | ||
onChange={(e) => setFile(e.target.files[0])} // ํ์ผ ์ ํ ์ฒ๋ฆฌ | ||
/> | ||
<button type="button" onClick={handleSummit}> | ||
์์ฑ | ||
</button> | ||
</ModalBox> | ||
</ModalBackdrop> | ||
); | ||
} | ||
|
||
export default CreateProjectModal; | ||
|
||
const ModalBackdrop = styled.div` | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100vw; | ||
height: 100vh; | ||
background-color: rgba(0, 0, 0, 0.5); | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
z-index: 999; | ||
`; | ||
|
||
const ModalBox = styled.div` | ||
position: absolute; | ||
display: flex; | ||
flex-direction: column; | ||
width: 22.5vw; | ||
height: 56.388888888888886vh; | ||
background-color: #ffffff; | ||
border-radius: 12px; | ||
padding: 1.04vw; | ||
`; | ||
|
||
const CancelPostion = styled.div` | ||
position: absolute; | ||
top: 1vw; | ||
right: 1vw; | ||
`; | ||
|
||
const MainTitle = styled.p` | ||
font-size: 1.2vw; | ||
`; |
Oops, something went wrong.