From 6345ebd5366e399261c031947ff3a22824843ac7 Mon Sep 17 00:00:00 2001 From: lnxcz Date: Thu, 11 Apr 2024 08:27:29 +0200 Subject: [PATCH] feat: :sparkles: im the best --- public/print.html | 2 +- src/bindings.ts | 19 ++++++++++--------- src/index.tsx | 1 + .../Dashboard/pages/Other/Clients/index.tsx | 4 ++-- .../pages/Sales/Invoices/ManageInvoice.tsx | 11 ----------- src/store/services/stateService.ts | 4 ++-- 6 files changed, 16 insertions(+), 25 deletions(-) diff --git a/public/print.html b/public/print.html index 031ec36..eb34c65 100644 --- a/public/print.html +++ b/public/print.html @@ -5,7 +5,7 @@ diff --git a/src/bindings.ts b/src/bindings.ts index a8ee0ce..46342b6 100644 --- a/src/bindings.ts +++ b/src/bindings.ts @@ -1,6 +1,8 @@ import { invoke } from "@tauri-apps/api/core"; import type { Indicies } from "./screens/Dashboard/components/Table"; -import { StateService } from "./store/services/stateService"; +import { stateStore } from "./store/services/stateService"; + +const [state, _] = stateStore; export function checkDb() { return invoke<200 | 400>("check_db"); @@ -31,7 +33,7 @@ export enum DocumentType { export function getDocuments(documentType: DocumentType, indicies: Indicies) { return invoke("get_documents", { - companyId: StateService().state.companyId, + companyId: state.companyId, documentType, indicies, }); @@ -49,11 +51,11 @@ export function deleteDocument(id: number) { } export function createDocument(data: Document) { - return invoke("create_document", { data }); + return invoke("create_document", { data: { ...data, companyId: state.companyId } }); } export function getClients(indicies: Indicies) { - return invoke("get_clients", { companyId: StateService().state.companyId, indicies }); + return invoke("get_clients", { companyId: state.companyId, indicies }); } export function getClient(id: number) { @@ -88,7 +90,7 @@ type ManageClientData = { }; export function createClient(data: ManageClientData) { - return invoke("create_client", { data: { ...data, companyId: StateService().state.companyId } }); + return invoke("create_client", { data: { ...data, companyId: state.companyId } }); } export function migrateAndPopulate() { @@ -100,7 +102,7 @@ export async function getCompanies(exclude?: number) { } export async function getTemplates(indicies: Indicies) { - return await invoke("get_templates", { companyId: StateService().state.companyId, indicies }); + return await invoke("get_templates", { companyId: state.companyId, indicies }); } export async function saveTemplate(template: Template) { @@ -116,7 +118,7 @@ export async function deleteTemplate(id: number) { } export async function templateCount() { - return await invoke("template_count", { companyId: StateService().state.companyId }); + return await invoke("template_count", { companyId: state.companyId }); } export async function createTemplate(template: { @@ -124,7 +126,7 @@ export async function createTemplate(template: { html: string; name: string; }) { - return await invoke("create_template", { companyId: StateService().state.companyId, data: template }); + return await invoke("create_template", { companyId: state.companyId, data: template }); } export async function updateTemplate(id: number, html: string) { @@ -153,7 +155,6 @@ export interface Document { dueDate: Date; status: string; items: DocumentItem[]; - companyId: number; } export interface DocumentItem { diff --git a/src/index.tsx b/src/index.tsx index 0114691..1c8f4fa 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -43,6 +43,7 @@ render( + diff --git a/src/screens/Dashboard/pages/Other/Clients/index.tsx b/src/screens/Dashboard/pages/Other/Clients/index.tsx index a13b47d..3e8231f 100644 --- a/src/screens/Dashboard/pages/Other/Clients/index.tsx +++ b/src/screens/Dashboard/pages/Other/Clients/index.tsx @@ -1,4 +1,4 @@ -import { getClients } from "@/bindings"; +import { type GetClientData, getClients } from "@/bindings"; import { useI18n } from "@/i18n"; import Table, { type Indicies } from "@/screens/Dashboard/components/Table"; import { FiEdit, FiPlus } from "solid-icons/fi"; @@ -16,7 +16,7 @@ const Clients: Component = () => { return await getClients(indices); }; - const handleEdit = (item) => { + const handleEdit = (item: GetClientData) => { navigate(`detail/${item.id}`); }; diff --git a/src/screens/Dashboard/pages/Sales/Invoices/ManageInvoice.tsx b/src/screens/Dashboard/pages/Sales/Invoices/ManageInvoice.tsx index 5e85d86..55fe54b 100644 --- a/src/screens/Dashboard/pages/Sales/Invoices/ManageInvoice.tsx +++ b/src/screens/Dashboard/pages/Sales/Invoices/ManageInvoice.tsx @@ -29,7 +29,6 @@ const ManageInvoice: Component = () => { dueDate: new Date(), status: "DRAFT", items: [], - companyId: 0, }, onSubmit: async (invoice) => { console.log(invoice.value); @@ -176,16 +175,6 @@ const ManageInvoice: Component = () => { /> )} - - {(field) => ( - field().handleChange(Number(data))} - /> - )} -
diff --git a/src/store/services/stateService.ts b/src/store/services/stateService.ts index 1335786..5e86980 100644 --- a/src/store/services/stateService.ts +++ b/src/store/services/stateService.ts @@ -2,12 +2,12 @@ import { onMount } from "solid-js"; import { type StoreSetter, createStore } from "solid-js/store"; // import { Store } from "@tauri-apps/plugin-store"; -interface StateService { +export interface StateService { companyId: number | null; theme: "light" | "dark" | "auto"; } -const stateStore = createStore({} as StateService); +export const stateStore = createStore({} as StateService); export const StateService = () => { const [state, setState] = stateStore;