diff --git a/src/components/Admin/custom/SeasonCodeField.tsx b/src/components/Admin/custom/SeasonCodeField.tsx new file mode 100644 index 00000000..ef821dad --- /dev/null +++ b/src/components/Admin/custom/SeasonCodeField.tsx @@ -0,0 +1,16 @@ +import {FC} from 'react' +import {FunctionField, FunctionFieldProps} from 'react-admin' + +import {seasonCodeStrings} from '../seasonCodeStrings' + +export const SeasonCodeField: FC> = ({source, ...rest}) => { + return ( + { + return `${seasonCodeStrings[record.season_code].name ?? ''}` + }} + {...rest} + /> + ) +} diff --git a/src/components/Admin/resources/competition/event/EventList.tsx b/src/components/Admin/resources/competition/event/EventList.tsx index cd246544..87791ac8 100644 --- a/src/components/Admin/resources/competition/event/EventList.tsx +++ b/src/components/Admin/resources/competition/event/EventList.tsx @@ -2,13 +2,14 @@ import {FC} from 'react' import {Datagrid, FunctionField, List, NumberField, RaRecord, ReferenceField, TextField} from 'react-admin' import {DateTimeField} from '@/components/Admin/custom/DateTimeField' +import {SeasonCodeField} from '@/components/Admin/custom/SeasonCodeField' export const EventList: FC = () => ( - + diff --git a/src/components/Admin/resources/competition/event/EventShow.tsx b/src/components/Admin/resources/competition/event/EventShow.tsx index e7a665e5..de9f982d 100644 --- a/src/components/Admin/resources/competition/event/EventShow.tsx +++ b/src/components/Admin/resources/competition/event/EventShow.tsx @@ -12,6 +12,7 @@ import { import {DateTimeField} from '@/components/Admin/custom/DateTimeField' import {MyShow} from '@/components/Admin/custom/MyShow' +import {SeasonCodeField} from '@/components/Admin/custom/SeasonCodeField' export const EventShow: FC = () => ( @@ -20,7 +21,7 @@ export const EventShow: FC = () => ( - + diff --git a/src/components/Admin/resources/competition/semester/SemesterCreate.tsx b/src/components/Admin/resources/competition/semester/SemesterCreate.tsx index 8d9f6130..ed6df7d2 100644 --- a/src/components/Admin/resources/competition/semester/SemesterCreate.tsx +++ b/src/components/Admin/resources/competition/semester/SemesterCreate.tsx @@ -13,7 +13,7 @@ import { import {MyCreate} from '@/components/Admin/custom/MyCreate' import {MyDateTimeInput} from '@/components/Admin/custom/MyDateTimeInput' -import {seasonCodeStrings} from './seasonCodeStrings' +import {seasonCodeStrings} from '../../../seasonCodeStrings' export const SemesterCreate: FC = () => ( diff --git a/src/components/Admin/resources/competition/semester/SemesterEdit.tsx b/src/components/Admin/resources/competition/semester/SemesterEdit.tsx index 2d65a3a3..9101918b 100644 --- a/src/components/Admin/resources/competition/semester/SemesterEdit.tsx +++ b/src/components/Admin/resources/competition/semester/SemesterEdit.tsx @@ -14,7 +14,7 @@ import { import {MyDateTimeInput} from '@/components/Admin/custom/MyDateTimeInput' import {MyEdit} from '@/components/Admin/custom/MyEdit' -import {seasonCodeStrings} from './seasonCodeStrings' +import {seasonCodeStrings} from '../../../seasonCodeStrings' export const SemesterEdit: FC = () => ( ( - { - return `${seasonCodeStrings[record.season_code].name ?? ''}` - }} - /> + diff --git a/src/components/Admin/resources/competition/semester/SemesterShow.tsx b/src/components/Admin/resources/competition/semester/SemesterShow.tsx index 1c70f2ff..df27da02 100644 --- a/src/components/Admin/resources/competition/semester/SemesterShow.tsx +++ b/src/components/Admin/resources/competition/semester/SemesterShow.tsx @@ -3,7 +3,6 @@ import { ArrayField, BooleanField, Datagrid, - FunctionField, NumberField, ReferenceArrayField, ReferenceField, @@ -15,10 +14,9 @@ import { import {DateTimeField} from '@/components/Admin/custom/DateTimeField' import {MyShow} from '@/components/Admin/custom/MyShow' +import {SeasonCodeField} from '@/components/Admin/custom/SeasonCodeField' import {TruncatedTextField} from '@/components/Admin/custom/TruncatedTextField' -import {seasonCodeStrings} from './seasonCodeStrings' - export const SemesterShow: FC = () => ( @@ -26,12 +24,7 @@ export const SemesterShow: FC = () => ( - { - return `${seasonCodeStrings[record.season_code].name ?? ''}` - }} - /> + diff --git a/src/components/Admin/resources/competition/semester/seasonCodeStrings.ts b/src/components/Admin/seasonCodeStrings.ts similarity index 100% rename from src/components/Admin/resources/competition/semester/seasonCodeStrings.ts rename to src/components/Admin/seasonCodeStrings.ts