From e5f8001b9f8c41d9f6ecf09b56f8cbadfaafce1a Mon Sep 17 00:00:00 2001 From: Viliam Geffert <60324080+vgeffer@users.noreply.github.com> Date: Sun, 24 Nov 2024 14:52:40 +0100 Subject: [PATCH] Added SeasonCodeField to event (#491) --- src/components/Admin/custom/SeasonCodeField.tsx | 16 ++++++++++++++++ .../resources/competition/event/EventList.tsx | 3 ++- .../resources/competition/event/EventShow.tsx | 3 ++- .../competition/semester/SemesterCreate.tsx | 2 +- .../competition/semester/SemesterEdit.tsx | 2 +- .../competition/semester/SemesterList.tsx | 10 ++-------- .../competition/semester/SemesterShow.tsx | 11 ++--------- .../semester => }/seasonCodeStrings.ts | 0 8 files changed, 26 insertions(+), 21 deletions(-) create mode 100644 src/components/Admin/custom/SeasonCodeField.tsx rename src/components/Admin/{resources/competition/semester => }/seasonCodeStrings.ts (100%) 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