Working tree is now the canonical repo. Off-chain play-money + trustless on-chain (FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution, mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import { useEffect, useState } from 'react'
|
|
import { useIsAuthorized } from './use-user'
|
|
import { Dashboard } from 'common/dashboard'
|
|
import { api, getYourDashboards } from 'web/lib/api/api'
|
|
import { getYourFollowedDashboards } from 'web/lib/api/api'
|
|
|
|
export function useDashboardFromSlug(slug: string) {
|
|
const [dashboard, setDashboard] = useState<Dashboard>()
|
|
|
|
useEffect(() => {
|
|
api('get-dashboard-from-slug', { dashboardSlug: slug }).then((result) => {
|
|
setDashboard(result as Dashboard)
|
|
})
|
|
}, [slug])
|
|
|
|
return dashboard
|
|
}
|
|
|
|
export function useYourDashboards() {
|
|
const isAuth = useIsAuthorized()
|
|
|
|
const [yourDashboards, setYourDashboards] = useState<Dashboard[] | undefined>(
|
|
undefined
|
|
)
|
|
|
|
useEffect(() => {
|
|
if (!isAuth) return
|
|
getYourDashboards().then((results) => {
|
|
setYourDashboards(results.dashboards as Dashboard[])
|
|
})
|
|
}, [isAuth])
|
|
|
|
return yourDashboards
|
|
}
|
|
|
|
export function useYourFollowedDashboards() {
|
|
const isAuth = useIsAuthorized()
|
|
|
|
const [followedDashboards, setFollowedDashboards] = useState<
|
|
Dashboard[] | undefined
|
|
>(undefined)
|
|
|
|
useEffect(() => {
|
|
if (!isAuth) return
|
|
getYourFollowedDashboards().then((results) => {
|
|
setFollowedDashboards(results.dashboards as Dashboard[])
|
|
})
|
|
}, [isAuth])
|
|
|
|
return followedDashboards
|
|
}
|