Skip to content

Commit

Permalink
feat: ✨ im the best
Browse files Browse the repository at this point in the history
  • Loading branch information
dfrnoch committed Apr 11, 2024
1 parent 42e4149 commit 6345ebd
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 25 deletions.
2 changes: 1 addition & 1 deletion public/print.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<script>
window.onload = function() {
// window.print();
window.alert("Cus")
window.print();
// window.close();
};
</script>
Expand Down
19 changes: 10 additions & 9 deletions src/bindings.ts
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -31,7 +33,7 @@ export enum DocumentType {

export function getDocuments(documentType: DocumentType, indicies: Indicies) {
return invoke<GetDocumentData[]>("get_documents", {
companyId: StateService().state.companyId,
companyId: state.companyId,
documentType,
indicies,
});
Expand All @@ -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<GetClientData[]>("get_clients", { companyId: StateService().state.companyId, indicies });
return invoke<GetClientData[]>("get_clients", { companyId: state.companyId, indicies });
}

export function getClient(id: number) {
Expand Down Expand Up @@ -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() {
Expand All @@ -100,7 +102,7 @@ export async function getCompanies(exclude?: number) {
}

export async function getTemplates(indicies: Indicies) {
return await invoke<Template[]>("get_templates", { companyId: StateService().state.companyId, indicies });
return await invoke<Template[]>("get_templates", { companyId: state.companyId, indicies });
}

export async function saveTemplate(template: Template) {
Expand All @@ -116,15 +118,15 @@ export async function deleteTemplate(id: number) {
}

export async function templateCount() {
return await invoke<number>("template_count", { companyId: StateService().state.companyId });
return await invoke<number>("template_count", { companyId: state.companyId });
}

export async function createTemplate(template: {
templateType: "INVOICE" | "ESTIMATE" | "RECEIPT";
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) {
Expand Down Expand Up @@ -153,7 +155,6 @@ export interface Document {
dueDate: Date;
status: string;
items: DocumentItem[];
companyId: number;
}

export interface DocumentItem {
Expand Down
1 change: 1 addition & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ render(
<Route path="/sales">
<Route path="/invoices">
<Route path="/" component={Invoices} />
<Route path="/new" component={ManageInvoice} />
<Route path="/:id" component={ManageInvoice} />
</Route>
<Route path="/templates" component={InvoiceTemplates} />
Expand Down
4 changes: 2 additions & 2 deletions src/screens/Dashboard/pages/Other/Clients/index.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -16,7 +16,7 @@ const Clients: Component = () => {
return await getClients(indices);
};

const handleEdit = (item) => {
const handleEdit = (item: GetClientData) => {
navigate(`detail/${item.id}`);
};

Expand Down
11 changes: 0 additions & 11 deletions src/screens/Dashboard/pages/Sales/Invoices/ManageInvoice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const ManageInvoice: Component = () => {
dueDate: new Date(),
status: "DRAFT",
items: [],
companyId: 0,
},
onSubmit: async (invoice) => {
console.log(invoice.value);
Expand Down Expand Up @@ -176,16 +175,6 @@ const ManageInvoice: Component = () => {
/>
)}
</form.Field>
<form.Field name="companyId">
{(field) => (
<Input
type="number"
label="Company ID"
defaultValue={field().state.value}
onChange={(data) => field().handleChange(Number(data))}
/>
)}
</form.Field>
</Section>
<Section title="Invoice Items">
<form.Field name="items">
Expand Down
4 changes: 2 additions & 2 deletions src/store/services/stateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<StateService>({} as StateService);
export const stateStore = createStore<StateService>({} as StateService);

export const StateService = () => {
const [state, setState] = stateStore;
Expand Down

0 comments on commit 6345ebd

Please sign in to comment.