Merge branch 'feat/inda-383-daily-stat' into 'main'
[ProtonMail-WebClient.git] / applications / calendar / src / app / components / eventModal / eventForm / createPropFactory.ts
blob11410790a6b84fad36b1bd98b5835616c35a49bc
1 import type { ChangeEvent } from 'react';
3 import type { EventModel } from '@proton/shared/lib/interfaces/calendar';
5 const createHandlers = ({
6     model,
7     setModel,
8     field,
9 }: {
10     model: EventModel;
11     setModel: (value: EventModel) => void;
12     field: keyof EventModel;
13 }) => ({
14     native: {
15         value: model[field],
16         onChange: (event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) =>
17             setModel({ ...model, [field]: event.currentTarget.value }),
18     },
19     model: {
20         value: model[field],
21         onChange: (value: EventModel[typeof field]) => setModel({ ...model, [field]: value }),
22     },
23 });
25 export default createHandlers;