-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5708f5
commit 22825d0
Showing
33 changed files
with
524 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
apps/dashboard-app/actions/connections/user-connections.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,27 @@ | ||
'use server' | ||
import { getConnectionByUser} from '@repo/prisma-db/repo/user' | ||
|
||
import { updateConnection,deleteConnection, deleteYoutubeConnection, deleteNotionConnection, deleteOpenAIConnection } from '@repo/prisma-db/repo/connection' | ||
export const getUserInfo = async (userId: string) => { | ||
const user_info:any = await getConnectionByUser(userId); | ||
return user_info; | ||
} | ||
|
||
export const updateConnectionById = async (id: string, name: string) => { | ||
const conn = await updateConnection(id,name); | ||
return conn; | ||
} | ||
|
||
export const deleteConnectionById = async (id: string) => { | ||
const conn = await deleteConnection(id); | ||
if (conn.type === 'Youtube') { | ||
await deleteYoutubeConnection(conn.youtubeId as string); | ||
} | ||
else if (conn.type === 'OpenAI') { | ||
await deleteOpenAIConnection(conn.openaiId as string); | ||
} | ||
else if (conn.type === 'Notion') { | ||
await deleteNotionConnection(conn.notionId as string); | ||
} | ||
return conn; | ||
} |
5 changes: 1 addition & 4 deletions
5
apps/dashboard-app/actions/connections/youtube-connections.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
apps/dashboard-app/app/(dashboard)/connections/_components/Connected.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
'use client' | ||
import React, { useContext, useEffect, useState } from 'react' | ||
import { CONNECTIONS } from '../../../../lib/constant' | ||
import { useSession } from 'next-auth/react' | ||
import { getUserInfo } from '../../../../actions/connections/user-connections' | ||
import { ConnectionsContext } from '../../../../providers/connections-provider' | ||
import ConnectedCard from '../../../../components/ConnectedCard' | ||
|
||
const Connected = () => { | ||
|
||
const session = useSession() | ||
const [connections,setConnections] = useState<any>([]) | ||
|
||
useEffect(() => { | ||
const getConnections = async () => { | ||
if (session?.data?.user?.id) { | ||
const userInfo = await getUserInfo(session.data.user.id); | ||
const newConnections: any = []; | ||
for (let connection of userInfo?.connections) { | ||
const cons = CONNECTIONS.find((con) => con.title === connection.type); | ||
if (cons) { | ||
const newConnection = { ...cons, ...connection }; | ||
console.log() | ||
if (!connections.some((conn:any) => conn.id === newConnection.id)) { | ||
newConnections.push(newConnection); | ||
} | ||
} | ||
}; | ||
setConnections(newConnections); | ||
} | ||
}; | ||
|
||
getConnections(); | ||
}, [session]); | ||
|
||
if (!session) { | ||
return <div>loading...</div> | ||
} | ||
|
||
return ( | ||
<div className='m-6'> | ||
<div> | ||
These are the apps correctly corrected | ||
</div> | ||
<div className='mt-10 grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4'> | ||
|
||
{connections?.map((connection:any) => ( | ||
<ConnectedCard | ||
key={connection.title} | ||
connection={connection} | ||
/> | ||
))} | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default Connected; |
29 changes: 29 additions & 0 deletions
29
apps/dashboard-app/app/(dashboard)/connections/_components/Connections.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use client' | ||
import React from 'react' | ||
import { CONNECTIONS } from '../../../../lib/constant' | ||
import ConnectionCard from '../../../../components/ConnectionCard' | ||
|
||
type Props = { | ||
searchParams?: { [key: string]: string | undefined } | ||
} | ||
|
||
const Connections = () => { | ||
|
||
return ( | ||
<div className='m-6'> | ||
<div> | ||
Connect all your apps directly from here. You may need to connect these apps regularly to refresh verfication. | ||
</div> | ||
<div className='mt-10 grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4'> | ||
{CONNECTIONS.map((connection) => ( | ||
<ConnectionCard | ||
key={connection.title} | ||
connection={connection} | ||
/> | ||
))} | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default Connections; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import axios from 'axios'; | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
import { google } from 'googleapis'; | ||
|
||
|
||
export async function GET(req: NextRequest) { | ||
|
||
const oauth2Client = new google.auth.OAuth2( | ||
process.env.NEXT_PUBLIC_CALENDAR_CLIENT_ID, | ||
process.env.NEXT_PUBLIC_CALENDAR_CLIENT_SECRET, | ||
process.env.NEXT_PUBLIC_CALENDAR_REDIRECT_URI | ||
); | ||
|
||
// generate a url that asks permissions for Blogger and Google Calendar scopes | ||
const scopes = [ | ||
'https://www.googleapis.com/auth/calendar', | ||
]; | ||
|
||
const url = oauth2Client.generateAuthUrl({ | ||
// 'online' (default) or 'offline' (gets refresh_token) | ||
access_type: 'offline', | ||
|
||
// If you only need one scope you can pass it as a string | ||
scope: scopes | ||
}); | ||
return NextResponse.redirect(url); | ||
} |
6 changes: 3 additions & 3 deletions
6
...mponents/organisms/AddConnectionModal.tsx → ...ard-app/components/AddConnectionModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.