diff options
| author | Fuwn <[email protected]> | 2026-02-07 01:42:57 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-07 01:42:57 -0800 |
| commit | 5c5b1993edd890a80870ee05607ac5f088191d4e (patch) | |
| tree | a721b76bcd49ba10826c53efc87302c7a689512f /apps/web/lib/queries/use-user-profile.ts | |
| download | asa.news-5c5b1993edd890a80870ee05607ac5f088191d4e.tar.xz asa.news-5c5b1993edd890a80870ee05607ac5f088191d4e.zip | |
feat: asa.news RSS reader with developer tier, REST API, and webhooks
Full-stack RSS reader SaaS: Supabase + Next.js + Go worker.
Includes three subscription tiers (free/pro/developer), API key auth,
read-only REST API, webhook push notifications, Stripe billing with
proration, and PWA support.
Diffstat (limited to 'apps/web/lib/queries/use-user-profile.ts')
| -rw-r--r-- | apps/web/lib/queries/use-user-profile.ts | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/apps/web/lib/queries/use-user-profile.ts b/apps/web/lib/queries/use-user-profile.ts new file mode 100644 index 0000000..760f970 --- /dev/null +++ b/apps/web/lib/queries/use-user-profile.ts @@ -0,0 +1,46 @@ +"use client" + +import { useQuery } from "@tanstack/react-query" +import { createSupabaseBrowserClient } from "@/lib/supabase/client" +import { queryKeys } from "./query-keys" +import type { UserProfile } from "@/lib/types/user-profile" + +export function useUserProfile() { + const supabaseClient = createSupabaseBrowserClient() + + return useQuery({ + queryKey: queryKeys.userProfile.all, + queryFn: async () => { + const { + data: { user }, + } = await supabaseClient.auth.getUser() + + if (!user) throw new Error("Not authenticated") + + const { data, error } = await supabaseClient + .from("user_profiles") + .select( + "id, display_name, tier, feed_count, folder_count, muted_keyword_count, custom_feed_count, stripe_subscription_status, stripe_current_period_end" + ) + .eq("id", user.id) + .single() + + if (error) throw error + + const profile: UserProfile = { + identifier: data.id, + email: user.email ?? null, + displayName: data.display_name, + tier: data.tier, + feedCount: data.feed_count, + folderCount: data.folder_count, + mutedKeywordCount: data.muted_keyword_count, + customFeedCount: data.custom_feed_count, + stripeSubscriptionStatus: data.stripe_subscription_status, + stripeCurrentPeriodEnd: data.stripe_current_period_end, + } + + return profile + }, + }) +} |