Files
supabase/apps/database-new/data/conversations-query.ts
T
fbfe910c22 Initial work on database.new visualizer (#19027)
* Initial commit.

* Remove bunch of unneeded deps.

* Fix the providers.

* Minor fixes to make the themes work.

* Fix prettier errors.

* Add default constraint.

* Midway styling

* General styling improvements

* More styling stuff

* Bit more styling

* Bit more pizzazz

* Scaffold all threads modal

* Small style fix

* Ensure loading state persist in new page until redirect

* Fix

* Test';

* Add basic validation

* Fix

* Remove console logs

* Hide show all threads button

* chore: style the blocks

* fix: stroke width

* add some shadow

* stroke width

* Update TableNode.tsx

* Swap hide chat for hide code

* more sidebar styling

* Resolve conflicts

* Some style fixeds

* Some style fixeds

* mock profile

* update user dorpdown

* Update globals.css

* Chore/db new layouts and url params (#19142)

* chore: layouts

* Fix + clean up

---------

Co-authored-by: Jonathan Summers-Muir <MildTomato@users.noreply.github.com>

* Fix header

* Scaffold profile and conversations

* Some quick styling

* Update apps/database-new/.env.local.example

Co-authored-by: Greg Richardson <greg.nmr@gmail.com>

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
Co-authored-by: Jonathan Summers-Muir <MildTomato@users.noreply.github.com>
Co-authored-by: Greg Richardson <greg.nmr@gmail.com>
2023-11-22 12:31:32 -03:30

53 lines
1.6 KiB
TypeScript

import { useQuery } from '@tanstack/react-query'
export type ConversationsVariables = {
userId: string
enabled?: boolean
}
// Just update based on the schema - or use the dashboard's type generation feature 😉
export type Conversation = {
id: string
name: string
threadId: string
runId: string
createdAt: string
updatedAt: string
}
export const useConversationsQuery = ({ userId, enabled }: ConversationsVariables) =>
useQuery<Conversation[]>({
queryKey: [userId, 'conversations'],
enabled: enabled && !!userId,
queryFn: async () => {
// [Joshen] Just mocking the conversations data, to replace with fetching from Supabase
const getConversations = (): Promise<Conversation[]> => {
return new Promise(function (resolve, reject) {
setTimeout(function () {
resolve([
{
id: '1',
name: 'Twitter clone',
threadId: 'thread_vrXIl16bUusqFMUFYDw8CoEy',
runId: 'run_4DiPb5ppb5hwY1y6dT1qEWzc',
createdAt: '2022-07-29 07:53:58.560926+00',
updatedAt: '2022-07-29 07:53:58.560926+00',
},
{
id: '2',
name: 'Supabase clone',
threadId: 'thread_vrXIl16bUusqFMUFYDw8CoEy',
runId: 'run_4DiPb5ppb5hwY1y6dT1qEWzc',
createdAt: '2022-07-29 07:53:58.560926+00',
updatedAt: '2022-07-30 07:53:58.560926+00',
},
])
}, 100)
})
}
const result = await getConversations()
return result
},
})