-
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.
* add solution to RA * create solution uploader * fix showing event-registration references * client-side filter * create even registration in RA * add event field to event registration * add late_tag and is_online to solution * Results changes after backend now returns the entire grade object See ZdruzenieSTROM/webstrom-backend#426 * RA create solution also sending false-y but non-null values (e. g. 0) * RA EventRegistration changes after backend update * RA EventRegistrations fixed typing --------- Co-authored-by: rtrembecky <[email protected]> Co-authored-by: Michal Masrna <[email protected]>
- Loading branch information
1 parent
4c7f127
commit 9f01669
Showing
12 changed files
with
257 additions
and
5 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
23 changes: 23 additions & 0 deletions
23
src/components/Admin/resources/competition/event-registration/EventRegistrationCreate.tsx
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 {FC} from 'react' | ||
import {AutocompleteInput, ReferenceInput, required, SimpleForm} from 'react-admin' | ||
|
||
import {MyCreate} from '@/components/Admin/custom/MyCreate' | ||
|
||
export const EventRegistrationCreate: FC = () => ( | ||
<MyCreate> | ||
<SimpleForm> | ||
<ReferenceInput source="profile" reference="personal/profiles"> | ||
<AutocompleteInput optionText="verbose_name" fullWidth validate={required()} /> | ||
</ReferenceInput> | ||
<ReferenceInput source="school" reference="personal/schools"> | ||
<AutocompleteInput optionText="verbose_name" fullWidth validate={required()} /> | ||
</ReferenceInput> | ||
<ReferenceInput source="grade" reference="competition/grade"> | ||
<AutocompleteInput optionText="name" fullWidth validate={required()} /> | ||
</ReferenceInput> | ||
<ReferenceInput source="event" reference="competition/event"> | ||
<AutocompleteInput optionText="verbose_name" fullWidth validate={required()} /> | ||
</ReferenceInput> | ||
</SimpleForm> | ||
</MyCreate> | ||
) |
30 changes: 30 additions & 0 deletions
30
src/components/Admin/resources/competition/event-registration/EventRegistrationEdit.tsx
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,30 @@ | ||
import {FC} from 'react' | ||
import {AutocompleteInput, ReferenceInput, required, SimpleForm} from 'react-admin' | ||
|
||
import {MyEdit} from '@/components/Admin/custom/MyEdit' | ||
|
||
export const EventRegistrationEdit: FC = () => ( | ||
<MyEdit | ||
transform={(record) => { | ||
record.profile = record.profile.id | ||
record.school = record.school.code | ||
record.grade = record.grade.id | ||
return record | ||
}} | ||
> | ||
<SimpleForm> | ||
<ReferenceInput source="profile.id" reference="personal/profiles"> | ||
<AutocompleteInput optionText="verbose_name" fullWidth validate={required()} /> | ||
</ReferenceInput> | ||
<ReferenceInput source="school.code" reference="personal/schools"> | ||
<AutocompleteInput optionText="verbose_name" fullWidth validate={required()} /> | ||
</ReferenceInput> | ||
<ReferenceInput source="grade.id" reference="competition/grade"> | ||
<AutocompleteInput optionText="name" fullWidth validate={required()} /> | ||
</ReferenceInput> | ||
<ReferenceInput source="event" reference="competition/event"> | ||
<AutocompleteInput optionText="verbose_name" fullWidth validate={required()} /> | ||
</ReferenceInput> | ||
</SimpleForm> | ||
</MyEdit> | ||
) |
19 changes: 19 additions & 0 deletions
19
src/components/Admin/resources/competition/event-registration/EventRegistrationList.tsx
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,19 @@ | ||
import {FC} from 'react' | ||
import {Datagrid, FunctionField, List, ReferenceField, TextField} from 'react-admin' | ||
|
||
import {EventRegistration} from '@/types/api/competition' | ||
|
||
export const EventRegistrationList: FC = () => ( | ||
<List> | ||
<Datagrid rowClick="show"> | ||
<FunctionField | ||
source="profile.last_name" | ||
label="Meno a priezvisko" | ||
render={(record: EventRegistration) => `${record.profile.first_name} ${record.profile.last_name}`} | ||
/> | ||
<TextField source="school.abbreviation" label="Škola" /> | ||
<TextField source="grade.tag" label="Ročník" /> | ||
<ReferenceField source="event" reference="competition/event" link={false} /> | ||
</Datagrid> | ||
</List> | ||
) |
20 changes: 20 additions & 0 deletions
20
src/components/Admin/resources/competition/event-registration/EventRegistrationShow.tsx
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,20 @@ | ||
import {FC} from 'react' | ||
import {FunctionField, ReferenceField, SimpleShowLayout, TextField} from 'react-admin' | ||
|
||
import {MyShow} from '@/components/Admin/custom/MyShow' | ||
import {EventRegistration} from '@/types/api/competition' | ||
|
||
export const EventRegistrationShow: FC = () => ( | ||
<MyShow> | ||
<SimpleShowLayout> | ||
<FunctionField | ||
source="profile.last_name" | ||
label="Meno a priezvisko" | ||
render={(record: EventRegistration) => `${record.profile.first_name} ${record.profile.last_name}`} | ||
/> | ||
<TextField source="school.abbreviation" label="Škola" /> | ||
<TextField source="grade.tag" label="Ročník" /> | ||
<ReferenceField source="event" reference="competition/event" link={false} /> | ||
</SimpleShowLayout> | ||
</MyShow> | ||
) |
32 changes: 32 additions & 0 deletions
32
src/components/Admin/resources/competition/solution/SolutionCreate.tsx
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,32 @@ | ||
import {FC} from 'react' | ||
import {AutocompleteInput, BooleanInput, FileInput, ReferenceInput, required, SimpleForm} from 'react-admin' | ||
|
||
import {MyCreate} from '@/components/Admin/custom/MyCreate' | ||
import {MyFileField} from '@/components/Admin/custom/MyFileField' | ||
|
||
import {createSolutionFormData} from './createSolutionFormData' | ||
|
||
export const SolutionCreate: FC = () => ( | ||
<MyCreate | ||
transform={(record) => { | ||
record.formData = createSolutionFormData(record) | ||
return record | ||
}} | ||
> | ||
<SimpleForm> | ||
<ReferenceInput source="problem" reference="competition/problem"> | ||
<AutocompleteInput fullWidth validate={required()} /> | ||
</ReferenceInput> | ||
<ReferenceInput source="semester_registration" reference="competition/event-registration"> | ||
<AutocompleteInput optionText="verbose_name" fullWidth validate={required()} /> | ||
</ReferenceInput> | ||
<FileInput source="solution" accept="application/pdf"> | ||
<MyFileField /> | ||
</FileInput> | ||
<ReferenceInput source="late_tag" reference="competition/late-tag" label="Je riešenie po termíne?"> | ||
<AutocompleteInput optionText="name" fullWidth /> | ||
</ReferenceInput> | ||
<BooleanInput source="is_online" label="Je to internetové riešenie?" /> | ||
</SimpleForm> | ||
</MyCreate> | ||
) |
32 changes: 32 additions & 0 deletions
32
src/components/Admin/resources/competition/solution/SolutionEdit.tsx
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,32 @@ | ||
import {FC} from 'react' | ||
import {AutocompleteInput, BooleanInput, FileInput, ReferenceInput, required, SimpleForm} from 'react-admin' | ||
|
||
import {MyEdit} from '@/components/Admin/custom/MyEdit' | ||
import {MyFileField} from '@/components/Admin/custom/MyFileField' | ||
|
||
import {createSolutionFormData} from './createSolutionFormData' | ||
|
||
export const SolutionEdit: FC = () => ( | ||
<MyEdit | ||
transform={(record) => { | ||
record.formData = createSolutionFormData(record) | ||
return record | ||
}} | ||
> | ||
<SimpleForm> | ||
<ReferenceInput source="problem" reference="competition/problem"> | ||
<AutocompleteInput fullWidth validate={required()} /> | ||
</ReferenceInput> | ||
<ReferenceInput source="semester_registration" reference="competition/event-registration"> | ||
<AutocompleteInput optionText="verbose_name" fullWidth validate={required()} /> | ||
</ReferenceInput> | ||
<FileInput source="solution" accept="application/pdf"> | ||
<MyFileField /> | ||
</FileInput> | ||
<ReferenceInput source="late_tag" reference="competition/late-tag" label="Je riešenie po termíne?"> | ||
<AutocompleteInput optionText="name" fullWidth /> | ||
</ReferenceInput> | ||
<BooleanInput source="is_online" label="Je to internetové riešenie?" /> | ||
</SimpleForm> | ||
</MyEdit> | ||
) |
17 changes: 17 additions & 0 deletions
17
src/components/Admin/resources/competition/solution/SolutionList.tsx
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,17 @@ | ||
import {FC} from 'react' | ||
import {BooleanField, Datagrid, FunctionField, List, RaRecord, ReferenceField} from 'react-admin' | ||
|
||
export const SolutionList: FC = () => ( | ||
<List> | ||
<Datagrid rowClick="show"> | ||
<ReferenceField source="problem" reference="competition/problem" link={false} /> | ||
<ReferenceField source="semester_registration" reference="competition/event-registration" link={false} /> | ||
<FunctionField<RaRecord> | ||
label="Má nahraté riešenie" | ||
render={(record) => record && <BooleanField record={{xxx: !!record['solution']}} source="xxx" />} | ||
/> | ||
<ReferenceField source="late_tag" reference="competition/late-tag" label="Po termíne" link={false} /> | ||
<BooleanField source="is_online" label="Internetové riešenie" /> | ||
</Datagrid> | ||
</List> | ||
) |
16 changes: 16 additions & 0 deletions
16
src/components/Admin/resources/competition/solution/SolutionShow.tsx
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,16 @@ | ||
import {FC} from 'react' | ||
import {BooleanField, FileField, ReferenceField, SimpleShowLayout} from 'react-admin' | ||
|
||
import {MyShow} from '@/components/Admin/custom/MyShow' | ||
|
||
export const SolutionShow: FC = () => ( | ||
<MyShow> | ||
<SimpleShowLayout> | ||
<ReferenceField source="problem" reference="competition/problem" link="show" /> | ||
<ReferenceField source="semester_registration" reference="competition/event-registration" link="show" /> | ||
<FileField source="solution" title="Riešenie" /> | ||
<ReferenceField source="late_tag" reference="competition/late-tag" label="Po termíne" link="show" /> | ||
<BooleanField source="is_online" label="Internetové riešenie" /> | ||
</SimpleShowLayout> | ||
</MyShow> | ||
) |
17 changes: 17 additions & 0 deletions
17
src/components/Admin/resources/competition/solution/createSolutionFormData.tsx
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,17 @@ | ||
import {Solution} from '@/types/api/competition' | ||
|
||
export const createSolutionFormData = ({ | ||
solution, | ||
...data | ||
}: Omit<Solution, 'solution'> & { | ||
solution?: {rawFile: File} | ||
}) => { | ||
const formData = new FormData() | ||
// vzdy appendneme kazdy kluc, aj tieto fily, len null sa tu neda pouzit. null znamena, ze file odstranujeme | ||
formData.append('solution', solution?.rawFile ?? '') | ||
Object.entries(data).forEach(([key, value]) => { | ||
if (value != null) formData.append(key, value.toString()) | ||
}) | ||
|
||
return formData | ||
} |
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