Skip to content

Commit

Permalink
Added SeasonCodeField to event (#491)
Browse files Browse the repository at this point in the history
  • Loading branch information
vgeffer authored Nov 24, 2024
1 parent fec541f commit e5f8001
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 21 deletions.
16 changes: 16 additions & 0 deletions src/components/Admin/custom/SeasonCodeField.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {FC} from 'react'
import {FunctionField, FunctionFieldProps} from 'react-admin'

import {seasonCodeStrings} from '../seasonCodeStrings'

export const SeasonCodeField: FC<Omit<FunctionFieldProps, 'render'>> = ({source, ...rest}) => {
return (
<FunctionField
source={source}
render={(record) => {
return `${seasonCodeStrings[record.season_code].name ?? ''}`
}}
{...rest}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => (
<List>
<Datagrid rowClick="show">
<ReferenceField source="competition" reference="competition/competition" link={false} />
<NumberField source="year" />
<NumberField source="season_code" />
<SeasonCodeField source="season_code" />
<TextField source="school_year" />
<DateTimeField source="start" />
<DateTimeField source="end" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => (
<MyShow>
Expand All @@ -20,7 +21,7 @@ export const EventShow: FC = () => (
<SimpleShowLayout>
<ReferenceField source="competition" reference="competition/competition" link="show" />
<NumberField source="year" />
<NumberField source="season_code" />
<SeasonCodeField source="season_code" />
<TextField source="school_year" />
<DateTimeField source="start" />
<DateTimeField source="end" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => (
<MyCreate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => (
<MyEdit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,14 @@ import {
} from 'react-admin'

import {DateTimeField} from '@/components/Admin/custom/DateTimeField'

import {seasonCodeStrings} from './seasonCodeStrings'
import {SeasonCodeField} from '@/components/Admin/custom/SeasonCodeField'

export const SemesterList: FC = () => (
<List>
<Datagrid rowClick="show">
<ReferenceField source="competition" reference="competition/competition" link={false} />
<NumberField source="year" />
<FunctionField
source="season_code"
render={(record) => {
return `${seasonCodeStrings[record.season_code].name ?? ''}`
}}
/>
<SeasonCodeField source="season_code" />
<TextField source="school_year" />
<DateTimeField source="start" />
<DateTimeField source="end" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
ArrayField,
BooleanField,
Datagrid,
FunctionField,
NumberField,
ReferenceArrayField,
ReferenceField,
Expand All @@ -15,23 +14,17 @@ 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 = () => (
<MyShow>
<TabbedShowLayout>
<Tab label="general">
<SimpleShowLayout>
<ReferenceField source="competition" reference="competition/competition" link="show" />
<NumberField source="year" />
<FunctionField
source="season_code"
render={(record) => {
return `${seasonCodeStrings[record.season_code].name ?? ''}`
}}
/>
<SeasonCodeField source="season_code" />
<TextField source="school_year" />
<DateTimeField source="start" />
<DateTimeField source="end" />
Expand Down
File renamed without changes.

0 comments on commit e5f8001

Please sign in to comment.