Skip to content

Commit

Permalink
feat: ✨ many changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dfrnoch committed Apr 12, 2024
1 parent 6671daf commit fc492e8
Show file tree
Hide file tree
Showing 17 changed files with 219 additions and 191 deletions.
2 changes: 2 additions & 0 deletions src/bindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export enum DocumentType {
INVOICE = "INVOICE",
PROFORMA = "PROFORMA",
RECIEVE = "RECIEVE",
TEMPLATE = "TEMPLATE",
}

export function getDocuments(documentType: DocumentType, indicies: Indicies) {
Expand All @@ -38,6 +39,7 @@ export function getDocuments(documentType: DocumentType, indicies: Indicies) {
indicies,
});
}

export function getDocument(id: number) {
return invoke<Document>("get_document", { id });
}
Expand Down
4 changes: 3 additions & 1 deletion src/i18n/dict/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"help": {
"retrieve_by_cin": "Po zadání správného IČA se načte zbytek údajů automaticky"
}
}
},
"error_creating_ompany": "Při vytváření firmy došlo k chybě. Zkuste to prosím znovu.",
"company_created": "Firma byla úspěšně vytvořena"
},
"table": {
"all": "Vše"
Expand Down
4 changes: 3 additions & 1 deletion src/i18n/dict/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"help": {
"retrieve_by_cin": "After entering your CIN, we will try to retrieve your company information from the government database."
}
}
},
"error_creating_ompany": "Error creating company",
"company_created": "Company created"
},
"table": {
"all": "All"
Expand Down
9 changes: 0 additions & 9 deletions src/screens/Dashboard/components/Form/index.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/screens/Dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const Dashboard: ParentComponent = (props) => {
<>
<div class="flex flex-row items-start w-screen">
<Sidebar />
<Toaster position="bottom-right" gutter={8} />
{/* px 4 pt-50px */}
<div class="overflow-y-auto mx-auto w-full h-screen pt-40px no-scrollbar bg-primary text-primary">
{props.children}
Expand Down
66 changes: 27 additions & 39 deletions src/screens/Dashboard/pages/Other/Clients/ManageClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,18 @@ import Container from "@/screens/Dashboard/components/Container";
import PageHeader from "@/screens/Dashboard/components/PageHeader";
import HeaderButton from "@/screens/Dashboard/components/PageHeader/HeaderButton";
import { useNavigate, useParams } from "@solidjs/router";
import { For, Show, onMount, type Component } from "solid-js";
import { Show, onMount, type Component } from "solid-js";
import { createForm } from "@tanstack/solid-form";
import Input from "@/screens/Dashboard/components/Form/Input";
import Dropdown from "@/screens/Dashboard/components/Form/Dropdown";
import Input from "@/shared/components/Form/Input";
import Dropdown from "@/shared/components/Form/Dropdown";
import { type Client, createClient, deleteClient, getClient, updateClient } from "@/bindings";
import Form from "@/screens/Dashboard/components/Form";
import Form from "@/shared/components/Form";
import { zodValidator } from "@tanstack/zod-form-adapter";
import { z } from "zod";
import Section from "@/screens/Dashboard/components/Form/Section";
import Section from "@/shared/components/Form/Section";
import toast from "solid-toast";
import { FiTrash } from "solid-icons/fi";

const schema = z.object({
id: z.number(),
name: z.string().min(20),
clientType: z.enum(["BOTH", "SUPPLIER", "CUSTOMER"]),
email: z.string().optional(),
cin: z.string(),
vatId: z.string(),
address: z.string(),
city: z.string(),
zip: z.string(),
phone: z.string(),
});

const ManageClient: Component = () => {
const params = useParams<{ readonly id?: string }>();
const [t] = useI18n();
Expand All @@ -46,9 +33,6 @@ const ManageClient: Component = () => {
phone: "",
} as Client,
validatorAdapter: zodValidator,
validators: {
onSubmit: schema,
},
onSubmitInvalid: (e) => {
console.log("invalid", e.formApi.state.errors);
},
Expand Down Expand Up @@ -104,19 +88,17 @@ const ManageClient: Component = () => {
</Show>,
]}
/>
<Form form={form}>
<Form>
<Section title="Client Information">
<form.Field name="name" validators={{ onChange: z.string().min(20), onChangeAsyncDebounceMs: 500 }}>
<form.Field name="name" validators={{ onChange: z.string().min(2).max(100), onChangeAsyncDebounceMs: 500 }}>
{(field) => (
<>
<Input
type="text"
label="Name"
defaultValue={field().state.value}
onChange={(data) => field().handleChange(data)}
errors={field().state.meta.touchedErrors}
/>
</>
<Input
type="text"
label="Name"
defaultValue={field().state.value}
onChange={(data) => field().handleChange(data)}
errors={field().state.meta.touchedErrors}
/>
)}
</form.Field>
<form.Field
Expand Down Expand Up @@ -150,65 +132,71 @@ const ManageClient: Component = () => {
/>
)}
</form.Field>
<form.Field name="cin">
<form.Field name="cin" validators={{ onChange: z.string().optional(), onChangeAsyncDebounceMs: 500 }}>
{(field) => (
<Input
type="text"
label="CIN"
defaultValue={field().state.value}
onChange={(data) => field().handleChange(data)}
errors={field().state.meta.touchedErrors}
/>
)}
</form.Field>
<form.Field name="vatId">
<form.Field name="vatId" validators={{ onChange: z.string().optional(), onChangeAsyncDebounceMs: 500 }}>
{(field) => (
<Input
type="text"
label="VAT ID"
defaultValue={field().state.value}
onChange={(data) => field().handleChange(data)}
errors={field().state.meta.touchedErrors}
/>
)}
</form.Field>
</Section>
<Section title="Adress">
<form.Field name="address">
<Section title="Address">
<form.Field name="address" validators={{ onChange: z.string().optional(), onChangeAsyncDebounceMs: 500 }}>
{(field) => (
<Input
type="text"
label="Street Address"
defaultValue={field().state.value}
onChange={(data) => field().handleChange(data)}
errors={field().state.meta.touchedErrors}
/>
)}
</form.Field>
<form.Field name="city">
<form.Field name="city" validators={{ onChange: z.string().optional(), onChangeAsyncDebounceMs: 500 }}>
{(field) => (
<Input
type="text"
label="City"
defaultValue={field().state.value}
onChange={(data) => field().handleChange(data)}
errors={field().state.meta.touchedErrors}
/>
)}
</form.Field>
<form.Field name="zip">
<form.Field name="zip" validators={{ onChange: z.string().optional(), onChangeAsyncDebounceMs: 500 }}>
{(field) => (
<Input
type="text"
label="Postal Code"
defaultValue={field().state.value}
onChange={(data) => field().handleChange(data)}
errors={field().state.meta.touchedErrors}
/>
)}
</form.Field>
<form.Field name="phone">
<form.Field name="phone" validators={{ onChange: z.string().optional(), onChangeAsyncDebounceMs: 500 }}>
{(field) => (
<Input
type="tel"
label="Phone Number"
defaultValue={field().state.value}
onChange={(data) => field().handleChange(data)}
errors={field().state.meta.touchedErrors}
/>
)}
</form.Field>
Expand Down
8 changes: 4 additions & 4 deletions src/screens/Dashboard/pages/Sales/Invoices/ManageInvoice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import HeaderButton from "@/screens/Dashboard/components/PageHeader/HeaderButton
import { useNavigate, useParams } from "@solidjs/router";
import { For, Show, onMount, type Component } from "solid-js";
import { createForm } from "@tanstack/solid-form";
import Input from "@/screens/Dashboard/components/Form/Input";
import Dropdown from "@/screens/Dashboard/components/Form/Dropdown";
import Input from "@/shared/components/Form/Input";
import Dropdown from "@/shared/components/Form/Dropdown";
import { createDocument, deleteDocument, getDocument, updateDocument, type Document } from "@/bindings";
import Form from "@/screens/Dashboard/components/Form";
import Section from "@/screens/Dashboard/components/Form/Section";
import Form from "@/shared/components/Form";
import Section from "@/shared/components/Form/Section";
import toast from "solid-toast";
import { FiTrash } from "solid-icons/fi";

Expand Down
2 changes: 1 addition & 1 deletion src/screens/Setup/components/LanguageBox.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ParentComponent } from "solid-js";
import type { ParentComponent } from "solid-js";

