@rainlanguage/ui-components 0.0.1-alpha.102 → 0.0.1-alpha.104

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,6 +26,7 @@ import { useAccount } from "../../providers/wallet/useAccount";
26
26
  import {
27
27
  getOrderByHash
28
28
  } from "@rainlanguage/orderbook";
29
+ import { useToasts } from "../../providers/toasts/useToasts";
29
30
  export let handleQuoteDebugModal = void 0;
30
31
  export const handleDebugTradeModal = void 0;
31
32
  export let colorTheme;
@@ -42,6 +43,7 @@ let codeMirrorDisabled = true;
42
43
  let codeMirrorStyles = {};
43
44
  const queryClient = useQueryClient();
44
45
  const { matchesAccount } = useAccount();
46
+ const { errToast } = useToasts();
45
47
  $: orderDetailQuery = createQuery({
46
48
  queryKey: [orderHash, QKEY_ORDER + orderHash],
47
49
  queryFn: async () => {
@@ -57,6 +59,13 @@ const interval = setInterval(async () => {
57
59
  onDestroy(() => {
58
60
  clearInterval(interval);
59
61
  });
62
+ const handleRefresh = async () => {
63
+ try {
64
+ await invalidateTanstackQueries(queryClient, [orderHash]);
65
+ } catch {
66
+ errToast("Failed to refresh");
67
+ }
68
+ };
60
69
  $: subgraphName = $page.url.pathname.split("/")[2]?.split("-")[0];
61
70
  </script>
62
71
 
@@ -86,7 +95,7 @@ $: subgraphName = $page.url.pathname.split("/")[2]?.split("-")[0];
86
95
 
87
96
  <Refresh
88
97
  testId="top-refresh"
89
- on:click={() => invalidateTanstackQueries(queryClient, [orderHash])}
98
+ on:click={handleRefresh}
90
99
  spin={$orderDetailQuery.isLoading || $orderDetailQuery.isFetching}
91
100
  />
92
101
  </div>
@@ -1,4 +1,5 @@
1
- <script generics="T">import { invalidateTanstackQueries } from "../../queries/queryClient";
1
+ <script generics="T">import { useToasts } from "../../providers/toasts/useToasts";
2
+ import { invalidateTanstackQueries } from "../../queries/queryClient";
2
3
  import Refresh from "../icon/Refresh.svelte";
3
4
  import EditableSpan from "../EditableSpan.svelte";
4
5
  import { getOrderQuote } from "@rainlanguage/orderbook";
@@ -22,8 +23,13 @@ export let orderbookAddress;
22
23
  export let handleQuoteDebugModal = void 0;
23
24
  let enabled = true;
24
25
  const queryClient = useQueryClient();
26
+ const { errToast } = useToasts();
25
27
  const refreshQuotes = async () => {
26
- invalidateTanstackQueries(queryClient, [id, QKEY_ORDER_QUOTE + id]);
28
+ try {
29
+ await invalidateTanstackQueries(queryClient, [id, QKEY_ORDER_QUOTE + id]);
30
+ } catch {
31
+ errToast("Failed to refresh");
32
+ }
27
33
  };
28
34
  $: orderQuoteQuery = createQuery({
29
35
  queryKey: [id, QKEY_ORDER_QUOTE + id],
@@ -16,6 +16,7 @@ import { invalidateTanstackQueries } from "../../queries/queryClient";
16
16
  import { useAccount } from "../../providers/wallet/useAccount";
17
17
  import { Button } from "flowbite-svelte";
18
18
  import { ArrowDownToBracketOutline, ArrowUpFromBracketOutline } from "flowbite-svelte-icons";
19
+ import { useToasts } from "../../providers/toasts/useToasts";
19
20
  export let id;
20
21
  export let network;
21
22
  export let lightweightChartsTheme = void 0;
@@ -27,6 +28,7 @@ export let onWithdraw;
27
28
  const subgraphUrl = $settings?.subgraphs?.[network] || "";
28
29
  const queryClient = useQueryClient();
29
30
  const { matchesAccount } = useAccount();
31
+ const { errToast } = useToasts();
30
32
  $: vaultDetailQuery = createQuery({
31
33
  queryKey: [id, QKEY_VAULT + id],
32
34
  queryFn: async () => {
@@ -46,6 +48,13 @@ const interval = setInterval(async () => {
46
48
  onDestroy(() => {
47
49
  clearInterval(interval);
48
50
  });
51
+ const handleRefresh = async () => {
52
+ try {
53
+ await invalidateTanstackQueries(queryClient, [id, QKEY_VAULT + id]);
54
+ } catch {
55
+ errToast("Failed to refresh");
56
+ }
57
+ };
49
58
  </script>
50
59
 
51
60
  <TanstackPageContentDetail query={vaultDetailQuery} emptyMessage="Vault not found">
@@ -80,7 +89,7 @@ onDestroy(() => {
80
89
 
81
90
  <Refresh
82
91
  testId="top-refresh"
83
- on:click={() => invalidateTanstackQueries(queryClient, [id, QKEY_VAULT + id])}
92
+ on:click={handleRefresh}
84
93
  spin={$vaultDetailQuery.isLoading || $vaultDetailQuery.isFetching}
85
94
  />
86
95
  </div>
@@ -12,4 +12,5 @@ export declare function useToasts(): {
12
12
  toasts: import("svelte/store").Writable<ToastProps[]>;
13
13
  addToast: (toast: ToastProps) => void;
14
14
  removeToast: (index: number) => void;
15
+ errToast: (message: string) => void;
15
16
  };
@@ -40,9 +40,22 @@ export function useToasts() {
40
40
  return updatedToasts;
41
41
  });
42
42
  };
43
+ /**
44
+ * Adds a standardized error toast notification
45
+ *
46
+ * @param message - The error message to display
47
+ */
48
+ const errToast = (message) => {
49
+ addToast({
50
+ message,
51
+ type: 'error',
52
+ color: 'red'
53
+ });
54
+ };
43
55
  return {
44
56
  toasts,
45
57
  addToast,
46
- removeToast
58
+ removeToast,
59
+ errToast
47
60
  };
48
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rainlanguage/ui-components",
3
- "version": "0.0.1-alpha.102",
3
+ "version": "0.0.1-alpha.104",
4
4
  "description": "A component library for building Svelte applications to be used with Raindex.",
5
5
  "license": "LicenseRef-DCL-1.0",
6
6
  "author": "Rain Open Source Software Ltd",
@@ -53,7 +53,7 @@
53
53
  "@fontsource/dm-sans": "5.1.0",
54
54
  "@imask/svelte": "7.6.1",
55
55
  "@observablehq/plot": "0.6.16",
56
- "@rainlanguage/orderbook": "0.0.1-alpha.102",
56
+ "@rainlanguage/orderbook": "0.0.1-alpha.104",
57
57
  "@reown/appkit": "1.6.4",
58
58
  "@reown/appkit-adapter-wagmi": "1.6.4",
59
59
  "@sentry/sveltekit": "7.120.0",