From 99deb9ac751161889d94af2213652348bb195250 Mon Sep 17 00:00:00 2001 From: Viliam Geffert <60324080+vgeffer@users.noreply.github.com> Date: Sun, 24 Nov 2024 01:09:54 +0100 Subject: [PATCH] Season code now maps to strings (#481) * Season code now maps to strings * Moved string mappings to separate component --- .../resources/competition/semester/SemesterCreate.tsx | 4 +++- .../resources/competition/semester/SemesterEdit.tsx | 8 +++++--- .../resources/competition/semester/SemesterList.tsx | 9 ++++++++- .../resources/competition/semester/SemesterShow.tsx | 10 +++++++++- .../competition/semester/seasonCodeStrings.ts | 5 +++++ 5 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 src/components/Admin/resources/competition/semester/seasonCodeStrings.ts diff --git a/src/components/Admin/resources/competition/semester/SemesterCreate.tsx b/src/components/Admin/resources/competition/semester/SemesterCreate.tsx index dc1c6948..8d9f6130 100644 --- a/src/components/Admin/resources/competition/semester/SemesterCreate.tsx +++ b/src/components/Admin/resources/competition/semester/SemesterCreate.tsx @@ -13,6 +13,8 @@ import { import {MyCreate} from '@/components/Admin/custom/MyCreate' import {MyDateTimeInput} from '@/components/Admin/custom/MyDateTimeInput' +import {seasonCodeStrings} from './seasonCodeStrings' + export const SemesterCreate: FC = () => ( @@ -20,7 +22,7 @@ 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 30538df6..2d65a3a3 100644 --- a/src/components/Admin/resources/competition/semester/SemesterEdit.tsx +++ b/src/components/Admin/resources/competition/semester/SemesterEdit.tsx @@ -14,6 +14,8 @@ import { import {MyDateTimeInput} from '@/components/Admin/custom/MyDateTimeInput' import {MyEdit} from '@/components/Admin/custom/MyEdit' +import {seasonCodeStrings} from './seasonCodeStrings' + export const SemesterEdit: FC = () => ( { @@ -30,14 +32,14 @@ export const SemesterEdit: FC = () => ( - + {/* nechavam viditelne disabled nech sa rozhodneme, co s tym. BE nam posiela ID, - neviem, ci vieme updatnut cely objekt tym, ze ho pribalim, ako v EventEdit... - uvidime, ci ten field vobec potrebujeme */} + neviem, ci vieme updatnut cely objekt tym, ze ho pribalim, ako v EventEdit... + uvidime, ci ten field vobec potrebujeme */} diff --git a/src/components/Admin/resources/competition/semester/SemesterList.tsx b/src/components/Admin/resources/competition/semester/SemesterList.tsx index 034cc20e..8ad356cd 100644 --- a/src/components/Admin/resources/competition/semester/SemesterList.tsx +++ b/src/components/Admin/resources/competition/semester/SemesterList.tsx @@ -12,12 +12,19 @@ import { import {DateTimeField} from '@/components/Admin/custom/DateTimeField' +import {seasonCodeStrings} from './seasonCodeStrings' + export const SemesterList: 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 ca34a9ea..1c70f2ff 100644 --- a/src/components/Admin/resources/competition/semester/SemesterShow.tsx +++ b/src/components/Admin/resources/competition/semester/SemesterShow.tsx @@ -3,6 +3,7 @@ import { ArrayField, BooleanField, Datagrid, + FunctionField, NumberField, ReferenceArrayField, ReferenceField, @@ -16,6 +17,8 @@ import {DateTimeField} from '@/components/Admin/custom/DateTimeField' import {MyShow} from '@/components/Admin/custom/MyShow' import {TruncatedTextField} from '@/components/Admin/custom/TruncatedTextField' +import {seasonCodeStrings} from './seasonCodeStrings' + export const SemesterShow: FC = () => ( @@ -23,7 +26,12 @@ 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/resources/competition/semester/seasonCodeStrings.ts new file mode 100644 index 00000000..92d94ac5 --- /dev/null +++ b/src/components/Admin/resources/competition/semester/seasonCodeStrings.ts @@ -0,0 +1,5 @@ +export const seasonCodeStrings = [ + {id: 0, name: 'Zimný'}, + {id: 1, name: 'Letný'}, + {id: 2, name: 'Iný'}, +]