From dbe7aee9151ee04147edbce7d34e1275edfc1254 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Thu, 5 Sep 2024 18:17:19 +0800 Subject: [PATCH] feat: display power purchase and tx --- src/hono.ts | 19 ++--- .../src/modules/settings/tabs/invitations.tsx | 82 +++++++++---------- .../tabs/wallet/transaction-section/index.tsx | 9 +- 3 files changed, 57 insertions(+), 53 deletions(-) diff --git a/src/hono.ts b/src/hono.ts index cf7d1d8fc..4b9218c39 100644 --- a/src/hono.ts +++ b/src/hono.ts @@ -2212,7 +2212,7 @@ declare const walletsRelations: drizzle_orm.Relations<"wallets", { transactionsFrom: drizzle_orm.Many<"transactions">; transactionTo: drizzle_orm.Many<"transactions">; }>; -declare const transactionType: drizzle_orm_pg_core.PgEnum<["tip", "mint", "burn", "withdraw"]>; +declare const transactionType: drizzle_orm_pg_core.PgEnum<["tip", "mint", "burn", "withdraw", "purchase"]>; declare const transactions: drizzle_orm_pg_core.PgTableWithColumns<{ name: "transactions"; schema: undefined; @@ -2238,14 +2238,14 @@ declare const transactions: drizzle_orm_pg_core.PgTableWithColumns<{ tableName: "transactions"; dataType: "string"; columnType: "PgEnumColumn"; - data: "tip" | "mint" | "burn" | "withdraw"; + data: "tip" | "mint" | "burn" | "withdraw" | "purchase"; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; - enumValues: ["tip", "mint", "burn", "withdraw"]; + enumValues: ["tip", "mint", "burn", "withdraw", "purchase"]; baseColumn: never; generated: undefined; }, {}, {}>; @@ -2366,7 +2366,7 @@ declare const transactions: drizzle_orm_pg_core.PgTableWithColumns<{ }>; declare const transactionsOpenAPISchema: zod.ZodObject<{ hash: zod.ZodString; - type: zod.ZodEnum<["tip", "mint", "burn", "withdraw"]>; + type: zod.ZodEnum<["tip", "mint", "burn", "withdraw", "purchase"]>; fromUserId: zod.ZodNullable; toUserId: zod.ZodNullable; toFeedId: zod.ZodNullable; @@ -2375,7 +2375,7 @@ declare const transactionsOpenAPISchema: zod.ZodObject<{ createdAt: zod.ZodString; comment: zod.ZodNullable; }, zod.UnknownKeysParam, zod.ZodTypeAny, { - type: "tip" | "mint" | "burn" | "withdraw"; + type: "tip" | "mint" | "burn" | "withdraw" | "purchase"; createdAt: string; hash: string; fromUserId: string | null; @@ -2385,7 +2385,7 @@ declare const transactionsOpenAPISchema: zod.ZodObject<{ powerToken: string; comment: string | null; }, { - type: "tip" | "mint" | "burn" | "withdraw"; + type: "tip" | "mint" | "burn" | "withdraw" | "purchase"; createdAt: string; hash: string; fromUserId: string | null; @@ -2584,7 +2584,7 @@ declare const _routes: hono_hono_base.HonoBase { const invitations = useAuthQuery(Queries.invitations.list()) - const newInvitation = useMutation({ - mutationKey: ["newInvitation"], - mutationFn: () => apiClient.invitations.new.$post(), - async onError(err) { - toast.error(getFetchErrorMessage(err)) - }, - onSuccess(data) { - Queries.invitations.list().invalidate() - toast("🎉 New invitation generated, invite code is copied") - navigator.clipboard.writeText(data.data) - }, - }) - const presentUserProfile = usePresentUserProfileModal("drawer") const { present } = useModalStack() + const presentUserProfile = usePresentUserProfileModal("drawer") return ( <> @@ -69,24 +57,7 @@ export const SettingInvitations = () => { onClick={() => { present({ title: "Confirm", - content: ({ dismiss }) => ( - <> -
- Generating an invitation code will cost you 10 Power. Do you want to continue? -
-
- - -
- - ), + content: ({ dismiss }) => , }) }} > @@ -173,16 +144,6 @@ export const SettingInvitations = () => { (

No invitations

- -
- -
)} @@ -191,3 +152,42 @@ export const SettingInvitations = () => { ) } + +const ConfirmModalContent = ({ + dismiss, +}: { + dismiss: () => void +}) => { + const newInvitation = useMutation({ + mutationKey: ["newInvitation"], + mutationFn: () => apiClient.invitations.new.$post(), + async onError(err) { + toast.error(getFetchErrorMessage(err)) + }, + onSuccess(data) { + Queries.invitations.list().invalidate() + toast("🎉 New invitation generated, invite code is copied") + navigator.clipboard.writeText(data.data) + dismiss() + }, + }) + + return ( + <> +
+ Generating an invitation code will cost you 10 Power. Do you want to continue? +
+
+ + +
+ + ) +} diff --git a/src/renderer/src/modules/settings/tabs/wallet/transaction-section/index.tsx b/src/renderer/src/modules/settings/tabs/wallet/transaction-section/index.tsx index 8ddefdd75..299b4c620 100644 --- a/src/renderer/src/modules/settings/tabs/wallet/transaction-section/index.tsx +++ b/src/renderer/src/modules/settings/tabs/wallet/transaction-section/index.tsx @@ -65,6 +65,9 @@ export const TransactionsSection = () => { Date + + Tx + @@ -89,6 +92,9 @@ export const TransactionsSection = () => { + + {row.hash.slice(0, 6)}... + ))} @@ -111,11 +117,12 @@ const TypeRenderer = ({ >[number]["type"] }) => (
{type}