Skip to content

Commit

Permalink
style: Rename departement in department in the code
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinVignal committed Feb 25, 2024
1 parent 76239fb commit 30317b1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function App (): JSX.Element {

const [imageUploads, setImageUploads] = useState<File[]>([])
const [globalInfo, setGlobalInfo] = useState<GlobalInfoData | null>(
{ consent: true, datetime: new Date(), departement: 'Aine' }
{ consent: true, datetime: new Date(), department: 'Aine' }
)
const [, setPicturesInfo] = useState<PictureInfo[]>([])

Expand Down
16 changes: 8 additions & 8 deletions src/pages/global-info/GlobalInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,17 @@ const departments: DepartmentInfo = {

export interface GlobalInfoData {
datetime: Date
departement: string
department: string
consent: boolean
}

export const GlobalInfo = ({ imageUploads, onSubmit }: { imageUploads: File[], onSubmit: (output: GlobalInfoData) => void }): JSX.Element => {
const [consentCheckboxChecked, setConsentCheckboxChecked] = useState(false)
const [date, setDate] = useState<Date | null>(new Date(imageUploads[0].lastModified))
const [departement, setDepartement] = useState<string | null>(null)
const [department, setDepartment] = useState<string | null>(null)

const isValid = (): boolean => {
if (!consentCheckboxChecked && (departement === null)) return false
if (!consentCheckboxChecked && (department === null)) return false
if (date === null || date.getTime() > Date.now()) {
// If the date is in the future, it's not valid
return false
Expand All @@ -136,7 +136,7 @@ export const GlobalInfo = ({ imageUploads, onSubmit }: { imageUploads: File[], o
if (!isValid()) { return }
onSubmit({
datetime: date!,
departement: departement as string,
department: department!,
consent: consentCheckboxChecked
})
}
Expand All @@ -146,7 +146,7 @@ export const GlobalInfo = ({ imageUploads, onSubmit }: { imageUploads: File[], o
<h2>Ajoutez des informations pour ces photos </h2>
<h3>Vous pourrez éditer l&apos;emplacement pour chaque photo à l&#39;étape suivante.</h3>
<div id="form" className='formBox' >
<GlobalInfoForm date={date} onDateTimeChange={setDate} onDepartementChange={setDepartement}/>
<GlobalInfoForm date={date} onDateTimeChange={setDate} onDepartmentChange={setDepartment}/>
</div>
<Checkbox label="J'accepte que ces photos soient intégrées à un jeu de données public" onChecked={setConsentCheckboxChecked} checked={consentCheckboxChecked}/>
<Button text='Suivant' filled disabled={!isValid()} onClick={onButtonClick}/>
Expand All @@ -156,7 +156,7 @@ export const GlobalInfo = ({ imageUploads, onSubmit }: { imageUploads: File[], o

GlobalInfo.displayName = 'GlobalInfo'

export const GlobalInfoForm = ({ date, onDateTimeChange, onDepartementChange, initialDepartement }: { date: Date | null, onDateTimeChange: (dateTime: Date) => void, onDepartementChange: (departement: string | null) => void, initialDepartement?: string }): JSX.Element => {
export const GlobalInfoForm = ({ date, onDateTimeChange, onDepartmentChange, initialDepartment }: { date: Date | null, onDateTimeChange: (dateTime: Date) => void, onDepartmentChange: (department: string | null) => void, initialDepartment?: string }): JSX.Element => {
return (
<>
<DateTimePicker dateTime={date} onChange={onDateTimeChange}/>
Expand All @@ -166,8 +166,8 @@ export const GlobalInfoForm = ({ date, onDateTimeChange, onDepartementChange, in
placeholder='Choisir un département'
icon={faChevronDown}
items={Object.keys(departments).map((name) => ({ displayName: name, value: name }))}
onChange={onDepartementChange}
initialValue={initialDepartement}
onChange={onDepartmentChange}
initialValue={initialDepartment}
/>
</>
)
Expand Down
2 changes: 1 addition & 1 deletion src/pages/per-picture-info/PerPictureInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export const PerPictureInfo = ({
<div className="pillsContainer">
<Pill text={formatDate(perPictureInfo[currentPictureIndex].datetime)} onClick={onPillClick} icon={faPencil}/>
<Pill text={formatTime(perPictureInfo[currentPictureIndex].datetime)} onClick={onPillClick} icon={faPencil}/>
<Pill text={perPictureInfo[currentPictureIndex].departement} onClick={onPillClick} icon={faPencil}/>
<Pill text={perPictureInfo[currentPictureIndex].department} onClick={onPillClick} icon={faPencil}/>
</div>
<h3>Quels éléments apparaissent ?</h3>
<p>Sélectionnez les éléments que vous voyez</p>
Expand Down
6 changes: 3 additions & 3 deletions src/pages/per-picture-info/PictureInfoEditModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ export type PictureInfoEditModalContext = PictureInfo & {

export const PictureInfoEditModal: ModalInnerComponent = ({ close, context }: { close: () => void, context: PictureInfoEditModalContext }): JSX.Element => {
const [date, setDate] = useState<Date>(context.datetime)
const [departement, setDepartement] = useState<string | null>(context.departement)
const [department, setDepartment] = useState<string | null>(context.department)
const submit = (): void => {
context.patchInfo({ datetime: date, departement: departement as string, consent: true })
context.patchInfo({ datetime: date, department: department as string, consent: true })
close()
}
// todo : fix validity
return (<>
<FontAwesomeIcon icon={faCircleXmark} className='closeIcon' onClick={close}/>
<GlobalInfoForm date={date} onDateTimeChange={setDate} onDepartementChange={(d) => setDepartement(d as string)} initialDepartement={context.departement}/>
<GlobalInfoForm date={date} onDateTimeChange={setDate} onDepartmentChange={(d) => setDepartment(d as string)} initialDepartment={context.department}/>
<Button text='Valider' onClick={submit}/>
</>)
}

0 comments on commit 30317b1

Please sign in to comment.