Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment variables using server actions now #16

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions apps/dashboard-app/app/actions/env/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use server"

export async function getEnvironmentVariables(){
var res:any = {}
res["NEXT_PUBLIC_RESEND_API_KEY"] = process.env.NEXT_PUBLIC_RESEND_API_KEY
res["NEXT_PUBLIC_URL"] = process.env.NEXT_PUBLIC_URL
res["NEXT_PUBLIC_YOUTUBE_OAUTH_URL"] = process.env.NEXT_PUBLIC_YOUTUBE_OAUTH_URL
res["NEXT_PUBLIC_NOTION_CLIENT_ID"] = process.env.NEXT_PUBLIC_NOTION_CLIENT_ID
res["NEXT_PUBLIC_NOTION_CLIENT_SECRET"] = process.env.NEXT_PUBLIC_NOTION_CLIENT_SECRET
res["NEXT_PUBLIC_NOTION_REDIRECT_URI"] = process.env.NEXT_PUBLIC_NOTION_REDIRECT_URI
res["NEXT_PUBLIC_NOTION_OAUTH_URL"] = process.env.NEXT_PUBLIC_NOTION_OAUTH_URL
return res

}
19 changes: 12 additions & 7 deletions apps/dashboard-app/components/ConnectionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import AddConnectionsModal from './AddConnectionModal'
import { useSession } from 'next-auth/react'
import { createOpenAIConnection } from '../app/actions/connections/openai-connections'
import { useRouter } from 'next/navigation'
import { getEnvironmentVariables } from '../app/actions/env/env'


const ConnectionCard = ({connection}:any) => {
Expand All @@ -32,14 +33,18 @@ const ConnectionCard = ({connection}:any) => {
}

useEffect(() => {
setAppType(connection.title)
if (connection.title === 'Notion'){
setOauthUrl(process.env.NEXT_PUBLIC_NOTION_OAUTH_URL as string)
}
else if (connection.title === 'Youtube'){
setCallbackUrl(process.env.NEXT_PUBLIC_URL+'/api/callback/youtube')
setOauthUrl(process.env.NEXT_PUBLIC_YOUTUBE_OAUTH_URL as string)
const updateEnvironmentVariables = async () => {
setAppType(connection.title)
const res = await getEnvironmentVariables();
if (connection.title === 'Notion'){
setOauthUrl(res["NEXT_PUBLIC_NOTION_OAUTH_URL"] )
}
else if (connection.title === 'Youtube'){
setCallbackUrl(res["NEXT_PUBLIC_URL"]+'/api/callback/youtube')
setOauthUrl(res["NEXT_PUBLIC_YOUTUBE_OAUTH_URL"])
}
}
updateEnvironmentVariables()
},[connection.title])

const handleConnect = () => {
Expand Down
Loading