diff --git a/src/components/Admin/custom/MyCreate.tsx b/src/components/Admin/custom/MyCreate.tsx index 173630b3..380c606b 100644 --- a/src/components/Admin/custom/MyCreate.tsx +++ b/src/components/Admin/custom/MyCreate.tsx @@ -1,4 +1,8 @@ import {FC, PropsWithChildren} from 'react' -import {Create} from 'react-admin' +import {Create, CreateProps} from 'react-admin' -export const MyCreate: FC = ({children}) => {children} +export const MyCreate: FC> = ({children, ...rest}) => ( + + {children} + +) diff --git a/src/components/Admin/custom/MyEdit.tsx b/src/components/Admin/custom/MyEdit.tsx index 55f6fe9f..020a2127 100644 --- a/src/components/Admin/custom/MyEdit.tsx +++ b/src/components/Admin/custom/MyEdit.tsx @@ -1,10 +1,10 @@ import {FC, PropsWithChildren} from 'react' -import {Edit} from 'react-admin' +import {Edit, EditProps} from 'react-admin' import {MyEditActions} from './MyEditActions' -export const MyEdit: FC = ({children}) => ( - } mutationMode="pessimistic" redirect="show"> +export const MyEdit: FC> = ({children, ...rest}) => ( + } mutationMode="pessimistic" redirect="show" {...rest}> {children} ) diff --git a/src/components/Admin/resources/competition/event/EventCreate.tsx b/src/components/Admin/resources/competition/event/EventCreate.tsx index ee5b682d..8d4e2213 100644 --- a/src/components/Admin/resources/competition/event/EventCreate.tsx +++ b/src/components/Admin/resources/competition/event/EventCreate.tsx @@ -1,51 +1,45 @@ -import {FC} from 'react' -import { - ArrayInput, - DateTimeInput, - FormTab, - NumberInput, - required, - SimpleFormIterator, - TabbedForm, - TextInput, -} from 'react-admin' +import {Checkbox, FormControlLabel} from '@mui/material' +import {FC, useState} from 'react' +import {DateTimeInput, Labeled, NumberInput, required, SimpleForm, TextInput} from 'react-admin' import {CompetitionInput} from '@/components/Admin/custom/CompetitionInput' import {MyCreate} from '@/components/Admin/custom/MyCreate' -export const EventCreate: FC = () => ( - - - - +export const EventCreate: FC = () => { + // initial false, necakame, ze mame registration link uz ready + const [includeRegLink, setIncludeRegLink] = useState(false) + + return ( + { + // bud musime pridat cely registration object, alebo poslat null. ideal je si to tu ohandlit explicitne, + // nie je uplne jasne, ako inak presvedcit react admina, aby ako ten cely objekt poslat null + if (!includeRegLink) record.registration_link = null + return record + }} + > + - - napr. 2023/2024 + - - TODO: always sends null as registration_link - - - TODO: publikacie treba vediet nahrat, nie tu editovat db - - - - - - - - - - - - - -) + setIncludeRegLink(e.target.checked)} />} + label="Pridať registračný link" + /> + {includeRegLink && ( + + <> + + + + + + + + )} + + + ) +} diff --git a/src/components/Admin/resources/competition/event/EventEdit.tsx b/src/components/Admin/resources/competition/event/EventEdit.tsx index efb20c6a..d81697ed 100644 --- a/src/components/Admin/resources/competition/event/EventEdit.tsx +++ b/src/components/Admin/resources/competition/event/EventEdit.tsx @@ -1,51 +1,47 @@ -import {FC} from 'react' -import { - ArrayInput, - DateTimeInput, - FormTab, - NumberInput, - required, - SimpleFormIterator, - TabbedForm, - TextInput, -} from 'react-admin' +import {Checkbox, FormControlLabel} from '@mui/material' +import {FC, useState} from 'react' +import {DateTimeInput, Labeled, NumberInput, required, SimpleForm, TextInput} from 'react-admin' import {CompetitionInput} from '@/components/Admin/custom/CompetitionInput' import {MyEdit} from '@/components/Admin/custom/MyEdit' -export const EventEdit: FC = () => ( - - - - +export const EventEdit: FC = () => { + // initial true, nech vidime vsetky fieldy, ktore ideme editovat + const [includeRegLink, setIncludeRegLink] = useState(true) + + return ( + { + // bud musime pridat cely registration object, alebo poslat null. ideal je si to tu ohandlit explicitne, + // nie je uplne jasne, ako inak presvedcit react admina, aby ako ten cely objekt poslat null + if (!includeRegLink) record.registration_link = null + // publication_set je nested field, sme dohodnuti, ze neposielame a publikacie handlujeme inak + delete record.publication_set + return record + }} + > + - - napr. 2023/2024 + - - TODO: always sends null as registration_link - - - TODO: publikacie treba vediet nahrat, nie tu editovat db - - - - - - - - - - - - - -) + setIncludeRegLink(e.target.checked)} />} + label="Upraviť registračný link" + /> + {includeRegLink && ( + + <> + + + + + + + + )} + + + ) +} diff --git a/src/components/Admin/resources/competition/event/EventList.tsx b/src/components/Admin/resources/competition/event/EventList.tsx index 5869f109..80159c98 100644 --- a/src/components/Admin/resources/competition/event/EventList.tsx +++ b/src/components/Admin/resources/competition/event/EventList.tsx @@ -1,12 +1,11 @@ import {FC} from 'react' -import {BooleanField, Datagrid, DateField, FunctionField, List, NumberField, RaRecord, TextField} from 'react-admin' +import {Datagrid, DateField, FunctionField, List, NumberField, RaRecord, TextField} from 'react-admin' import {CompetitionField} from '@/components/Admin/custom/CompetitionField' export const EventList: FC = () => ( - @@ -14,12 +13,7 @@ export const EventList: FC = () => ( - - - - - source="publication_set" label="Publication count" diff --git a/src/components/Admin/resources/competition/event/EventShow.tsx b/src/components/Admin/resources/competition/event/EventShow.tsx index ae4dc711..8556a00a 100644 --- a/src/components/Admin/resources/competition/event/EventShow.tsx +++ b/src/components/Admin/resources/competition/event/EventShow.tsx @@ -1,7 +1,6 @@ import {FC} from 'react' import { ArrayField, - BooleanField, Datagrid, DateField, NumberField, @@ -20,9 +19,6 @@ export const EventShow: FC = () => ( - - - @@ -31,10 +27,6 @@ export const EventShow: FC = () => ( - - - - @@ -45,7 +37,6 @@ export const EventShow: FC = () => ( -