@@ -4,11 +4,13 @@ import clsx from 'clsx';
44import { FormField } from '~/components/generic/Form' ;
55import { InputDateTime } from '~/components/generic/InputDateTime' ;
66import { InputLocation } from '~/components/generic/InputLocation' ;
7+ import { InputSelect , InputSelectOption } from '~/components/generic/InputSelect' ;
78import { InputText } from '~/components/generic/InputText' ;
89import { InputTextArea } from '~/components/generic/InputTextArea' ;
910import { Separator } from '~/components/generic/Separator' ;
1011import { InputSingleFile } from '~/components/InputSingleFile/InputSingleFile' ;
1112import { TournamentFormData } from '~/components/TournamentForm/TournamentForm.schema' ;
13+ import { getTournamentDisplayName } from '~/utils/common/getTournamentDisplayName' ;
1214
1315import styles from './GeneralFields.module.scss' ;
1416
@@ -21,16 +23,43 @@ export const GeneralFields = ({
2123 className,
2224 status = 'draft' ,
2325} : GeneralFieldsProps ) : JSX . Element => {
24- const { resetField } = useFormContext < TournamentFormData > ( ) ;
26+ const { resetField, watch } = useFormContext < TournamentFormData > ( ) ;
2527
2628 // Once a tournament is active, lock some fields
2729 const disableFields = ! [ 'draft' , 'published' ] . includes ( status ) ;
2830
31+ const getYearOptions = ( ) => {
32+ const options : InputSelectOption < string > [ ] = [ {
33+ value : '0' ,
34+ label : 'None' ,
35+ } ] ;
36+ for ( let i = 2010 ; i < 2027 ; i += 1 ) {
37+ options . push ( {
38+ value : i . toString ( ) ,
39+ label : i . toString ( ) ,
40+ } ) ;
41+ }
42+ return options ;
43+ } ;
44+
45+ const tournament = watch ( ) ;
46+
2947 return (
3048 < div className = { clsx ( styles . GeneralFields , className ) } >
31- < FormField name = "title" label = "Title" description = "Avoid including points and other rules in the title." disabled = { disableFields } >
32- < InputText type = "text" />
33- </ FormField >
49+ < div className = { styles . GeneralFields_TitleRow } >
50+ < FormField name = "title" label = "Title" description = "Avoid including points and other rules in the title." disabled = { disableFields } >
51+ < InputText type = "text" />
52+ </ FormField >
53+ < FormField name = "editionYear" label = "Year" disabled = { disableFields } >
54+ < InputSelect options = { getYearOptions ( ) } />
55+ </ FormField >
56+ </ div >
57+ { tournament . editionYear > 0 && (
58+ < div className = { styles . GeneralFields_Preview } >
59+ < p className = { styles . GeneralFields_Preview_Description } > Your tournament's name will render as:</ p >
60+ < h2 > { getTournamentDisplayName ( tournament ) } </ h2 >
61+ </ div >
62+ ) }
3463 < FormField name = "description" label = "Description" disabled = { disableFields } >
3564 < InputTextArea />
3665 </ FormField >
0 commit comments