Skip to content

Commit

Permalink
feat: ✨ workflow atc
Browse files Browse the repository at this point in the history
  • Loading branch information
dfrnoch committed Apr 8, 2024
1 parent 6d040fd commit 16d0314
Show file tree
Hide file tree
Showing 13 changed files with 269 additions and 50 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: 'Publish'
on: workflow_dispatch

env:
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: short
RUSTFLAGS: '-W unreachable-pub -W rust-2021-compatibility'

jobs:
publish-tauri:
strategy:
fail-fast: false
matrix:
settings:
- platform: 'macos-latest'
args: '--target universal-apple-darwin'
- platform: 'ubuntu-22.04'
args: ''
- platform: 'windows-latest'
args: '--target x86_64-pc-windows-msvc'
runs-on: ${{ matrix.settings.platform }}
steps:
- uses: actions/checkout@v3
- name: setup node
uses: actions/setup-node@v3
with:
node-version: 20
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-darwin
- name: install dependencies (ubuntu only)
if: matrix.settings.platform == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y build-essential libssl-dev javascriptcoregtk-4.1 libayatana-appindicator3-dev libsoup-3.0-dev libgtk-3-dev libwebkit2gtk-4.1-dev webkit2gtk-4.1 librsvg2-dev patchelf
- name: Install bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Setup node and cache for package data
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
cache: 'bun'
cache-dependency-path: bun.lockb
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- run: bun install
- uses: tauri-apps/tauri-action@dev
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: v__VERSION__
releaseName: 'v__VERSION__'
releaseBody: 'See the assets to download this version and install.'
releaseDraft: true
prerelease: false
args: ${{ matrix.settings.args }}
includeDebug: false
12 changes: 12 additions & 0 deletions src/bindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,21 @@ export type GetInvoiceData = {
status: string;
};

export type GetClientData = {
id: number;
name: string;
email: string;
phoneNumber: string;
};

export function getInvoices(indicies: Indicies) {
return invoke<GetInvoiceData[]>("get_invoices", { companyId: StateService().state.companyId, indicies });
}

export function getClients(indicies: Indicies) {
return invoke<GetClientData[]>("get_clients", { companyId: StateService().state.companyId, indicies });
}

