import { FunctionalComponent, h, Fragment } from "preact"; import { Project } from "../../models/project"; import { ProjectReducerActions, updateParam } from "../../hooks/use-project-reducer"; import { getRoundUpEstimations, getCurrency, getTimeUnit, getHideFinancialPreviewOnPrint } from "../../models/params"; import TaskCategoriesTable from "./task-categories-table"; import { useState } from "preact/hooks"; import { route } from "preact-router"; import { getProjectStorageKey } from "../../util/storage"; export interface ParamsTabProps { project: Project dispatch: (action: ProjectReducerActions) => void } const ParamsTab: FunctionalComponent = ({ project, dispatch }) => { const [ deleteButtonEnabled, setDeleteButtonEnabled ] = useState(false); const onEnableDeleteButtonChange = (evt: Event) => { const checked = (evt.currentTarget as HTMLInputElement).checked; setDeleteButtonEnabled(checked); } const onRoundUpChange = (evt: Event) => { const checked = (evt.currentTarget as HTMLInputElement).checked; dispatch(updateParam("roundUpEstimations", checked)); }; const onHideFinancialPreview = (evt: Event) => { const checked = (evt.currentTarget as HTMLInputElement).checked; dispatch(updateParam("hideFinancialPreviewOnPrint", checked)); }; const onCurrencyChange = (evt: Event) => { const value = (evt.currentTarget as HTMLInputElement).value; dispatch(updateParam("currency", value)); }; const timeUnit = getTimeUnit(project); const onTimeUnitLabelChange = (evt: Event) => { const value = (evt.currentTarget as HTMLInputElement).value; dispatch(updateParam("timeUnit", { ...timeUnit, label: value })); }; const onTimeUnitAcronymChange = (evt: Event) => { const value = (evt.currentTarget as HTMLInputElement).value; dispatch(updateParam("timeUnit", { ...timeUnit, acronym: value })); }; const onDeleteProjectClick = (evt: Event) => { const projectStorageKey = getProjectStorageKey(project.id); window.localStorage.removeItem(projectStorageKey); route('/'); }; return (





); }; export default ParamsTab;