feat: implement sharing

This commit is contained in:
shadcn 2023-06-16 15:20:42 +04:00
parent 385b31d42c
commit 8cc3fea048
19 changed files with 507 additions and 96 deletions

View file

@ -5,5 +5,17 @@ export interface Chat extends Record<string, any> {
title: string
createdAt: Date
userId: string
path: string
messages: Message[]
}
export interface Share {
id: string
title: string
createdAt: number
userId: string
path: string
chat: Chat
}
export type ServerActionResult<Result> = Promise<Result | Error>

View file

@ -32,3 +32,12 @@ export async function fetcher<JSON = any>(
return res.json()
}
export function formatDate(input: string | number | Date): string {
const date = new Date(input)
return date.toLocaleDateString('en-US', {
month: 'long',
day: 'numeric',
year: 'numeric'
})
}