export function getCompany(id: number | null) {
return invoke<Company | null>("get_company", { id });
}
Expand All @@ -31,6 +42,7 @@ export function createCompany(data: CreateCompanyData) {
export function migrateAndPopulate() {
return invoke("migrate_and_populate");
}

export async function getCompanies(exclude?: number) {
return await invoke<Company[]>("get_companies", { exclude });
}
Expand Down
4 changes: 1 addition & 3 deletions src/screens/Dashboard/components/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import type { ParentComponent } from "solid-js";

const Box: ParentComponent<{ class: string }> = (props) => {
return (
<div class={`rounded-lg border p-3 bg-[#E6E6E6] border-default dark:bg-[#282828] h-full w-full ${props.class}`}>
{props.children}
</div>
<div class={`rounded-lg border p-3 bg-element border-default h-full w-full ${props.class}`}>{props.children}</div>
);
};

Expand Down
95 changes: 95 additions & 0 deletions src/screens/Dashboard/components/Form/Dropdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import type { Component, JSX } from "solid-js";
import { For, createSignal } from "solid-js";
import { DisclosureStateChild, Listbox, ListboxButton, ListboxOption, ListboxOptions, Transition } from "terracotta";
import { TbSelector } from "solid-icons/tb";
import { FiCheck } from "solid-icons/fi";

interface DropdownItem {
id: number;
name: string;
}

interface DropdownProps {
data: DropdownItem[];
onSelect: (value: DropdownItem) => void;
}

const Dropdown: Component<DropdownProps> = (props) => {
const [selected, setSelected] = createSignal(props.data[0]);

const handleSelect = (value: DropdownItem | undefined) => {
if (!value) return;
setSelected(value);
props.onSelect(value);
};

return (
<div class="w-full">
<Listbox defaultOpen={false} value={selected()} onSelectChange={handleSelect}>
<div class="relative mt-1">
<ListboxButton class="relative w-full py-2 pl-3 pr-10 text-left bg-element border-default border-1 rounded-lg cursor-default focus:outline-none sm:text-sm">
<span class="block truncate">{selected().name}</span>
<span class="absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none">
<TbSelector class="w-5 h-5 text-primary" aria-hidden="true" />
</span>
</ListboxButton>
<DisclosureStateChild>
{({ isOpen }): JSX.Element => (
<Transition
show={isOpen()}
enter="transition ease-in duration-100"
enterFrom="opacity-0"
enterTo="opacity-100"
leave="transition ease-out duration-100"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<ListboxOptions
unmount={false}
class="absolute w-full py-1 mt-1 overflow-auto text-base bg-element border-default border-1 rounded-md shadow-lg max-h-60 focus:outline-none sm:text-sm"
>
<For each={props.data}>
{(item): JSX.Element => (
<ListboxOption class="focus:outline-none group" value={item}>
{({ isActive, isSelected }): JSX.Element => (
<div
classList={{
"bg-default": isActive(),
"cursor-default select-none relative py-2 pl-10 pr-4": true,
}}
>
<span
classList={{
"font-medium": isSelected(),
"font-normal": !isSelected(),
"block truncate": true,
}}
>
{item.name}
</span>
{isSelected() ? (
<span
classList={{
"text-primary": true,
"absolute inset-y-0 left-0 flex items-center pl-3": true,
}}
>
<FiCheck class="w-5 h-5" />
</span>
) : null}
</div>
)}
</ListboxOption>
)}
</For>
</ListboxOptions>
</Transition>
)}
</DisclosureStateChild>
</div>
</Listbox>
</div>
);
};

export default Dropdown;
40 changes: 40 additions & 0 deletions src/screens/Dashboard/components/Form/Input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { Component } from "solid-js";

type TextInputProps = {
type: "text" | "date";
onChange: (value: string) => void;
label: string;
defaultValue?: string;
};

type NumberInputProps = {
type: "number";
onChange: (value: number) => void;
label: string;
defaultValue?: number;
};

type InputProps = TextInputProps | NumberInputProps;

const Input: Component<InputProps> = (props) => {
const handleInput = (e: Event) => {
const value = (e.target as HTMLInputElement).value;
if (props.type === "number") {
props.onChange(Number(value) as never);
} else {
props.onChange(value as never);
}
};

return (
<input
type={props.type}
class="w-full px-2 py-1 border border-default rounded-lg bg-element border-default"
onInput={handleInput}
placeholder={props.label}
value={props.defaultValue}
/>
);
};

export default Input;
7 changes: 7 additions & 0 deletions src/screens/Dashboard/components/Form/Table.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { Component } from "solid-js";

const Table: Component<{}> = (props) => {
return <div></div>;
};

export default Table;
2 changes: 1 addition & 1 deletion src/screens/Dashboard/components/StatBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const StatBox: Component<{
};

return (
<div class="p-2.5 rounded-lg border bg-[#E6E6E6] border-default dark-(bg-[#282828]) h-25 w-full relative overflow-hidden">
<div class="p-2.5 rounded-lg border bg-element border-default h-25 w-full relative overflow-hidden">
<div class="absolute top-0 right-0 w-14 h-8 rounded-lg bg-green-500/30 blur-md" />
<div class="flex flex-col justify-between items-stretch w-full h-full">
<div class="flex flex-row justify-between items-start">
Expand Down
12 changes: 11 additions & 1 deletion src/screens/Dashboard/pages/Sales/Clients/ClientDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Container from "@/screens/Dashboard/components/Container";
import PageHeader from "@/screens/Dashboard/components/PageHeader";
import HeaderButton from "@/screens/Dashboard/components/PageHeader/HeaderButton";
import StatBox from "@/screens/Dashboard/components/StatBox";
import Table from "@/screens/Dashboard/components/Table";
import { useNavigate, useParams } from "@solidjs/router";
import type { Component } from "solid-js";

Expand All @@ -28,7 +29,16 @@ const ClientDetail: Component = () => {
<StatBox title={t("overview.stats.tax")} value={120} />
</div>
<div class="grid grid-cols-6 h-full mt-4 gap-4">
<div class="bg-red col-span-4"></div>
<div class="bg-red col-span-4">
<Table
columns={[
{ field: "id", header: "ID" },
{ field: "name", header: "Name" },
]}
totalItems={10}
loadPage={() => {}}
/>
</div>
<Box class="col-span-2">ddd</Box>
</div>
</Container>
Expand Down
19 changes: 16 additions & 3 deletions src/screens/Dashboard/pages/Sales/Clients/ManageClient.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
import { useI18n } from "@/i18n";
import Container from "@/screens/Dashboard/components/Container";
import PageHeader from "@/screens/Dashboard/components/PageHeader";
import HeaderButton from "@/screens/Dashboard/components/PageHeader/HeaderButton";
import { useParams } from "@solidjs/router";
import type { Component } from "solid-js";

const ManageClient: Component = () => {
const params = useParams<{ readonly id?: string }>();
const [t] = useI18n();

return (
<div>
<h1 class="text-4xl font-bold">Create Client</h1>
</div>
<Container>
<PageHeader
title={[t("sidebar.section.sales"), t("sidebar.button.clients"), params.id ? params.id : t("pageHeaader.new")]}
actionElements={[
<HeaderButton onClick={() => {}} buttonType="primary">
Save
</HeaderButton>,
]}
/>
</Container>
);
};

Expand Down
26 changes: 7 additions & 19 deletions src/screens/Dashboard/pages/Sales/Clients/index.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,37 @@
import { type Template, getTemplates } from "@/bindings";
import { getClients } from "@/bindings";
import { useI18n } from "@/i18n";
import Table, { type Indicies } from "@/screens/Dashboard/components/Table";
import { FiEdit, FiPlus, FiTrash } from "solid-icons/fi";
import { FiEdit, FiPlus } from "solid-icons/fi";
import type { Component } from "solid-js";
import { useNavigate } from "@solidjs/router";
import PageHeader from "@/screens/Dashboard/components/PageHeader";
import HeaderButton from "@/screens/Dashboard/components/PageHeader/HeaderButton";
import Container from "@/screens/Dashboard/components/Container";
import { Button } from "@/shared/components/Button";

const Clients: Component = () => {
const [t] = useI18n();
const navigate = useNavigate();

const loadPage = async (indices: Indicies) => {
const data = await getTemplates(indices);
console.log(data);
return data;
return await getClients(indices);
};

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

const handleDelete = (item: Template) => {
console.log("Delete:", item);
// Handle delete action
};

const rowActions = [
{
label: "Edit",
onClick: handleEdit,
icon: FiEdit,
},
{
label: "Delete",
onClick: handleDelete,
icon: FiTrash,
},
];

return (
<Container>
<PageHeader
title={[t("sidebar.section.other"), t("sidebar.button.templates")]}
title={[t("sidebar.section.sales"), t("sidebar.button.clients")]}
actionElements={[
<HeaderButton onClick={() => navigate("new")} buttonType="primary">
<FiPlus class="stroke-2" />
Expand All @@ -55,7 +42,8 @@ const Clients: Component = () => {
columns={[
{ field: "id", header: "ID" },
{ field: "name", header: "Name" },
{ field: "templateType", header: "Type" },
{ field: "email", header: "Email" },
{ field: "phoneNumber", header: "Phone" },
]}
totalItems={10}
loadPage={loadPage}
Expand Down
Loading

0 comments on commit 16d0314

Please sign in to comment.