From 0ff5cc8459c583a5e53f6810b1b166dd338c6d0c Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Thu, 25 Jan 2024 21:20:07 +0100 Subject: [PATCH] chore: format --- README.md | 9 +-- public/index.html | 19 ++++-- public/workers/backup.js | 2 +- public/workers/billable.js | 2 +- public/workers/export.js | 8 +-- public/workers/utils/utils.js | 2 +- public/workers/utils/utils.pdf.js | 4 +- src/App.tsx | 4 +- src/components/charts/week/WeekCharts.tsx | 2 +- src/components/projects/Projects.tsx | 4 +- .../settings/general/SettingsGeneral.tsx | 2 +- .../settings/templates/SettingsTemplates.tsx | 10 ++-- src/components/summary/Summary.tsx | 8 +-- src/components/tasks/Tasks.tsx | 13 ++-- src/index.tsx | 2 +- src/modals/client/CreateClientModal.tsx | 4 +- src/modals/invoice/InvoiceModal.tsx | 35 ++++++----- src/modals/project/ProjectModal.tsx | 8 +-- src/modals/task/create/CreateTaskModal.tsx | 14 +++-- src/modals/template/TemplateModal.tsx | 2 +- src/pages/about/About.tsx | 3 +- src/pages/details/client/ClientDetails.tsx | 8 +-- src/pages/details/task/TaskDetails.tsx | 59 ++++++++++--------- src/pages/period/Period.tsx | 6 +- src/service-worker.ts | 4 +- src/serviceWorkerRegistration.ts | 6 +- src/services/backup/backup.service.ts | 4 +- src/services/export/export.service.ts | 10 ++-- src/services/invoices/invoices.service.ts | 2 +- src/services/theme/theme.service.tsx | 8 +-- src/store/reducers/tasks.reducer.ts | 2 +- src/store/thunks/tasks.thunks.ts | 7 +-- src/theme/datetime.picker.scss | 12 ++-- src/utils/utils.budget.ts | 2 +- src/utils/utils.color.ts | 4 +- src/utils/utils.currency.ts | 2 +- src/utils/utils.filesystem.ts | 8 +-- 37 files changed, 165 insertions(+), 136 deletions(-) diff --git a/README.md b/README.md index 4a2b08c..ed3106c 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,11 @@
- [![App Store](https://img.shields.io/static/v1?label=App%20Store&message=Download&color=ff69b4)](https://apps.apple.com/us/app/tie-tracker/id1493399075) - [![Google Play](https://img.shields.io/static/v1?label=Google%20Play&message=Download&color=ff69b4)](https://play.google.com/store/apps/details?id=com.tietracker.app) - [![Website](https://img.shields.io/static/v1?label=Web&message=Open&color=success)](https://tietracker.com) - [![GitHub release](https://img.shields.io/github/release/peterpeterparker/tietracker/all?logo=GitHub)](https://github.com/peterpeterparker/tietracker/releases/latest) +[![App Store](https://img.shields.io/static/v1?label=App%20Store&message=Download&color=ff69b4)](https://apps.apple.com/us/app/tie-tracker/id1493399075) +[![Google Play](https://img.shields.io/static/v1?label=Google%20Play&message=Download&color=ff69b4)](https://play.google.com/store/apps/details?id=com.tietracker.app) +[![Website](https://img.shields.io/static/v1?label=Web&message=Open&color=success)](https://tietracker.com) +[![GitHub release](https://img.shields.io/github/release/peterpeterparker/tietracker/all?logo=GitHub)](https://github.com/peterpeterparker/tietracker/releases/latest) + ## Table of contents diff --git a/public/index.html b/public/index.html index 2401de3..137a70f 100644 --- a/public/index.html +++ b/public/index.html @@ -1,4 +1,4 @@ - + @@ -14,7 +14,10 @@ - + { $event.data.currency, $event.data.vat, $event.data.i18n, - $event.data.signature + $event.data.signature, ); } else if ($event && $event.data && $event.data.msg === 'backup-idb') { await self.backupIdb(); diff --git a/public/workers/billable.js b/public/workers/billable.js index a6e305c..3996ef6 100644 --- a/public/workers/billable.js +++ b/public/workers/billable.js @@ -117,7 +117,7 @@ self.listInvoices = async (invoices, filterProjectId) => { invoices, projects, clients, - filterProjectId + filterProjectId, ); const results = reduceAllProjects(projectsWithInvoices); diff --git a/public/workers/export.js b/public/workers/export.js index 5550365..46c8446 100644 --- a/public/workers/export.js +++ b/public/workers/export.js @@ -21,7 +21,7 @@ self.onmessage = async ($event) => { $event.data.client, $event.data.i18n, $event.data.type, - $event.data.signature + $event.data.signature, ); } }; @@ -35,7 +35,7 @@ self.export = async ( client, i18n, type, - signature + signature, ) => { if (!invoices || invoices.length <= 0) { self.postMessage(undefined); @@ -63,7 +63,7 @@ self.export = async ( client, i18n, type, - signature + signature, ); await updateBudget(results.invoices, filterProjectId, bill); @@ -83,7 +83,7 @@ async function exportInvoices( client, i18n, type, - signature + signature, ) { const promises = []; diff --git a/public/workers/utils/utils.js b/public/workers/utils/utils.js index 06e4d2a..7f58410 100644 --- a/public/workers/utils/utils.js +++ b/public/workers/utils/utils.js @@ -39,4 +39,4 @@ function loadProjects() { resolve(result); }); -} \ No newline at end of file +} diff --git a/public/workers/utils/utils.pdf.js b/public/workers/utils/utils.pdf.js index 6ce6fd5..2fc42ae 100644 --- a/public/workers/utils/utils.pdf.js +++ b/public/workers/utils/utils.pdf.js @@ -64,8 +64,8 @@ const initPdfColumns = (invoices, i18n, total) => { index === 0 ? firstColumnLength : index < columns.length - 1 - ? columnLength - : lastColumnLength, + ? columnLength + : lastColumnLength, }; }); diff --git a/src/App.tsx b/src/App.tsx index f2b5227..b2d1a78 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -158,8 +158,8 @@ const App: React.FC = (props: RootProps) => { )} - {(t, {i18n}) => {t('navigation.home')}} - + {(t, {i18n}) => {t('navigation.home')}} + diff --git a/src/components/charts/week/WeekCharts.tsx b/src/components/charts/week/WeekCharts.tsx index a0f5cc8..0290423 100644 --- a/src/components/charts/week/WeekCharts.tsx +++ b/src/components/charts/week/WeekCharts.tsx @@ -97,7 +97,7 @@ const WeekCharts: React.FC = () => { }, ], }; - }) + }), ); } else { setData(undefined); diff --git a/src/components/projects/Projects.tsx b/src/components/projects/Projects.tsx index 9a663b6..2fca68b 100644 --- a/src/components/projects/Projects.tsx +++ b/src/components/projects/Projects.tsx @@ -32,7 +32,7 @@ const Projects: React.FC = (props: Props) => { const {t} = useTranslation('projects'); const projects: Project[] | undefined = useSelector( - (state: RootState) => state.activeProjects.projects + (state: RootState) => state.activeProjects.projects, ); const task: Task | undefined = useSelector((state: RootState) => state.tasks.taskInProgress); const settings: SettingsModel = useSelector((state: RootState) => state.settings.settings); @@ -67,7 +67,7 @@ const Projects: React.FC = (props: Props) => {
{projects.map((project: Project) => { const colorContrast: string = contrast( - project.data.client ? project.data.client.color : undefined + project.data.client ? project.data.client.color : undefined, ); return ( diff --git a/src/components/settings/general/SettingsGeneral.tsx b/src/components/settings/general/SettingsGeneral.tsx index 4e57b35..b644b43 100644 --- a/src/components/settings/general/SettingsGeneral.tsx +++ b/src/components/settings/general/SettingsGeneral.tsx @@ -25,7 +25,7 @@ const SettingsGeneral: React.FC = (props) => { useEffect(() => { setNotificationsOn( - props.settings.notifications !== undefined ? props.settings.notifications : false + props.settings.notifications !== undefined ? props.settings.notifications : false, ); setBackup(props.settings.backup !== undefined ? props.settings.backup : true); }, [props.settings]); diff --git a/src/components/settings/templates/SettingsTemplates.tsx b/src/components/settings/templates/SettingsTemplates.tsx index 7f0199d..2219b5e 100644 --- a/src/components/settings/templates/SettingsTemplates.tsx +++ b/src/components/settings/templates/SettingsTemplates.tsx @@ -87,7 +87,7 @@ const SettingsTemplates: React.FC = (props) => { function openAddTemplate( $event: React.MouseEvent | React.TouchEvent, template: Template | undefined, - action: 'edit' | 'add' + action: 'edit' | 'add', ) { if (reorder && action === 'edit') { return; @@ -105,14 +105,14 @@ const SettingsTemplates: React.FC = (props) => { } const exist: boolean = templates.some( - (filteredTemplate: Template) => filteredTemplate.key === template.key + (filteredTemplate: Template) => filteredTemplate.key === template.key, ); if (exist) { setTemplates( templates.map((filteredTemplate: Template) => - filteredTemplate.key === template.key ? template : filteredTemplate - ) + filteredTemplate.key === template.key ? template : filteredTemplate, + ), ); } else { setTemplates([...templates, template]); @@ -125,7 +125,7 @@ const SettingsTemplates: React.FC = (props) => { } setTemplates( - templates.filter((filteredTemplate: Template) => filteredTemplate.key !== template.key) + templates.filter((filteredTemplate: Template) => filteredTemplate.key !== template.key), ); } diff --git a/src/components/summary/Summary.tsx b/src/components/summary/Summary.tsx index 8dfa29e..015897f 100644 --- a/src/components/summary/Summary.tsx +++ b/src/components/summary/Summary.tsx @@ -49,7 +49,7 @@ const Summary: React.FC = (props: Props) => { hours: acc.hours + value.hours, }; }, - {...open} + {...open}, ); setOpen(openSum); @@ -74,7 +74,7 @@ const Summary: React.FC = (props: Props) => { {formatCurrency( summary !== undefined ? summary.total.today.billable : undefined, - settings.currency.currency + settings.currency.currency, )} @@ -91,7 +91,7 @@ const Summary: React.FC = (props: Props) => { {formatCurrency( summary !== undefined ? summary.total.week.billable : undefined, - settings.currency.currency + settings.currency.currency, )} @@ -119,7 +119,7 @@ const Summary: React.FC = (props: Props) => { {formatCurrency( open !== undefined ? open.billable : undefined, - settings.currency.currency + settings.currency.currency, )} diff --git a/src/components/tasks/Tasks.tsx b/src/components/tasks/Tasks.tsx index 470f166..e1b6656 100644 --- a/src/components/tasks/Tasks.tsx +++ b/src/components/tasks/Tasks.tsx @@ -33,12 +33,12 @@ const Tasks: React.FC = (props: Props) => { const {t} = useTranslation('tasks'); const tasks: TaskItemStore[] | undefined = useSelector( - (state: RootState) => state.tasks.taskItems + (state: RootState) => state.tasks.taskItems, ); const selecteDay: Date = useSelector((state: RootState) => state.tasks.taskItemsSelectedDate); const projects: Project[] | undefined = useSelector( - (state: RootState) => state.activeProjects.projects + (state: RootState) => state.activeProjects.projects, ); function openDatePicker() { @@ -76,7 +76,8 @@ const Tasks: React.FC = (props: Props) => { fill="outline" color="medium" size="small" - aria-label={t('entries.select_date')}> + aria-label={t('entries.select_date')} + > {t('entries.select_date')} @@ -96,7 +97,8 @@ const Tasks: React.FC = (props: Props) => { fill="outline" color="medium" size="small" - aria-label={t('entries.add_task')}> + aria-label={t('entries.add_task')} + > {t('entries.add_task')} ); @@ -115,7 +117,8 @@ const Tasks: React.FC = (props: Props) => { <>

+ dangerouslySetInnerHTML={{__html: t(label, {selectedDate: format(selecteDay)})}} + >

, - document.getElementById('root') + document.getElementById('root'), ); // If you want your app to work offline and load faster, you can change diff --git a/src/modals/client/CreateClientModal.tsx b/src/modals/client/CreateClientModal.tsx index 84a9677..05f0551 100644 --- a/src/modals/client/CreateClientModal.tsx +++ b/src/modals/client/CreateClientModal.tsx @@ -108,7 +108,7 @@ const CreateClientModal: React.FC = (props: Props) => { function validateClientName() { setValidClientName( - clientData !== undefined && clientData.name !== undefined && clientData.name.length >= 3 + clientData !== undefined && clientData.name !== undefined && clientData.name.length >= 3, ); } @@ -246,7 +246,7 @@ const CreateClientModal: React.FC = (props: Props) => { projectData.name !== undefined && projectData.name.length >= 3 && projectData.rate && - projectData.rate.hourly >= 0 + projectData.rate.hourly >= 0, ); } diff --git a/src/modals/invoice/InvoiceModal.tsx b/src/modals/invoice/InvoiceModal.tsx index 58f5a83..f617089 100644 --- a/src/modals/invoice/InvoiceModal.tsx +++ b/src/modals/invoice/InvoiceModal.tsx @@ -108,7 +108,7 @@ const InvoiceModal: React.FC = (props) => { billable: props.invoice.billable, hours: props.invoice.hours, } - : undefined + : undefined, ); } else { setFrom(undefined); @@ -134,7 +134,7 @@ const InvoiceModal: React.FC = (props) => { settings.vat, bill, type, - settings.signature + settings.signature, ); } else if (isPlatform('hybrid')) { await ExportService.getInstance().exportMobileFileSystem( @@ -145,7 +145,7 @@ const InvoiceModal: React.FC = (props) => { settings.vat, bill, type, - settings.signature + settings.signature, ); } else { await ExportService.getInstance().exportDownload( @@ -156,7 +156,7 @@ const InvoiceModal: React.FC = (props) => { settings.vat, bill, type, - settings.signature + settings.signature, ); } @@ -194,12 +194,12 @@ const InvoiceModal: React.FC = (props) => { billable: data.billable, hours: data.hours, } - : undefined + : undefined, ); }, props.invoice.project_id, from, - to + to, ); } @@ -280,7 +280,8 @@ const InvoiceModal: React.FC = (props) => { hours: formatTime(billable.hours * 3600 * 1000), ratio, }), - }}>

+ }} + >

); } @@ -291,7 +292,8 @@ const InvoiceModal: React.FC = (props) => { amount: formatCurrency(billable.billable, settings.currency.currency), hours: formatTime(billable.hours * 3600 * 1000), }), - }}>

+ }} + >

); } @@ -309,7 +311,7 @@ const InvoiceModal: React.FC = (props) => { props.invoice.project.budget.billed !== undefined ? props.invoice.project.budget.billed : 0; const cumulated: string = formatCurrency( billed + billable.billable, - settings.currency.currency + settings.currency.currency, ); if ( @@ -319,7 +321,8 @@ const InvoiceModal: React.FC = (props) => { ) { return (

+ dangerouslySetInnerHTML={{__html: t('invoices:invoice.billed', {amount: cumulated})}} + >

); } @@ -327,7 +330,8 @@ const InvoiceModal: React.FC = (props) => {

+ }} + >

); } @@ -389,7 +393,8 @@ const InvoiceModal: React.FC = (props) => { {'--background-checked': color, '--border-color-checked': color} as CSSProperties } checked={bill} - onIonChange={($event: CustomEvent) => setBill($event.detail.checked)}> + onIonChange={($event: CustomEvent) => setBill($event.detail.checked)} + > @@ -421,7 +426,8 @@ const InvoiceModal: React.FC = (props) => { '--background-activated': colorContrast, '--color-activated': color, } as CSSProperties - }> + } + > {t('export:excel')} ); @@ -444,7 +450,8 @@ const InvoiceModal: React.FC = (props) => { '--background-activated': colorContrast, '--color-activated': color, } as CSSProperties - }> + } + > {t('export:pdf')} ); diff --git a/src/modals/project/ProjectModal.tsx b/src/modals/project/ProjectModal.tsx index d51dc01..d31524f 100644 --- a/src/modals/project/ProjectModal.tsx +++ b/src/modals/project/ProjectModal.tsx @@ -93,24 +93,24 @@ const ProjectModal: React.FC = (props) => { setRate( project && project.data !== undefined && project.data.rate !== undefined ? project.data.rate.hourly - : undefined + : undefined, ); setVat( project && project.data !== undefined && project.data.rate !== undefined ? project.data.rate.vat - : false + : false, ); setEnabled(project && project.data !== undefined ? !project.data.disabled : false); setBudgetValue( project && project.data !== undefined && project.data.budget !== undefined ? project.data.budget.budget - : undefined + : undefined, ); setBilled( project && project.data !== undefined && project.data.budget !== undefined ? project.data.budget.billed - : undefined + : undefined, ); setBudgetType(project?.data?.budget?.type); diff --git a/src/modals/task/create/CreateTaskModal.tsx b/src/modals/task/create/CreateTaskModal.tsx index 6fee67f..cbfec63 100644 --- a/src/modals/task/create/CreateTaskModal.tsx +++ b/src/modals/task/create/CreateTaskModal.tsx @@ -49,7 +49,7 @@ const CreateTaskModal: React.FC = (props: Props) => { const [to, setTo] = useState(new Date()); const projects: Project[] | undefined = useSelector( - (state: RootState) => state.activeProjects.projects + (state: RootState) => state.activeProjects.projects, ); const settings: SettingsModel = useSelector((state: RootState) => state.settings.settings); @@ -133,7 +133,8 @@ const CreateTaskModal: React.FC = (props: Props) => { '--color': colorContrast, '--ion-toolbar-color': colorContrast, } as CSSProperties - }> + } + > {t('tasks:create.title')} props.closeAction()}> @@ -182,7 +183,8 @@ const CreateTaskModal: React.FC = (props: Props) => { '--background-activated': colorContrast, '--color-activated': color, } as CSSProperties - }> + } + > {t('common:actions.submit')} @@ -206,7 +208,8 @@ const CreateTaskModal: React.FC = (props: Props) => { interfaceOptions={{header: t('tasks:create.project')}} placeholder={t('tasks:create.project')} value={project} - onIonChange={($event: CustomEvent) => onProjectChange($event)}> + onIonChange={($event: CustomEvent) => onProjectChange($event)} + > {renderProjectOptions()} @@ -241,7 +244,8 @@ const CreateTaskModal: React.FC = (props: Props) => { interfaceOptions={{header: t('tasks:tracker.description')}} placeholder={t('tasks:tracker.description')} value={description} - onIonChange={($event: CustomEvent) => onDescriptionChange($event)}> + onIonChange={($event: CustomEvent) => onDescriptionChange($event)} + > {settings.descriptions.map((description: string, i: number) => { return ( diff --git a/src/modals/template/TemplateModal.tsx b/src/modals/template/TemplateModal.tsx index 2dfb72d..bcf38b9 100644 --- a/src/modals/template/TemplateModal.tsx +++ b/src/modals/template/TemplateModal.tsx @@ -57,7 +57,7 @@ const TemplateModal: React.FC = (props: Props) => { key: props.template ? props.template.key : uuid(), description: description as string, }, - 'edit' + 'edit', ); } diff --git a/src/pages/about/About.tsx b/src/pages/about/About.tsx index de79f4a..0eb185f 100644 --- a/src/pages/about/About.tsx +++ b/src/pages/about/About.tsx @@ -94,7 +94,8 @@ const About: React.FC = () => { href="http://github.com/peterpeterparker/tietracker" target="_blank" rel="noopener noreferrer" - className={styles.github}> + className={styles.github} + > GitHub . diff --git a/src/pages/details/client/ClientDetails.tsx b/src/pages/details/client/ClientDetails.tsx index bea8592..ba31435 100644 --- a/src/pages/details/client/ClientDetails.tsx +++ b/src/pages/details/client/ClientDetails.tsx @@ -74,14 +74,14 @@ const ClientDetails: React.FC = (props: Props) => { const [selectedProjectId, setSelectedProjectId] = useState(undefined); const [projectModalAction, setProjectModalAction] = useState( - undefined + undefined, ); useIonViewWillEnter(async () => { setSaving(false); const client: Client | undefined = await ClientsService.getInstance().find( - props.match.params.id + props.match.params.id, ); setClient(client); @@ -104,7 +104,7 @@ const ClientDetails: React.FC = (props: Props) => { async function loadProjects() { const projects: Project[] | undefined = await ProjectsService.getInstance().listForClient( - props.match.params.id + props.match.params.id, ); setProjects(projects); } @@ -142,7 +142,7 @@ const ClientDetails: React.FC = (props: Props) => { client !== undefined && client.data !== undefined && client.data.name !== undefined && - client.data.name.length >= 3 + client.data.name.length >= 3, ); } diff --git a/src/pages/details/task/TaskDetails.tsx b/src/pages/details/task/TaskDetails.tsx index 5b0ea13..45812e9 100644 --- a/src/pages/details/task/TaskDetails.tsx +++ b/src/pages/details/task/TaskDetails.tsx @@ -85,13 +85,13 @@ const TaskDetails: React.FC = (props: Props) => { setDisableActions( task === undefined || !task.data || - (task.data.invoice && task.data.invoice.status === 'billed') + (task.data.invoice && task.data.invoice.status === 'billed'), ); setTaskBilled( - task === undefined || + task === undefined || !task.data || - (task.data.invoice && task.data.invoice.status === 'billed') + (task.data.invoice && task.data.invoice.status === 'billed'), ); }, [task]); @@ -101,7 +101,7 @@ const TaskDetails: React.FC = (props: Props) => { const task: Task | undefined = await TasksService.getInstance().find( props.match.params.id, - props.match.params.day + props.match.params.day, ); setTask(task); @@ -111,12 +111,12 @@ const TaskDetails: React.FC = (props: Props) => { setDescription(task.data.description); const project: Project | undefined = await ProjectsService.getInstance().find( - task.data.project_id + task.data.project_id, ); setProject(project); const client: Client | undefined = await ClientsService.getInstance().find( - task.data.client_id + task.data.client_id, ); setClient(client); } else { @@ -262,9 +262,8 @@ const TaskDetails: React.FC = (props: Props) => { maxlength={256} value={description} input-mode="text" - onIonInput={($event: IonInputCustomEvent) => - onDescriptionChange($event) - }> + onIonInput={($event: IonInputCustomEvent) => onDescriptionChange($event)} + > @@ -328,39 +327,41 @@ const TaskDetails: React.FC = (props: Props) => { '--background-activated': colorContrast, '--color-activated': color, } as CSSProperties - }> + } + > {t('common:actions.update')} taskBilled ? setShowAlertDelete(true): deleteTask()} + onClick={() => (taskBilled ? setShowAlertDelete(true) : deleteTask())} color="button" fill="outline" - disabled={saving}> + disabled={saving} + > {t('common:actions.delete')} setShowAlertDelete(false)} - header={t('tasks:delete.warning')} - message={t('tasks:delete.message')} - buttons={[ - { - text: t('common:actions.cancel'), - role: 'cancel', - handler: async () => { - setShowAlertDelete(false) - }, + isOpen={showAlertDelete} + onDidDismiss={() => setShowAlertDelete(false)} + header={t('tasks:delete.warning')} + message={t('tasks:delete.message')} + buttons={[ + { + text: t('common:actions.cancel'), + role: 'cancel', + handler: async () => { + setShowAlertDelete(false); }, - { - text: t('common:actions.delete'), - handler: async () => { - await deleteTask(); - }, + }, + { + text: t('common:actions.delete'), + handler: async () => { + await deleteTask(); }, - ]} + }, + ]} />