From fa37a0ca2c8235fb5fd47f96c26de7fdcd762ad8 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Sun, 15 Sep 2024 02:29:19 +0800 Subject: [PATCH] feat: invitation limitation message --- locales/settings/en.json | 1 + src/hono.ts | 39 +++++++++++-------- .../src/modules/settings/tabs/invitations.tsx | 14 ++++++- src/renderer/src/queries/invitations.ts | 6 +++ 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/locales/settings/en.json b/locales/settings/en.json index afb4d62eb..5a14d56c1 100644 --- a/locales/settings/en.json +++ b/locales/settings/en.json @@ -131,6 +131,7 @@ "invitation.generateButton": "Generate new code", "invitation.generateCost": "You can spend {{INVITATION_PRICE}} Power to generate an invitation code for your friends.", "invitation.getCodeMessage": "You can get an invitation code through the following methods:", + "invitation.limitationMessage": "Based on your usage time, you can generate up to {{limitation}} invitation codes.", "invitation.newInvitationSuccess": "🎉 New invitation generated, invite code is copied", "invitation.noInvitations": "No invitations", "invitation.notUsed": "Not used", diff --git a/src/hono.ts b/src/hono.ts index bb2b2db91..02bc36547 100644 --- a/src/hono.ts +++ b/src/hono.ts @@ -3492,21 +3492,23 @@ declare const users: drizzle_orm_pg_core.PgTableWithColumns<{ dialect: "pg" }> declare const usersOpenApiSchema: z.ZodObject< - { - id: z.ZodString - name: z.ZodNullable - email: z.ZodString - emailVerified: z.ZodNullable - image: z.ZodNullable - handle: z.ZodNullable - createdAt: z.ZodDate - }, + Omit< + { + id: z.ZodString + name: z.ZodNullable + email: z.ZodString + emailVerified: z.ZodNullable + image: z.ZodNullable + handle: z.ZodNullable + createdAt: z.ZodDate + }, + "email" + >, z.UnknownKeysParam, z.ZodTypeAny, { name: string | null id: string - email: string emailVerified: string | null image: string | null handle: string | null @@ -3515,7 +3517,6 @@ declare const usersOpenApiSchema: z.ZodObject< { name: string | null id: string - email: string emailVerified: string | null image: string | null handle: string | null @@ -4416,7 +4417,6 @@ declare const _routes: hono_hono_base.HonoBase< fromUser: { name: string | null id: string - email: string emailVerified: string | null image: string | null handle: string | null @@ -4425,7 +4425,6 @@ declare const _routes: hono_hono_base.HonoBase< toUser: { name: string | null id: string - email: string emailVerified: string | null image: string | null handle: string | null @@ -4619,7 +4618,6 @@ declare const _routes: hono_hono_base.HonoBase< owner: { name: string | null id: string - email: string emailVerified: string | null image: string | null handle: string | null @@ -4819,7 +4817,6 @@ declare const _routes: hono_hono_base.HonoBase< data: { name: string | null id: string - email: string emailVerified: string | null image: string | null handle: string | null @@ -4900,6 +4897,17 @@ declare const _routes: hono_hono_base.HonoBase< status: 200 } } + "/invitations/limitation": { + $get: { + input: {} + output: { + code: 0 + data: number + } + outputFormat: "json" | "text" + status: 200 + } + } } & { "/feeds/claim/message": { $get: { @@ -5300,7 +5308,6 @@ declare const _routes: hono_hono_base.HonoBase< owner: { name: string | null id: string - email: string emailVerified: string | null image: string | null handle: string | null diff --git a/src/renderer/src/modules/settings/tabs/invitations.tsx b/src/renderer/src/modules/settings/tabs/invitations.tsx index 074cb0a6b..84ab6c065 100644 --- a/src/renderer/src/modules/settings/tabs/invitations.tsx +++ b/src/renderer/src/modules/settings/tabs/invitations.tsx @@ -33,6 +33,7 @@ import { toast } from "sonner" export const SettingInvitations = () => { const { t } = useTranslation("settings") const invitations = useAuthQuery(Queries.invitations.list()) + const limitation = useAuthQuery(Queries.invitations.limitation()) const { present } = useModalStack() const presentUserProfile = usePresentUserProfileModal("drawer") @@ -54,7 +55,16 @@ export const SettingInvitations = () => { PowerIcon: , }} i18nKey="invitation.generateCost" - /> + /> +

+

+