From a24875cf36caaf9a2e29e3c146ef1c388e10ab9b Mon Sep 17 00:00:00 2001 From: Katja Lutz Date: Fri, 24 Jun 2022 20:23:37 +0200 Subject: [PATCH] feat: show project number in document title --- src/components/Settings/Overlay.tsx | 18 +++++++++++------- src/routes/index.tsx | 10 ++++++---- src/stores.ts | 16 ++++++++++++---- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/components/Settings/Overlay.tsx b/src/components/Settings/Overlay.tsx index a1d7fe7..0ec2703 100644 --- a/src/components/Settings/Overlay.tsx +++ b/src/components/Settings/Overlay.tsx @@ -26,6 +26,8 @@ import { localStoreSchema, POSITION_TYPE_AGILE, POSITION_TYPE_QUANTITY, + PrintType, + printTypeTitles, PRINT_TYPE_CONFIRMATION, PRINT_TYPE_INVOICE, PRINT_TYPE_OFFER, @@ -876,15 +878,17 @@ const SettingsOverlay: Component = () => { }} > - {([type, label]) => ( + {(type) => ( )} diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 2c4d0da..42be673 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -26,6 +26,7 @@ import { createStore, createUiStore, LocalStoreContext, + printTypeTitles, PRINT_TYPE_CONFIRMATION, PRINT_TYPE_INVOICE, PRINT_TYPE_OFFER, @@ -128,10 +129,11 @@ export default function Home() { const titleMemo = createMemo( () => (state.positions.length > 0 ? `(${state.positions.length}) ` : "") + - "Räppli" + - (state.project.projectNumber.length - ? ` - ${state.project.projectNumber}` - : "") + "Räppli - " + + (state.project.projectNumber.length > 0 + ? `${state.project.projectNumber} - ` + : "") + + printTypeTitles[uiState.printType] ); return ( diff --git a/src/stores.ts b/src/stores.ts index 1ea49ab..b9595da 100644 --- a/src/stores.ts +++ b/src/stores.ts @@ -29,13 +29,21 @@ export const PRINT_TYPE_OFFER = "OFFER"; export const PRINT_TYPE_CONFIRMATION = "CONFIRMATION"; export const PRINT_TYPE_INVOICE = "INVOICE"; +export type PrintType = + | typeof PRINT_TYPE_OFFER + | typeof PRINT_TYPE_CONFIRMATION + | typeof PRINT_TYPE_INVOICE; + +export const printTypeTitles = { + [PRINT_TYPE_OFFER]: "Offerte", + [PRINT_TYPE_CONFIRMATION]: "Bestätigung", + [PRINT_TYPE_INVOICE]: "Rechnung", +}; + export const createUiStore = () => createStore_({ lastSaved: 0, - printType: PRINT_TYPE_INVOICE as - | typeof PRINT_TYPE_OFFER - | typeof PRINT_TYPE_CONFIRMATION - | typeof PRINT_TYPE_INVOICE, + printType: PRINT_TYPE_INVOICE as PrintType, selectedPosition: undefined as undefined | number, }); export type UiStore = ReturnType;