Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SeasonCodeField to event #491

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading