Skip to content

Commit

Permalink
create solution uploader
Browse files Browse the repository at this point in the history
  • Loading branch information
vikibrezinova committed May 18, 2024
1 parent ce6da68 commit 7e195ac
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 43 deletions.
12 changes: 12 additions & 0 deletions src/components/Admin/Admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ import {SeriesCreate} from './resources/competition/series/SeriesCreate'
import {SeriesEdit} from './resources/competition/series/SeriesEdit'
import {SeriesList} from './resources/competition/series/SeriesList'
import {SeriesShow} from './resources/competition/series/SeriesShow'
import {SolutionCreate} from './resources/competition/solution/SolutionCreate'
import {SolutionEdit} from './resources/competition/solution/SolutionEdit'
import {SolutionList} from './resources/competition/solution/SolutionList'
import {SolutionShow} from './resources/competition/solution/SolutionShow'
import {useAuthProvider} from './useAuthProvider'

export const Admin: FC = () => {
Expand Down Expand Up @@ -85,6 +89,14 @@ export const Admin: FC = () => {
show={ProblemShow}
create={ProblemCreate}
/>
<Resource
name="competition/solution"
recordRepresentation="verbose_name"
list={SolutionList}
edit={SolutionEdit}
show={SolutionShow}
create={SolutionCreate}
/>
</ReactAdmin>
)
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
import {FC} from 'react'
import {
AutocompleteInput,
CheckboxGroupInput,
DateTimeInput,
FileInput,
NumberInput,
ReferenceArrayInput,
ReferenceInput,
required,
SelectInput,
SimpleForm,
TextInput,
} from 'react-admin'
import {AutocompleteInput, FileInput, ReferenceInput, required, SimpleForm} from 'react-admin'

import {MyCreate} from '@/components/Admin/custom/MyCreate'
import {MyFileField} from '@/components/Admin/custom/MyFileField'
Expand All @@ -27,10 +15,10 @@ export const SolutionCreate: FC = () => (
>
<SimpleForm>
<ReferenceInput source="problem" reference="competition/problem">
<SelectInput fullWidth validate={required()} />
<AutocompleteInput fullWidth validate={required()} />
</ReferenceInput>
<ReferenceInput source="semester_registration" reference="/competition/event-registration/">
<SelectInput optionText="verbose_name" fullWidth validate={required()} />
<AutocompleteInput optionText="verbose_name" fullWidth validate={required()} />
</ReferenceInput>
<FileInput source="solution" accept="application/pdf">
<MyFileField />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
import {FC} from 'react'
import {
AutocompleteInput,
FileInput,
NumberInput,
ReferenceInput,
required,
SelectInput,
SimpleForm,
TextInput,
} from 'react-admin'
import {AutocompleteInput, FileInput, ReferenceInput, required, SimpleForm} from 'react-admin'

import {MyEdit} from '@/components/Admin/custom/MyEdit'
import {MyFileField} from '@/components/Admin/custom/MyFileField'
import {SitesCheckboxInput} from '@/components/Admin/custom/SitesCheckboxInput'

import {createSolutionFormData} from './createSolutionFormData'

export const SolutionEdit: FC = () => (
<MyEdit>
<MyEdit
transform={(record) => {
record.formData = createSolutionFormData(record)
return record
}}
>
<SimpleForm>
<ReferenceInput source="problem" reference="competition/problem">
<SelectInput fullWidth validate={required()} />
<AutocompleteInput fullWidth validate={required()} />
</ReferenceInput>
<ReferenceInput source="semester_registration" reference="competition/event-registration">
<SelectInput optionText="verbose_name" fullWidth validate={required()} />
<AutocompleteInput optionText="verbose_name" fullWidth validate={required()} />
</ReferenceInput>
<FileInput source="solution" accept="application/pdf">
<MyFileField />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
import {FC} from 'react'
import {
BooleanField,
Datagrid,
FunctionField,
ImageField,
List,
NumberField,
RaRecord,
ReferenceField,
} from 'react-admin'

import {TruncatedTextField} from '@/components/Admin/custom/TruncatedTextField'
import {BooleanField, Datagrid, FunctionField, List, RaRecord, ReferenceField} from 'react-admin'

export const SolutionList: FC = () => (
<List>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {FC} from 'react'
import {FileField, ImageField, NumberField, ReferenceField, SimpleShowLayout} from 'react-admin'
import {FileField, ReferenceField, SimpleShowLayout} from 'react-admin'

import {MyShow} from '@/components/Admin/custom/MyShow'
import {TruncatedTextField} from '@/components/Admin/custom/TruncatedTextField'

export const SolutionShow: FC = () => (
<MyShow>
Expand Down

0 comments on commit 7e195ac

Please sign in to comment.