const LangaugeBox: ParentComponent<{ onClick: () => void; active?: boolean }> = (props) => {
return (
Expand Down
11 changes: 4 additions & 7 deletions src/screens/Setup/components/Progress.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import { Component, For } from "solid-js";
import { type Component, For } from "solid-js";

// https://macos-tailwind.netlify.app/?path=/docs/controls-progress-bar--docs
const ProgressDots: Component<{ count: number; active: number }> = (props) => {
return (
// add blur and
<div class="absolute w-full h-10 top-0 left-0 flex gap-4 items-center justify-center">
{/* <div class="bg-black/20 flex flex-row"> */}
<div class="absolute w-full h-10 top-0 left-0 flex gap-4 items-center justify-center" data-tauri-drag-region>
<For each={Array(props.count).fill(0)}>
{(_, index) => (
<div
class={`w-2 h-2 bg-primary opacity-80 transition rounded-full ${
props.active === index() ? "bg-red opacity-100 " : ""
class={`transition rounded-full bg-black dark:bg-white ${
props.active === index() ? "w-2.5 h-2.5 opacity-100 " : "opacity-30 w-2 h-2"
}`}
/>
)}
</For>
{/* </div> */}
</div>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/screens/Setup/components/Title.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ParentComponent } from "solid-js";
import type { ParentComponent } from "solid-js";

export const Title: ParentComponent<{ class?: string }> = (props) => {
return <h1 class={`text-2xl font-semibold text-primary ${props.class}`}>{props.children}</h1>;
Expand Down
Loading

0 comments on commit fc492e8

Please sign in to comment.