From 0c3652ed67e556c385163f91c12e97e1ff2ce744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20Sj=C3=B6din?= Date: Thu, 28 Nov 2024 10:01:54 +0100 Subject: [PATCH 01/12] feat(pages): add simple pages when logged in --- src-tauri/Cargo.lock | 2 +- .../dialogs/auth/sign-out-dialog.svelte | 2 +- src/lib/components/header.svelte | 8 ------ src/lib/components/navbar.svelte | 15 ----------- ...button.svelte => navigation-button.svelte} | 0 src/lib/components/sidebar.svelte | 25 +++++++++++++++++++ src/routes/(protected)/+layout.svelte | 13 ++-------- src/routes/(protected)/proxies/+page.svelte | 3 +++ src/routes/(protected)/signups/+page.svelte | 3 +++ src/routes/(protected)/tasks/+page.svelte | 3 +++ 10 files changed, 38 insertions(+), 36 deletions(-) delete mode 100644 src/lib/components/navbar.svelte rename src/lib/components/{navbar-button.svelte => navigation-button.svelte} (100%) create mode 100644 src/lib/components/sidebar.svelte create mode 100644 src/routes/(protected)/proxies/+page.svelte create mode 100644 src/routes/(protected)/signups/+page.svelte create mode 100644 src/routes/(protected)/tasks/+page.svelte diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 441776c..4808cca 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "Jaafar" -version = "0.0.3" +version = "0.0.4" dependencies = [ "cocoa 0.25.0", "objc", diff --git a/src/lib/components/dialogs/auth/sign-out-dialog.svelte b/src/lib/components/dialogs/auth/sign-out-dialog.svelte index 500dba3..1d24b4b 100644 --- a/src/lib/components/dialogs/auth/sign-out-dialog.svelte +++ b/src/lib/components/dialogs/auth/sign-out-dialog.svelte @@ -28,7 +28,7 @@ - Confirm Sign-Out + Confirm Sign Out Please confirm if you would like to sign out of your account. diff --git a/src/lib/components/header.svelte b/src/lib/components/header.svelte index 2c0ff58..e2d92f7 100644 --- a/src/lib/components/header.svelte +++ b/src/lib/components/header.svelte @@ -11,12 +11,4 @@ > - diff --git a/src/lib/components/navbar.svelte b/src/lib/components/navbar.svelte deleted file mode 100644 index 1ce9feb..0000000 --- a/src/lib/components/navbar.svelte +++ /dev/null @@ -1,15 +0,0 @@ - - - diff --git a/src/lib/components/navbar-button.svelte b/src/lib/components/navigation-button.svelte similarity index 100% rename from src/lib/components/navbar-button.svelte rename to src/lib/components/navigation-button.svelte diff --git a/src/lib/components/sidebar.svelte b/src/lib/components/sidebar.svelte new file mode 100644 index 0000000..597f481 --- /dev/null +++ b/src/lib/components/sidebar.svelte @@ -0,0 +1,25 @@ + + +
+
+
+
+ +
+ +
+
diff --git a/src/routes/(protected)/+layout.svelte b/src/routes/(protected)/+layout.svelte index 0b3ce55..f40c6e9 100644 --- a/src/routes/(protected)/+layout.svelte +++ b/src/routes/(protected)/+layout.svelte @@ -1,7 +1,6 @@ + + + + + + + Settings +
+ +
+
+ + + {#each pages as { name, page: Page }} + + + + {/each} + +
+
diff --git a/src/lib/components/settings/profile-page.svelte b/src/lib/components/settings/profile-page.svelte new file mode 100644 index 0000000..6a3ce75 --- /dev/null +++ b/src/lib/components/settings/profile-page.svelte @@ -0,0 +1,3 @@ +
+ profile +
diff --git a/src/lib/components/settings/sidebar.svelte b/src/lib/components/settings/sidebar.svelte new file mode 100644 index 0000000..78ecfdb --- /dev/null +++ b/src/lib/components/settings/sidebar.svelte @@ -0,0 +1,31 @@ + + +
+ {#each pages as page} + + {#snippet child({ props })} + + {/snippet} + + {/each} +
diff --git a/src/lib/components/sidebar.svelte b/src/lib/components/sidebar.svelte index 597f481..5b4f951 100644 --- a/src/lib/components/sidebar.svelte +++ b/src/lib/components/sidebar.svelte @@ -5,7 +5,8 @@ const navigations = [ { label: "Dashboard", icon: "fa-house", href: "/" }, { label: "Tasks", icon: "fa-table-layout", href: "/tasks" }, - { label: "Signups", icon: "fa-user-tie-hair", href: "/signups" }, + { label: "Signups", icon: "fa-pen", href: "/signups" }, + { label: "Accounts", icon: "fa-user-tie-hair", href: "/accounts" }, { label: "Proxies", icon: "fa-globe", href: "/proxies" }, ]; diff --git a/src/lib/components/ui/separator/index.ts b/src/lib/components/ui/separator/index.ts new file mode 100644 index 0000000..82442d2 --- /dev/null +++ b/src/lib/components/ui/separator/index.ts @@ -0,0 +1,7 @@ +import Root from "./separator.svelte"; + +export { + Root, + // + Root as Separator, +}; diff --git a/src/lib/components/ui/separator/separator.svelte b/src/lib/components/ui/separator/separator.svelte new file mode 100644 index 0000000..839494d --- /dev/null +++ b/src/lib/components/ui/separator/separator.svelte @@ -0,0 +1,22 @@ + + + diff --git a/src/lib/components/ui/tabs/index.ts b/src/lib/components/ui/tabs/index.ts new file mode 100644 index 0000000..f1ab372 --- /dev/null +++ b/src/lib/components/ui/tabs/index.ts @@ -0,0 +1,18 @@ +import { Tabs as TabsPrimitive } from "bits-ui"; +import Content from "./tabs-content.svelte"; +import List from "./tabs-list.svelte"; +import Trigger from "./tabs-trigger.svelte"; + +const Root = TabsPrimitive.Root; + +export { + Root, + Content, + List, + Trigger, + // + Root as Tabs, + Content as TabsContent, + List as TabsList, + Trigger as TabsTrigger, +}; diff --git a/src/lib/components/ui/tabs/tabs-content.svelte b/src/lib/components/ui/tabs/tabs-content.svelte new file mode 100644 index 0000000..f1c0515 --- /dev/null +++ b/src/lib/components/ui/tabs/tabs-content.svelte @@ -0,0 +1,19 @@ + + + diff --git a/src/lib/components/ui/tabs/tabs-list.svelte b/src/lib/components/ui/tabs/tabs-list.svelte new file mode 100644 index 0000000..f03e5fc --- /dev/null +++ b/src/lib/components/ui/tabs/tabs-list.svelte @@ -0,0 +1,19 @@ + + + diff --git a/src/lib/components/ui/tabs/tabs-trigger.svelte b/src/lib/components/ui/tabs/tabs-trigger.svelte new file mode 100644 index 0000000..f1f5825 --- /dev/null +++ b/src/lib/components/ui/tabs/tabs-trigger.svelte @@ -0,0 +1,19 @@ + + + diff --git a/src/lib/components/user-menu.svelte b/src/lib/components/user-menu.svelte index 4973855..54a0335 100644 --- a/src/lib/components/user-menu.svelte +++ b/src/lib/components/user-menu.svelte @@ -2,6 +2,7 @@ import { Button } from "$lib/components/ui/button"; import * as DropdownMenu from "$lib/components/ui/dropdown-menu"; import { signOutDialog } from "$lib/components/dialogs/auth/sign-out-dialog.svelte"; + import { settingsDialog } from "$lib/components/dialogs/settings-dialog.svelte"; @@ -27,12 +28,11 @@ - Profile - + Billing + settingsDialog.open = true}> Settings ⌘, - Billing signOutDialog.open = true}> Sign Out diff --git a/src/routes/(protected)/+layout.svelte b/src/routes/(protected)/+layout.svelte index f40c6e9..78a8756 100644 --- a/src/routes/(protected)/+layout.svelte +++ b/src/routes/(protected)/+layout.svelte @@ -2,11 +2,13 @@ import Header from "$lib/components/header.svelte"; import Sidebar from "$lib/components/sidebar.svelte"; import SignOutDialog from "$lib/components/dialogs/auth/sign-out-dialog.svelte"; + import SettingsDialog from "$lib/components/dialogs/settings-dialog.svelte"; let { children } = $props(); +
diff --git a/src/routes/(protected)/accounts/+page.svelte b/src/routes/(protected)/accounts/+page.svelte new file mode 100644 index 0000000..31e606f --- /dev/null +++ b/src/routes/(protected)/accounts/+page.svelte @@ -0,0 +1,3 @@ +
+

Accounts

+
From e4e61e4d7a6561b946226554432c7b2481398b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20Sj=C3=B6din?= Date: Thu, 28 Nov 2024 15:11:37 +0100 Subject: [PATCH 03/12] feat(settings): add correct tabs with icons --- src/lib/components/dialogs/settings-dialog.svelte | 12 ++++++++---- src/lib/components/settings/sidebar.svelte | 9 +++++++-- src/lib/components/user-menu.svelte | 1 - 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/lib/components/dialogs/settings-dialog.svelte b/src/lib/components/dialogs/settings-dialog.svelte index 01b441b..d6e51b1 100644 --- a/src/lib/components/dialogs/settings-dialog.svelte +++ b/src/lib/components/dialogs/settings-dialog.svelte @@ -13,14 +13,18 @@ interface Page { name: string; label: string; + icon: string; page: Component } const pages: Page[] = [ - { name: "profile", label: "Profile", page: ProfilePage }, - { name: "profile1", label: "Profile", page: Separator }, - { name: "profile2", label: "Profile", page: Separator }, - { name: "profile3", label: "Profile", page: Separator }, + { name: "account-settings", label: "Account Settings", icon: "fa-user", page: ProfilePage }, + { name: "notifications", label: "Notifications", icon: "fa-bell", page: Separator }, + { name: "privacy", label: "Privacy", icon: "fa-lock", page: Separator }, + { name: "preferences", label: "Preferences", icon: "fa-cog", page: Separator }, + { name: "integration", label: "Integration", icon: "fa-link", page: Separator }, + { name: "security", label: "Security", icon: "fa-shield", page: Separator }, + { name: "billing", label: "Billing", icon: "fa-money-bill", page: Separator }, ]; diff --git a/src/lib/components/settings/sidebar.svelte b/src/lib/components/settings/sidebar.svelte index 78ecfdb..20af3d7 100644 --- a/src/lib/components/settings/sidebar.svelte +++ b/src/lib/components/settings/sidebar.svelte @@ -2,10 +2,12 @@ import type { Component } from "svelte"; import { Button } from "$lib/components/ui/button"; import * as Tabs from "$lib/components/ui/tabs"; + import {cn} from "$lib/utils"; interface Page { name: string; label: string; + icon: string; page: Component } @@ -23,8 +25,11 @@ + class="justify-start data-[state=active]:bg-accent" + > + + {page.label} + {/snippet} {/each} diff --git a/src/lib/components/user-menu.svelte b/src/lib/components/user-menu.svelte index 54a0335..5305a88 100644 --- a/src/lib/components/user-menu.svelte +++ b/src/lib/components/user-menu.svelte @@ -28,7 +28,6 @@
- Billing settingsDialog.open = true}> Settings ⌘, From b6a51b76b70eb06264384cf4da94ed8b4b8c7764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20Sj=C3=B6din?= Date: Thu, 28 Nov 2024 15:18:19 +0100 Subject: [PATCH 04/12] feat(settings): add all pages for the tabs --- .../components/dialogs/settings-dialog.svelte | 22 ++++++++++++------- .../settings/account-settings-page.svelte | 3 +++ .../components/settings/billing-page.svelte | 3 +++ .../settings/integration-page.svelte | 3 +++ .../settings/notifications-page.svelte | 3 +++ .../settings/preferences-page.svelte | 3 +++ .../components/settings/privacy-page.svelte | 3 +++ .../components/settings/profile-page.svelte | 3 --- .../components/settings/security-page.svelte | 3 +++ 9 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 src/lib/components/settings/account-settings-page.svelte create mode 100644 src/lib/components/settings/billing-page.svelte create mode 100644 src/lib/components/settings/integration-page.svelte create mode 100644 src/lib/components/settings/notifications-page.svelte create mode 100644 src/lib/components/settings/preferences-page.svelte create mode 100644 src/lib/components/settings/privacy-page.svelte delete mode 100644 src/lib/components/settings/profile-page.svelte create mode 100644 src/lib/components/settings/security-page.svelte diff --git a/src/lib/components/dialogs/settings-dialog.svelte b/src/lib/components/dialogs/settings-dialog.svelte index d6e51b1..0f5fdb6 100644 --- a/src/lib/components/dialogs/settings-dialog.svelte +++ b/src/lib/components/dialogs/settings-dialog.svelte @@ -8,7 +8,13 @@ import * as Dialog from "$lib/components/ui/dialog"; import * as Tabs from "$lib/components/ui/tabs"; import Sidebar from "$lib/components/settings/sidebar.svelte"; - import ProfilePage from "$lib/components/settings/profile-page.svelte"; + import AccountSettingsPage from "$lib/components/settings/account-settings-page.svelte"; + import NotificationsPage from "$lib/components/settings/notifications-page.svelte"; + import PrivacyPage from "$lib/components/settings/privacy-page.svelte"; + import PreferencesPage from "$lib/components/settings/preferences-page.svelte"; + import IntegrationPage from "$lib/components/settings/integration-page.svelte"; + import SecurityPage from "$lib/components/settings/security-page.svelte"; + import BillingPage from "$lib/components/settings/billing-page.svelte"; interface Page { name: string; @@ -18,13 +24,13 @@ } const pages: Page[] = [ - { name: "account-settings", label: "Account Settings", icon: "fa-user", page: ProfilePage }, - { name: "notifications", label: "Notifications", icon: "fa-bell", page: Separator }, - { name: "privacy", label: "Privacy", icon: "fa-lock", page: Separator }, - { name: "preferences", label: "Preferences", icon: "fa-cog", page: Separator }, - { name: "integration", label: "Integration", icon: "fa-link", page: Separator }, - { name: "security", label: "Security", icon: "fa-shield", page: Separator }, - { name: "billing", label: "Billing", icon: "fa-money-bill", page: Separator }, + { name: "account-settings", label: "Account Settings", icon: "fa-user", page: AccountSettingsPage }, + { name: "notifications", label: "Notifications", icon: "fa-bell", page: NotificationsPage }, + { name: "privacy", label: "Privacy", icon: "fa-lock", page: PrivacyPage }, + { name: "preferences", label: "Preferences", icon: "fa-cog", page: PreferencesPage }, + { name: "integration", label: "Integration", icon: "fa-link", page: IntegrationPage }, + { name: "security", label: "Security", icon: "fa-shield", page: SecurityPage }, + { name: "billing", label: "Billing", icon: "fa-money-bill", page: BillingPage }, ]; diff --git a/src/lib/components/settings/account-settings-page.svelte b/src/lib/components/settings/account-settings-page.svelte new file mode 100644 index 0000000..b628e5c --- /dev/null +++ b/src/lib/components/settings/account-settings-page.svelte @@ -0,0 +1,3 @@ +
+ account settings +
diff --git a/src/lib/components/settings/billing-page.svelte b/src/lib/components/settings/billing-page.svelte new file mode 100644 index 0000000..1668710 --- /dev/null +++ b/src/lib/components/settings/billing-page.svelte @@ -0,0 +1,3 @@ +
+ billing +
diff --git a/src/lib/components/settings/integration-page.svelte b/src/lib/components/settings/integration-page.svelte new file mode 100644 index 0000000..f336e24 --- /dev/null +++ b/src/lib/components/settings/integration-page.svelte @@ -0,0 +1,3 @@ +
+ integration +
diff --git a/src/lib/components/settings/notifications-page.svelte b/src/lib/components/settings/notifications-page.svelte new file mode 100644 index 0000000..8f04956 --- /dev/null +++ b/src/lib/components/settings/notifications-page.svelte @@ -0,0 +1,3 @@ +
+ notifications +
diff --git a/src/lib/components/settings/preferences-page.svelte b/src/lib/components/settings/preferences-page.svelte new file mode 100644 index 0000000..9cacc31 --- /dev/null +++ b/src/lib/components/settings/preferences-page.svelte @@ -0,0 +1,3 @@ +
+ preferences +
diff --git a/src/lib/components/settings/privacy-page.svelte b/src/lib/components/settings/privacy-page.svelte new file mode 100644 index 0000000..5b7cc9d --- /dev/null +++ b/src/lib/components/settings/privacy-page.svelte @@ -0,0 +1,3 @@ +
+ privacy +
diff --git a/src/lib/components/settings/profile-page.svelte b/src/lib/components/settings/profile-page.svelte deleted file mode 100644 index 6a3ce75..0000000 --- a/src/lib/components/settings/profile-page.svelte +++ /dev/null @@ -1,3 +0,0 @@ -
- profile -
diff --git a/src/lib/components/settings/security-page.svelte b/src/lib/components/settings/security-page.svelte new file mode 100644 index 0000000..50592d9 --- /dev/null +++ b/src/lib/components/settings/security-page.svelte @@ -0,0 +1,3 @@ +
+ security +
From f2442d4b68de07c4adb7453f17aae545a8a024da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20Sj=C3=B6din?= Date: Thu, 28 Nov 2024 18:17:29 +0100 Subject: [PATCH 05/12] feat(settings): add scrollable pages --- .../components/dialogs/settings-dialog.svelte | 27 ++++--- .../settings/integration-page.svelte | 79 ++++++++++++++++++- src/lib/components/settings/sidebar.svelte | 2 +- src/lib/components/ui/scroll-area/index.ts | 10 +++ .../scroll-area/scroll-area-scrollbar.svelte | 29 +++++++ .../ui/scroll-area/scroll-area.svelte | 32 ++++++++ src/lib/components/ui/select/index.ts | 34 ++++++++ .../ui/select/select-content.svelte | 39 +++++++++ .../ui/select/select-group-heading.svelte | 16 ++++ .../components/ui/select/select-item.svelte | 37 +++++++++ .../select/select-scroll-down-button.svelte | 19 +++++ .../ui/select/select-scroll-up-button.svelte | 19 +++++ .../ui/select/select-separator.svelte | 13 +++ .../ui/select/select-trigger.svelte | 24 ++++++ 14 files changed, 366 insertions(+), 14 deletions(-) create mode 100644 src/lib/components/ui/scroll-area/index.ts create mode 100644 src/lib/components/ui/scroll-area/scroll-area-scrollbar.svelte create mode 100644 src/lib/components/ui/scroll-area/scroll-area.svelte create mode 100644 src/lib/components/ui/select/index.ts create mode 100644 src/lib/components/ui/select/select-content.svelte create mode 100644 src/lib/components/ui/select/select-group-heading.svelte create mode 100644 src/lib/components/ui/select/select-item.svelte create mode 100644 src/lib/components/ui/select/select-scroll-down-button.svelte create mode 100644 src/lib/components/ui/select/select-scroll-up-button.svelte create mode 100644 src/lib/components/ui/select/select-separator.svelte create mode 100644 src/lib/components/ui/select/select-trigger.svelte diff --git a/src/lib/components/dialogs/settings-dialog.svelte b/src/lib/components/dialogs/settings-dialog.svelte index 0f5fdb6..e2951b4 100644 --- a/src/lib/components/dialogs/settings-dialog.svelte +++ b/src/lib/components/dialogs/settings-dialog.svelte @@ -5,6 +5,7 @@ - - + + Settings
- +
- - - {#each pages as { name, page: Page }} - - - - {/each} - + + + +
+ {#each pages as { name, page: Page }} + + + + {/each} +
+
+
diff --git a/src/lib/components/settings/integration-page.svelte b/src/lib/components/settings/integration-page.svelte index f336e24..d2ee91e 100644 --- a/src/lib/components/settings/integration-page.svelte +++ b/src/lib/components/settings/integration-page.svelte @@ -1,3 +1,78 @@ -
- integration + + +
+
+ + (captchaValue = v)}> + {selectedCaptcha} + + {#each captchaSolvers as captchaSolver} + {captchaSolver.label} + {/each} + + +

Required for solving captchas on supported websites.

+
+ {#if !!captchaValue} +
+ + +
+ {/if} + +
+ + +

Configure the delay (in milliseconds) between automated actions.

+
+
+ + +

Sets the maximum number of entries/tasks to process per request.

+
+ +
+ + +
+
+ + +
+ +
+ + +

Configure a URL for handling webhook events.

+
diff --git a/src/lib/components/settings/sidebar.svelte b/src/lib/components/settings/sidebar.svelte index 20af3d7..7dae13b 100644 --- a/src/lib/components/settings/sidebar.svelte +++ b/src/lib/components/settings/sidebar.svelte @@ -18,7 +18,7 @@ let { pages }: Props = $props(); -
+
{#each pages as page} {#snippet child({ props })} diff --git a/src/lib/components/ui/scroll-area/index.ts b/src/lib/components/ui/scroll-area/index.ts new file mode 100644 index 0000000..e86a25b --- /dev/null +++ b/src/lib/components/ui/scroll-area/index.ts @@ -0,0 +1,10 @@ +import Scrollbar from "./scroll-area-scrollbar.svelte"; +import Root from "./scroll-area.svelte"; + +export { + Root, + Scrollbar, + //, + Root as ScrollArea, + Scrollbar as ScrollAreaScrollbar, +}; diff --git a/src/lib/components/ui/scroll-area/scroll-area-scrollbar.svelte b/src/lib/components/ui/scroll-area/scroll-area-scrollbar.svelte new file mode 100644 index 0000000..b436056 --- /dev/null +++ b/src/lib/components/ui/scroll-area/scroll-area-scrollbar.svelte @@ -0,0 +1,29 @@ + + + + {@render children?.()} + + diff --git a/src/lib/components/ui/scroll-area/scroll-area.svelte b/src/lib/components/ui/scroll-area/scroll-area.svelte new file mode 100644 index 0000000..9943f83 --- /dev/null +++ b/src/lib/components/ui/scroll-area/scroll-area.svelte @@ -0,0 +1,32 @@ + + + + + {@render children?.()} + + {#if orientation === "vertical" || orientation === "both"} + + {/if} + {#if orientation === "horizontal" || orientation === "both"} + + {/if} + + diff --git a/src/lib/components/ui/select/index.ts b/src/lib/components/ui/select/index.ts new file mode 100644 index 0000000..f31b8ae --- /dev/null +++ b/src/lib/components/ui/select/index.ts @@ -0,0 +1,34 @@ +import { Select as SelectPrimitive } from "bits-ui"; + +import GroupHeading from "./select-group-heading.svelte"; +import Item from "./select-item.svelte"; +import Content from "./select-content.svelte"; +import Trigger from "./select-trigger.svelte"; +import Separator from "./select-separator.svelte"; +import ScrollDownButton from "./select-scroll-down-button.svelte"; +import ScrollUpButton from "./select-scroll-up-button.svelte"; + +const Root = SelectPrimitive.Root; +const Group = SelectPrimitive.Group; + +export { + Root, + Group, + GroupHeading, + Item, + Content, + Trigger, + Separator, + ScrollDownButton, + ScrollUpButton, + // + Root as Select, + Group as SelectGroup, + GroupHeading as SelectGroupHeading, + Item as SelectItem, + Content as SelectContent, + Trigger as SelectTrigger, + Separator as SelectSeparator, + ScrollDownButton as SelectScrollDownButton, + ScrollUpButton as SelectScrollUpButton, +}; diff --git a/src/lib/components/ui/select/select-content.svelte b/src/lib/components/ui/select/select-content.svelte new file mode 100644 index 0000000..56916ef --- /dev/null +++ b/src/lib/components/ui/select/select-content.svelte @@ -0,0 +1,39 @@ + + + + + + + {@render children?.()} + + + + diff --git a/src/lib/components/ui/select/select-group-heading.svelte b/src/lib/components/ui/select/select-group-heading.svelte new file mode 100644 index 0000000..7984bef --- /dev/null +++ b/src/lib/components/ui/select/select-group-heading.svelte @@ -0,0 +1,16 @@ + + + diff --git a/src/lib/components/ui/select/select-item.svelte b/src/lib/components/ui/select/select-item.svelte new file mode 100644 index 0000000..c3a77db --- /dev/null +++ b/src/lib/components/ui/select/select-item.svelte @@ -0,0 +1,37 @@ + + + + {#snippet children({ selected, highlighted })} + + {#if selected} + + {/if} + + {#if childrenProp} + {@render childrenProp({ selected, highlighted })} + {:else} + {label || value} + {/if} + {/snippet} + diff --git a/src/lib/components/ui/select/select-scroll-down-button.svelte b/src/lib/components/ui/select/select-scroll-down-button.svelte new file mode 100644 index 0000000..b927d62 --- /dev/null +++ b/src/lib/components/ui/select/select-scroll-down-button.svelte @@ -0,0 +1,19 @@ + + + + + diff --git a/src/lib/components/ui/select/select-scroll-up-button.svelte b/src/lib/components/ui/select/select-scroll-up-button.svelte new file mode 100644 index 0000000..b8939ba --- /dev/null +++ b/src/lib/components/ui/select/select-scroll-up-button.svelte @@ -0,0 +1,19 @@ + + + + + diff --git a/src/lib/components/ui/select/select-separator.svelte b/src/lib/components/ui/select/select-separator.svelte new file mode 100644 index 0000000..38a3ab0 --- /dev/null +++ b/src/lib/components/ui/select/select-separator.svelte @@ -0,0 +1,13 @@ + + + diff --git a/src/lib/components/ui/select/select-trigger.svelte b/src/lib/components/ui/select/select-trigger.svelte new file mode 100644 index 0000000..f917f13 --- /dev/null +++ b/src/lib/components/ui/select/select-trigger.svelte @@ -0,0 +1,24 @@ + + +span]:line-clamp-1", + className + )} + {...restProps} +> + {@render children?.()} + + From 4bc1e7424eecdef50a48826060eba76cca88bf0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20Sj=C3=B6din?= Date: Thu, 28 Nov 2024 18:49:23 +0100 Subject: [PATCH 06/12] feat(hotkeys): add hotkeys to open settings dialog --- .../components/dialogs/settings-dialog.svelte | 6 +++- src/lib/services/hotkeys-service.ts | 31 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/lib/services/hotkeys-service.ts diff --git a/src/lib/components/dialogs/settings-dialog.svelte b/src/lib/components/dialogs/settings-dialog.svelte index e2951b4..3db1f3d 100644 --- a/src/lib/components/dialogs/settings-dialog.svelte +++ b/src/lib/components/dialogs/settings-dialog.svelte @@ -3,7 +3,8 @@ diff --git a/src/lib/services/hotkeys-service.ts b/src/lib/services/hotkeys-service.ts new file mode 100644 index 0000000..85143a2 --- /dev/null +++ b/src/lib/services/hotkeys-service.ts @@ -0,0 +1,31 @@ +/** + * + * + * Author: Elias Sjödin + * Created: 2024-11-28 + */ + +type Callback = (event: KeyboardEvent) => void; +let hotkeys: { [key: string]: Callback } = {}; + +export const addHotkey = (key: string, callback: Callback) => { + hotkeys = { ...hotkeys, [key]: callback }; +} + +export const removeHotkey = (key: string) => { + delete hotkeys[key]; +} + +const handleKeyDown = (event: KeyboardEvent) => { + const key = event.key.toLowerCase(); + const meta = event.metaKey ? "meta+" : ""; + const shortcut = `${meta}${key}`; + if (hotkeys[shortcut]) hotkeys[shortcut](event); +} + +const init = () => { + window.addEventListener("keydown", handleKeyDown); + return () => window.removeEventListener("keydown", handleKeyDown); +} + +export const cleanup = init(); From 09aa24f495c343f75d4cc87e495f7151c1442bb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20Sj=C3=B6din?= Date: Thu, 28 Nov 2024 23:03:05 +0100 Subject: [PATCH 07/12] feat(settings): add saving/loading functionality --- package-lock.json | 10 +++ package.json | 1 + src-tauri/Cargo.lock | 1 + src-tauri/Cargo.toml | 1 + src-tauri/capabilities/default.json | 7 +- src-tauri/src/lib.rs | 1 + src-tauri/tauri.conf.json | 2 +- .../components/dialogs/settings-dialog.svelte | 2 +- src/lib/services/files-service.ts | 68 +++++++++++++++++++ src/lib/services/settings-service.svelte.ts | 25 +++++++ src/lib/stores/settings-store.svelte.ts | 18 +++++ src/lib/utils.ts | 16 +++++ src/routes/+layout.svelte | 2 + 13 files changed, 150 insertions(+), 4 deletions(-) create mode 100644 src/lib/services/files-service.ts create mode 100644 src/lib/services/settings-service.svelte.ts create mode 100644 src/lib/stores/settings-store.svelte.ts diff --git a/package-lock.json b/package-lock.json index 23136ed..035cd05 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "@ilittlebig/easy-auth": "^0.0.9", "@tauri-apps/api": "^2", "@tauri-apps/plugin-dialog": "^2.0.1", + "@tauri-apps/plugin-fs": "^2.0.2", "@tauri-apps/plugin-process": "^2.0.0", "@tauri-apps/plugin-shell": "^2", "@tauri-apps/plugin-updater": "^2.0.0", @@ -2563,6 +2564,15 @@ "@tauri-apps/api": "^2.0.0" } }, + "node_modules/@tauri-apps/plugin-fs": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@tauri-apps/plugin-fs/-/plugin-fs-2.0.2.tgz", + "integrity": "sha512-4YZaX2j7ta81M5/DL8aN10kTnpUkEpkPo1FTYPT8Dd0ImHe3azM8i8MrtjrDGoyBYLPO3zFv7df/mSCYF8oA0Q==", + "license": "MIT OR Apache-2.0", + "dependencies": { + "@tauri-apps/api": "^2.0.0" + } + }, "node_modules/@tauri-apps/plugin-process": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@tauri-apps/plugin-process/-/plugin-process-2.0.0.tgz", diff --git a/package.json b/package.json index 26c045c..e620adb 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "@ilittlebig/easy-auth": "^0.0.9", "@tauri-apps/api": "^2", "@tauri-apps/plugin-dialog": "^2.0.1", + "@tauri-apps/plugin-fs": "^2.0.2", "@tauri-apps/plugin-process": "^2.0.0", "@tauri-apps/plugin-shell": "^2", "@tauri-apps/plugin-updater": "^2.0.0", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 4808cca..d6696c6 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -14,6 +14,7 @@ dependencies = [ "tauri", "tauri-build", "tauri-plugin-dialog", + "tauri-plugin-fs", "tauri-plugin-process", "tauri-plugin-shell", "tauri-plugin-updater", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 71c53db..1ac9d8f 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -20,6 +20,7 @@ serde_json = "1" rand = "0.8.5" tauri-plugin-dialog = "2" tauri-plugin-process = "2" +tauri-plugin-fs = "2" [target.'cfg(target_os = "macos")'.dependencies] cocoa = "0.25.0" diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 4c42458..5af2c15 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -11,6 +11,9 @@ "core:window:default", "core:window:allow-start-dragging", "dialog:default", - "process:default" + "process:default", + "fs:default", + "fs:allow-appdata-write", + "fs:allow-appdata-read" ] -} \ No newline at end of file +} diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 071c7bf..7c76326 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -12,6 +12,7 @@ use plugins::tauri_traffic_light_positioner_plugin; #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { tauri::Builder::default() + .plugin(tauri_plugin_fs::init()) .plugin(tauri_plugin_process::init()) .plugin(tauri_plugin_dialog::init()) .plugin(tauri_plugin_updater::Builder::new().build()) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 1f8901a..6e0ace8 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,6 +1,6 @@ { "$schema": "https://schema.tauri.app/config/2", - "identifier": "com.jaafar.app", + "identifier": "com.jaafar.application", "build": { "beforeDevCommand": "npm run dev", "devUrl": "http://localhost:1420", diff --git a/src/lib/components/dialogs/settings-dialog.svelte b/src/lib/components/dialogs/settings-dialog.svelte index 3db1f3d..1b6aa82 100644 --- a/src/lib/components/dialogs/settings-dialog.svelte +++ b/src/lib/components/dialogs/settings-dialog.svelte @@ -1,5 +1,5 @@ - + Settings @@ -48,16 +82,23 @@
- - -
- {#each pages as { name, page: Page }} - - - - {/each} -
-
+
+ + +
+ {#each pages as { name, page: Page }} + + + + {/each} +
+
+
diff --git a/src/lib/components/settings/integration-page.svelte b/src/lib/components/settings/integration-page.svelte index d2ee91e..860f6db 100644 --- a/src/lib/components/settings/integration-page.svelte +++ b/src/lib/components/settings/integration-page.svelte @@ -1,14 +1,22 @@
@@ -50,16 +60,30 @@
{/if} -
- - -

Configure the delay (in milliseconds) between automated actions.

-
-
- - -

Sets the maximum number of entries/tasks to process per request.

-
+ + + {#snippet children({ props })} +
+ Request Delay + +

Configure the delay (in milliseconds) between automated actions.

+
+ {/snippet} +
+ +
+ + + {#snippet children({ props })} +
+ Entry Limit + +

Sets the maximum number of entries/tasks to process per request.

+
+ {/snippet} +
+ +
diff --git a/src/lib/schemas/settings.ts b/src/lib/schemas/settings.ts new file mode 100644 index 0000000..a894674 --- /dev/null +++ b/src/lib/schemas/settings.ts @@ -0,0 +1,34 @@ +/** + * + * + * Author: Elias Sjödin + * Created: 2024-11-28 + */ + +import { z } from "zod"; + +const integrationSchema = z.object({ + captcha_solver: z.string().optional(), + captcha_solver_api_key: z.string().optional(), + request_delay: z.coerce + .number({ invalid_type_error: "Request delay must be a valid number" }) + .min(1000, { message: "Request delay must be at least 1000ms" }), + entry_limit: z.coerce + .number({ invalid_type_error: "Entry limit must be a valid number" }) + .min(1, { message: "Entry limit must be at least 1" }), + imap_email: z + .string() + .email({ message: "Invalid email format" }) + .optional(), + imap_password: z.string().optional(), + webhook: z + .string() + .url({ message: "Webhook must be a valid URL" }) + .optional(), +}); + +export const settingsSchema = z.object({ + integration: integrationSchema, +}); + +export type SettingsSchema = z.infer; diff --git a/src/lib/services/settings-service.svelte.ts b/src/lib/services/settings-service.svelte.ts index 3aa350d..aac2611 100644 --- a/src/lib/services/settings-service.svelte.ts +++ b/src/lib/services/settings-service.svelte.ts @@ -6,20 +6,35 @@ */ import { readFileJSON, writeFileJSON } from "$lib/services/files-service" -import { settingsStore } from "$lib/stores/settings-store.svelte"; +import { settingsStore, type Settings } from "$lib/stores/settings-store.svelte"; import { deepMerge } from "$lib/utils" +const updateSettingsStore = (settings: Settings) => { + for (const key in settings) { + if (typeof settings[key] === "object" && settings[key] !== null) { + settingsStore[key] = { + ...settingsStore[key], + ...settings[key], + }; + } else { + settingsStore[key] = settings[key]; + } + } +}; + export const loadSettings = async () => { const settings = await readFileJSON("settings.json"); if (settings) { - const mergedSettings = deepMerge({ ...settingsStore }, settings); - for (const key in mergedSettings) { - settingsStore[key] = mergedSettings[key]; - } + const mergedSettings = deepMerge(settingsStore, settings); + updateSettingsStore(mergedSettings); } await saveSettings(); } -export const saveSettings = async () => { - await writeFileJSON("settings.json", settingsStore); +export const saveSettings = async (settings?: Settings) => { + if (settings) { + const updatedSettings = deepMerge(settingsStore, settings); + updateSettingsStore(updatedSettings); + } + await writeFileJSON("settings.json", settings || settingsStore); } diff --git a/src/lib/stores/settings-store.svelte.ts b/src/lib/stores/settings-store.svelte.ts index a7ccf4f..bd8d66d 100644 --- a/src/lib/stores/settings-store.svelte.ts +++ b/src/lib/stores/settings-store.svelte.ts @@ -5,7 +5,9 @@ * Created: 2024-11-28 */ -export let settingsStore: { [key: string]: Record } = $state({ +export type Settings = { [key: string]: Record }; + +export let settingsStore: Settings = $state({ integration: { captcha_solver: undefined, captcha_solver_api_key: undefined, From 19613841be422cce4d26f9e1c39f14f733b25ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20Sj=C3=B6din?= Date: Fri, 29 Nov 2024 09:44:07 +0100 Subject: [PATCH 09/12] feat(settings): working validation --- .../components/dialogs/settings-dialog.svelte | 65 +++++++++++++++---- .../settings/integration-page.svelte | 44 ++++++++++--- src/lib/schemas/settings.ts | 34 ++++++++++ src/lib/services/settings-service.svelte.ts | 29 +++++++-- src/lib/stores/settings-store.svelte.ts | 4 +- 5 files changed, 146 insertions(+), 30 deletions(-) create mode 100644 src/lib/schemas/settings.ts diff --git a/src/lib/components/dialogs/settings-dialog.svelte b/src/lib/components/dialogs/settings-dialog.svelte index 1b6aa82..4d1fdba 100644 --- a/src/lib/components/dialogs/settings-dialog.svelte +++ b/src/lib/components/dialogs/settings-dialog.svelte @@ -4,7 +4,12 @@ - + Settings @@ -48,16 +82,23 @@
- - -
- {#each pages as { name, page: Page }} - - - - {/each} -
-
+
+ + +
+ {#each pages as { name, page: Page }} + + + + {/each} +
+
+
diff --git a/src/lib/components/settings/integration-page.svelte b/src/lib/components/settings/integration-page.svelte index d2ee91e..860f6db 100644 --- a/src/lib/components/settings/integration-page.svelte +++ b/src/lib/components/settings/integration-page.svelte @@ -1,14 +1,22 @@
@@ -50,16 +60,30 @@
{/if} -
- - -

Configure the delay (in milliseconds) between automated actions.

-
-
- - -

Sets the maximum number of entries/tasks to process per request.

-
+ + + {#snippet children({ props })} +
+ Request Delay + +

Configure the delay (in milliseconds) between automated actions.

+
+ {/snippet} +
+ +
+ + + {#snippet children({ props })} +
+ Entry Limit + +

Sets the maximum number of entries/tasks to process per request.

+
+ {/snippet} +
+ +
diff --git a/src/lib/schemas/settings.ts b/src/lib/schemas/settings.ts new file mode 100644 index 0000000..a894674 --- /dev/null +++ b/src/lib/schemas/settings.ts @@ -0,0 +1,34 @@ +/** + * + * + * Author: Elias Sjödin + * Created: 2024-11-28 + */ + +import { z } from "zod"; + +const integrationSchema = z.object({ + captcha_solver: z.string().optional(), + captcha_solver_api_key: z.string().optional(), + request_delay: z.coerce + .number({ invalid_type_error: "Request delay must be a valid number" }) + .min(1000, { message: "Request delay must be at least 1000ms" }), + entry_limit: z.coerce + .number({ invalid_type_error: "Entry limit must be a valid number" }) + .min(1, { message: "Entry limit must be at least 1" }), + imap_email: z + .string() + .email({ message: "Invalid email format" }) + .optional(), + imap_password: z.string().optional(), + webhook: z + .string() + .url({ message: "Webhook must be a valid URL" }) + .optional(), +}); + +export const settingsSchema = z.object({ + integration: integrationSchema, +}); + +export type SettingsSchema = z.infer; diff --git a/src/lib/services/settings-service.svelte.ts b/src/lib/services/settings-service.svelte.ts index 3aa350d..aac2611 100644 --- a/src/lib/services/settings-service.svelte.ts +++ b/src/lib/services/settings-service.svelte.ts @@ -6,20 +6,35 @@ */ import { readFileJSON, writeFileJSON } from "$lib/services/files-service" -import { settingsStore } from "$lib/stores/settings-store.svelte"; +import { settingsStore, type Settings } from "$lib/stores/settings-store.svelte"; import { deepMerge } from "$lib/utils" +const updateSettingsStore = (settings: Settings) => { + for (const key in settings) { + if (typeof settings[key] === "object" && settings[key] !== null) { + settingsStore[key] = { + ...settingsStore[key], + ...settings[key], + }; + } else { + settingsStore[key] = settings[key]; + } + } +}; + export const loadSettings = async () => { const settings = await readFileJSON("settings.json"); if (settings) { - const mergedSettings = deepMerge({ ...settingsStore }, settings); - for (const key in mergedSettings) { - settingsStore[key] = mergedSettings[key]; - } + const mergedSettings = deepMerge(settingsStore, settings); + updateSettingsStore(mergedSettings); } await saveSettings(); } -export const saveSettings = async () => { - await writeFileJSON("settings.json", settingsStore); +export const saveSettings = async (settings?: Settings) => { + if (settings) { + const updatedSettings = deepMerge(settingsStore, settings); + updateSettingsStore(updatedSettings); + } + await writeFileJSON("settings.json", settings || settingsStore); } diff --git a/src/lib/stores/settings-store.svelte.ts b/src/lib/stores/settings-store.svelte.ts index a7ccf4f..bd8d66d 100644 --- a/src/lib/stores/settings-store.svelte.ts +++ b/src/lib/stores/settings-store.svelte.ts @@ -5,7 +5,9 @@ * Created: 2024-11-28 */ -export let settingsStore: { [key: string]: Record } = $state({ +export type Settings = { [key: string]: Record }; + +export let settingsStore: Settings = $state({ integration: { captcha_solver: undefined, captcha_solver_api_key: undefined, From fd879520b6f33e81e63611eb4ef213bdd618af83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20Sj=C3=B6din?= Date: Fri, 29 Nov 2024 11:08:06 +0100 Subject: [PATCH 10/12] feat(settings): correctly loads data from settings.json file --- src/lib/components/dialogs/settings-dialog.svelte | 12 +++++++++--- src/lib/services/settings-service.svelte.ts | 3 ++- src/lib/stores/settings-store.svelte.ts | 2 ++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/lib/components/dialogs/settings-dialog.svelte b/src/lib/components/dialogs/settings-dialog.svelte index 4d1fdba..ab05781 100644 --- a/src/lib/components/dialogs/settings-dialog.svelte +++ b/src/lib/components/dialogs/settings-dialog.svelte @@ -8,8 +8,8 @@ import { zodClient } from "sveltekit-superforms/adapters"; import { addHotkey, removeHotkey } from "$lib/services/hotkeys-service"; import { settingsSchema } from "$lib/schemas/settings"; - import { settingsStore } from "$lib/stores/settings-store.svelte"; - import { saveSettings } from "$lib/services/settings-service.svelte"; + import { settingsLoaded, settingsStore } from "$lib/stores/settings-store.svelte"; + import { loadSettings, saveSettings } from "$lib/services/settings-service.svelte"; import { Separator } from "$lib/components/ui/separator"; import { ScrollArea } from "$lib/components/ui/scroll-area"; import * as Dialog from "$lib/components/ui/dialog"; @@ -69,7 +69,13 @@ await saveSettings($formData); } - onMount(() => addHotkey("meta+,", () => settingsDialog.open = true)); + onMount(async () => { + addHotkey("meta+,", () => settingsDialog.open = true); + if (settingsLoaded.value) return; + await loadSettings(); + formData.set(settingsStore); + }); + onDestroy(() => removeHotkey("meta+,")); diff --git a/src/lib/services/settings-service.svelte.ts b/src/lib/services/settings-service.svelte.ts index aac2611..64b8c87 100644 --- a/src/lib/services/settings-service.svelte.ts +++ b/src/lib/services/settings-service.svelte.ts @@ -6,7 +6,7 @@ */ import { readFileJSON, writeFileJSON } from "$lib/services/files-service" -import { settingsStore, type Settings } from "$lib/stores/settings-store.svelte"; +import { settingsStore, settingsLoaded, type Settings } from "$lib/stores/settings-store.svelte"; import { deepMerge } from "$lib/utils" const updateSettingsStore = (settings: Settings) => { @@ -29,6 +29,7 @@ export const loadSettings = async () => { updateSettingsStore(mergedSettings); } await saveSettings(); + settingsLoaded.value = true; } export const saveSettings = async (settings?: Settings) => { diff --git a/src/lib/stores/settings-store.svelte.ts b/src/lib/stores/settings-store.svelte.ts index bd8d66d..433e8bf 100644 --- a/src/lib/stores/settings-store.svelte.ts +++ b/src/lib/stores/settings-store.svelte.ts @@ -18,3 +18,5 @@ export let settingsStore: Settings = $state({ webhook: undefined, }, }); + +export let settingsLoaded = $state({ value: false }); From 1f341ab31cd833b8ccee58ea46262cb81c2fa929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20Sj=C3=B6din?= Date: Fri, 29 Nov 2024 12:26:04 +0100 Subject: [PATCH 11/12] feat(settings): add all settings for the integration page, no real functionality --- .../settings/integration-page.svelte | 103 ++++++++++++------ src/lib/schemas/settings.ts | 27 +++-- 2 files changed, 83 insertions(+), 47 deletions(-) diff --git a/src/lib/components/settings/integration-page.svelte b/src/lib/components/settings/integration-page.svelte index 860f6db..2e0498d 100644 --- a/src/lib/components/settings/integration-page.svelte +++ b/src/lib/components/settings/integration-page.svelte @@ -30,34 +30,46 @@ { value: "captcha-solutions", label: "CaptchaSolutions" }, ]; - let captchaValue = $state(""); + let { form, formData }: Props = $props(); const selectedCaptcha = $derived( - captchaValue - ? captchaSolvers.find((captcha: SelectType) => captcha.value === captchaValue)?.label + $formData.integration.captcha_solver + ? captchaSolvers.find((captcha: SelectType) => captcha.value === $formData.integration.captcha_solver)?.label : "Select a captcha solver" ); - - let { form, formData }: Props = $props();
-
- - (captchaValue = v)}> - {selectedCaptcha} - - {#each captchaSolvers as captchaSolver} - {captchaSolver.label} - {/each} - - -

Required for solving captchas on supported websites.

-
- {#if !!captchaValue} -
- - -
+ + + {#snippet children({ props })} +
+ Captcha Solver + + {selectedCaptcha} + + {#each captchaSolvers as captchaSolver} + {captchaSolver.label} + {/each} + + +

Required for solving captchas on supported websites.

+
+ {/snippet} +
+ +
+ {#if !!$formData.integration.captcha_solver} + + + {#snippet children({ props })} +
+ Captcha API Key + +
+ {/snippet} +
+ +
{/if} @@ -85,18 +97,39 @@ -
- - -
-
- - -
+ + + {#snippet children({ props })} +
+ IMAP Email + +
+ {/snippet} +
+ +
+ + + {#snippet children({ props })} +
+ IMAP Password + +
+ {/snippet} +
+ +
-
- - -

Configure a URL for handling webhook events.

-
+ + + {#snippet children({ props })} +
+ Webhook + +

Configure a URL for handling webhook events.

+
+ {/snippet} +
+ +
diff --git a/src/lib/schemas/settings.ts b/src/lib/schemas/settings.ts index a894674..07d7704 100644 --- a/src/lib/schemas/settings.ts +++ b/src/lib/schemas/settings.ts @@ -7,25 +7,28 @@ import { z } from "zod"; +const optionalString = (schema: z.ZodString) => { + return z.preprocess(value => { + if (typeof value === "string" && value.trim() === "") { + return undefined; + } + return value; + }, schema.optional()); +} + const integrationSchema = z.object({ - captcha_solver: z.string().optional(), - captcha_solver_api_key: z.string().optional(), + captcha_solver: optionalString(z.string()), + captcha_solver_api_key: optionalString(z.string()), request_delay: z.coerce .number({ invalid_type_error: "Request delay must be a valid number" }) .min(1000, { message: "Request delay must be at least 1000ms" }), entry_limit: z.coerce .number({ invalid_type_error: "Entry limit must be a valid number" }) .min(1, { message: "Entry limit must be at least 1" }), - imap_email: z - .string() - .email({ message: "Invalid email format" }) - .optional(), - imap_password: z.string().optional(), - webhook: z - .string() - .url({ message: "Webhook must be a valid URL" }) - .optional(), -}); + imap_email: optionalString(z.string().email({ message: "Invalid email format" })), + imap_password: optionalString(z.string()), + webhook: optionalString(z.string().url({ message: "Webhook must be a valid URL" })), +}) export const settingsSchema = z.object({ integration: integrationSchema, From fdd17b15f7c6a871d5fe0a8e4bfa87b2bd26e1b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20Sj=C3=B6din?= Date: Fri, 29 Nov 2024 12:29:26 +0100 Subject: [PATCH 12/12] chore(minor): bump version number --- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index d6696c6..ac2f4b0 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "Jaafar" -version = "0.0.4" +version = "0.0.5" dependencies = [ "cocoa 0.25.0", "objc", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 1ac9d8f..7268d3d 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "Jaafar" -version = "0.0.4" +version = "0.0.5" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html