-
Notifications
You must be signed in to change notification settings - Fork 1
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 #105 from softeerbootcamp4th/feat/adminUploadReward
Feat/admin upload reward
- Loading branch information
Showing
14 changed files
with
406 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { post } from '@/api/indexFormData'; | ||
|
||
const postQuizReward = (file, quizDate) => | ||
post('/admin/quizReward', { | ||
file, | ||
quizDate, | ||
}); | ||
|
||
export { postQuizReward }; |
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,51 @@ | ||
const ApiRequest = async (url, method, body) => { | ||
const accessToken = localStorage.getItem('userInfo'); | ||
|
||
try { | ||
const options = { | ||
method, | ||
headers: { | ||
...(accessToken && { | ||
Authorization: `Bearer ${accessToken}`, | ||
}), | ||
}, | ||
credentials: 'include', | ||
}; | ||
|
||
const formData = new FormData(); | ||
for (const key in body) { | ||
formData.append(key, body[key]); | ||
} | ||
options.body = formData; | ||
|
||
const response = await fetch( | ||
`${import.meta.env.VITE_API_URL}${url}`, | ||
options, | ||
); | ||
const result = await response.json(); | ||
return result; | ||
} catch (error) { | ||
console.log('API 통신 실패 : ', error); | ||
throw error; | ||
} | ||
}; | ||
|
||
export const post = (url, body) => { | ||
return ApiRequest(url, 'POST', body); | ||
}; | ||
|
||
export const get = url => { | ||
return ApiRequest(url, 'GET', null); | ||
}; | ||
|
||
export const put = (url, body) => { | ||
return ApiRequest(url, 'PUT', body); | ||
}; | ||
|
||
export const patch = (url, body) => { | ||
return ApiRequest(url, 'PATCH', body); | ||
}; | ||
|
||
export const del = (url, body, header) => { | ||
return ApiRequest(url, 'DELETE', body, header); | ||
}; |
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,27 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { NavLink } from 'react-router-dom'; | ||
|
||
function NavLinkItem({ path, value }) { | ||
return ( | ||
<NavLink | ||
to={path} | ||
className={({ isActive }) => | ||
`${ | ||
isActive | ||
? 'text-body-3-bold text-neutral-black border-b-black border-b-solid border-b-[3px]' | ||
: 'text-detail-1-regular text-neutral-500 hover:scale-110 transition-transform duration-300' | ||
}` | ||
} | ||
> | ||
{value} | ||
</NavLink> | ||
); | ||
} | ||
|
||
NavLinkItem.propTypes = { | ||
path: PropTypes.string.isRequired, | ||
value: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default NavLinkItem; |
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.