Skip to content

Commit

Permalink
add Accept to Uploader
Browse files Browse the repository at this point in the history
  • Loading branch information
vikibrezinova committed Nov 10, 2023
1 parent cd379f9 commit 4370bf1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/components/PublicationUploader/PublicationUploader.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import {Upload} from '@mui/icons-material'
import axios from 'axios'
import {FC, useCallback} from 'react'
import {DropzoneOptions, useDropzone} from 'react-dropzone'
import {Accept, DropzoneOptions, useDropzone} from 'react-dropzone'

interface PublicationUploaderProps {
uploadLink: string
acceptedFormats?: Accept
publication_type: string
event: string
order: string
refetch: () => void
}

export const PublicationUploader: FC<PublicationUploaderProps> = ({uploadLink, publication_type, event, order, refetch}) => {
export const PublicationUploader: FC<PublicationUploaderProps> = ({uploadLink, acceptedFormats, publication_type, event, order, refetch}) => {

Check failure on line 15 in src/components/PublicationUploader/PublicationUploader.tsx

View workflow job for this annotation

GitHub Actions / branch-test

Replace `uploadLink,·acceptedFormats,·publication_type,·event,·order,·refetch` with `⏎··uploadLink,⏎··acceptedFormats,⏎··publication_type,⏎··event,⏎··order,⏎··refetch,⏎`
const onDrop = useCallback<NonNullable<DropzoneOptions['onDrop']>>(
async (acceptedFiles) => {
async (acceptedFiles, fileRejections) => {
if (fileRejections.length > 0) {
return
}
const formData = new FormData()
formData.append('file', acceptedFiles[0])
formData.append('publication_type', publication_type)
Expand All @@ -26,7 +30,11 @@ export const PublicationUploader: FC<PublicationUploaderProps> = ({uploadLink, p
[refetch, uploadLink],

Check warning on line 30 in src/components/PublicationUploader/PublicationUploader.tsx

View workflow job for this annotation

GitHub Actions / branch-test

React Hook useCallback has missing dependencies: 'event', 'order', and 'publication_type'. Either include them or remove the dependency array
)

const {getRootProps, getInputProps} = useDropzone({onDrop})
const {getRootProps, getInputProps} = useDropzone({
onDrop,
multiple: false,
accept: acceptedFormats ?? {},
})

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ export const SemesterAdministration: FC = () => {
1. časopis:
<PublicationUploader
uploadLink={'/api/competition/publication/upload/'}
acceptedFormats={{
'application/pdf': ['.pdf'],
}}
publication_type={'Časopisy'}
event={`${semesterId}`}
order={'1'}
Expand All @@ -138,6 +141,9 @@ export const SemesterAdministration: FC = () => {
2. časopis:
<PublicationUploader
uploadLink={'/api/competition/publication/upload/'}
acceptedFormats={{
'application/pdf': ['.pdf'],
}}
publication_type={'Časopisy'}
event={`${semesterId}`}
order={'2'}
Expand All @@ -146,6 +152,9 @@ export const SemesterAdministration: FC = () => {
3. časopis:
<PublicationUploader
uploadLink={'/api/competition/publication/upload/'}
acceptedFormats={{
'application/pdf': ['.pdf'],
}}
publication_type={'Časopisy'}
event={`${semesterId}`}
order={'3'}
Expand Down

0 comments on commit 4370bf1

Please sign in to comment.