diff --git a/src/App.js b/src/App.js index 969b68a..6a27e30 100644 --- a/src/App.js +++ b/src/App.js @@ -12,6 +12,7 @@ import SideBar from './Components/SideBar/SideBar' import GroupMainPage from './Pages/GroupMainPage' import ShowEventList from './Pages/ShowEventList' import UploadMember from './Pages/UploadMember' +import UploadTransactions from './Pages/UploadTransaction' const StyledLayout = styled.div` // background-color: gray; @@ -57,6 +58,7 @@ function GroupRoutesWithSidebar() { } /> } /> } /> + } /> ) diff --git a/src/Components/SideBar/SideBar.js b/src/Components/SideBar/SideBar.js index 1a848da..b9ee1f2 100644 --- a/src/Components/SideBar/SideBar.js +++ b/src/Components/SideBar/SideBar.js @@ -84,7 +84,7 @@ const SideBar = () => { { index: 1, name: '거래내역 업로드', - path: `uploadResult`, + path: `uploadTransaction`, }, { index: 2, diff --git a/src/Components/Upload/UploadTranaction.js b/src/Components/Upload/UploadTranaction.js new file mode 100644 index 0000000..1e0f5bd --- /dev/null +++ b/src/Components/Upload/UploadTranaction.js @@ -0,0 +1,105 @@ +import React, { useState } from 'react' +import { createTransaction } from '../../apis/tranaction' +import { InboxOutlined, LockOutlined } from '@ant-design/icons' +import { Upload, Button, Input } from 'antd' +import styled from 'styled-components' + +const { Dragger } = Upload + +const UploadTransaction = ({ groupId }) => { + const [file, setFile] = useState(null) + const [password, setPassword] = useState('') + const [isFileUploaded, setIsFileUploaded] = useState(false) + + const props = { + name: 'file', + accept: '.xlsx, .xls, .csv', + multiple: false, + showUploadList: false, + beforeUpload: (file) => { + setFile(file) + setIsFileUploaded(true) + return false + }, + } + + const handleUpload = async () => { + await createTransaction(groupId, password, file) + alert('파일이 업로드되었습니다.') + window.location.reload() + } + + return ( + + + 확인 + + + + {file ? ( + + file +

{file.name}

+
+ ) : ( +
+

+ +

+

클릭 또는 파일을 드래그하여 업로드하세요

+

xlsx, csv 파일만 첨부 가능

+
+ )} +
+ } + type="password" + placeholder="비밀번호" + value={password} + onChange={(e) => setPassword(e.target.value)} + /> +
+ ) +} + +export default UploadTransaction + +export const StyledButton = styled(Button)` + margin-top: 20px; + margin-bottom: 10px; + width: 100px; + height: 50px; + font-size: 20px; + font-weight: 500; + + display: flex; + justify-content: center; + align-items: center; + background-color: #003e97; +` +export const StyledDragger = styled(Dragger)` + width: 100%; + height: 100%; + padding: 10px; + background-color: rgba(0, 62.67, 151.94, 0.08); + border-radius: 10px; +` + +export const Wrapper = styled.div` + display: flex; + flex-direction: column; + align-items: flex-end; + width: 50%; + margin-left: 12%; +` +const FileIconWrapper = styled.div` + width: 100%; + height: 100%; + display: flex; + justify-content: center; + align-items: center; +` diff --git a/src/Pages/UploadTransaction/index.js b/src/Pages/UploadTransaction/index.js new file mode 100644 index 0000000..da3feb4 --- /dev/null +++ b/src/Pages/UploadTransaction/index.js @@ -0,0 +1,9 @@ +import React from 'react' +import UploadTransaction from '../../Components/Upload/UploadTranaction' + +const UploadTransactions = () => { + const groupId = window.location.href.split('/')[4] + return +} + +export default UploadTransactions diff --git a/src/apis/tranaction.js b/src/apis/tranaction.js new file mode 100644 index 0000000..3161eeb --- /dev/null +++ b/src/apis/tranaction.js @@ -0,0 +1,9 @@ +import { formApi } from './index' + +export const createTransaction = async (groupId, password, file) => { + const formData = new FormData() + formData.append('password', password) + formData.append('transactionFile', file) + const response = await formApi.post(`/group/${groupId}/transaction/excel`, formData) + return response.data +}