forked from manifoldmarkets/manifold
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard.ts
43 lines (36 loc) · 935 Bytes
/
dashboard.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { JSONContent } from '@tiptap/core'
import { Row, convertSQLtoTS, tsToMillis } from './supabase/utils'
export const MAX_DASHBOARD_TITLE_LENGTH = 40
// corresponds to SQL
export type BaseDashboard = {
id: string
slug: string
creatorId: string
createdTime: number
description: JSONContent
title: string
items: DashboardItem[]
creatorUsername: string
creatorName: string
creatorAvatarUrl: string
visibility: 'public' | 'deleted'
}
export type Dashboard = BaseDashboard & {
topics: string[]
}
export type DashboardItem = DashboardQuestionItem | DashboardLinkItem
export type DashboardQuestionItem = {
type: 'question'
slug: string
}
export type DashboardLinkItem = {
type: 'link'
url: string
}
export const convertDashboardSqltoTS = (
sqlDashboard: Row<'dashboards'>
): BaseDashboard => {
return convertSQLtoTS<'dashboards', Dashboard>(sqlDashboard, {
created_time: tsToMillis,
})
}