Skip to content

Commit

Permalink
🔀 Merge oauth cred
Browse files Browse the repository at this point in the history
  • Loading branch information
naelob committed Apr 18, 2024
1 parent 5ea5797 commit 0ff50da
Show file tree
Hide file tree
Showing 35 changed files with 2,159 additions and 230 deletions.
1 change: 1 addition & 0 deletions apps/client-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-tooltip": "^1.0.7",
"@radix-ui/react-scroll-area": "^1.0.5",
"@stytch/nextjs": "^18.0.0",
"@stytch/vanilla-js": "^4.7.1",
"@tanstack/react-query": "^5.12.2",
Expand Down
55 changes: 54 additions & 1 deletion apps/client-ts/src/app/configuration/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,24 @@ import {
import { usePostHog } from 'posthog-js/react'
import config from "@/lib/config";
import useProjectStore from "@/state/projectStore";
import AddAuthCredentials from "@/components/Configuration/AddAuthCredentials";
import AuthCredentialsTable from "@/components/Configuration/AuthCredentialsTable";
import useConnectionStrategies from "@/hooks/useConnectionStrategies";
import { extractAuthMode,extractProvider,extractVertical} from '@panora/shared'

export default function Page() {
const {idProject} = useProjectStore();


const { data: linkedUsers, isLoading, error } = useLinkedUsers();
const { data: webhooks, isLoading: isWebhooksLoading, error: isWebhooksError } = useWebhooks();
const {data: ConnectionStrategies, isLoading: isConnectionStrategiesLoading,error: isConnectionStategiesError} = useConnectionStrategies(idProject)

const { data: mappings, isLoading: isFieldMappingsLoading, error: isFieldMappingsError } = useFieldMappings();
const [open, setOpen] = useState(false);
const handleClose = () => {
setOpen(false);
};
const {idProject} = useProjectStore();


const posthog = usePostHog()
Expand All @@ -72,6 +79,18 @@ import {
if(isWebhooksError){
console.log("error fetching webhooks..");
}

if(isConnectionStrategiesLoading)
{
console.log("loading Connection Strategies...");
}

if(isConnectionStategiesError)
{
console.log("error Fetching connection Strategies!")
}



const mappingTs = mappings?.map(mapping => ({
standard_object: mapping.ressource_owner_type,
Expand All @@ -82,6 +101,19 @@ import {
destination_field: mapping.slug,
data_type: mapping.data_type,
}))

// console.log(ConnectionStrategies)

const mappingConnectionStrategies = ConnectionStrategies?.map(cs => ({
id_cs : cs.id_connection_strategy,
provider_name : extractProvider(cs.type),
auth_type: extractAuthMode(cs.type),
vertical: extractVertical(cs.type),
type: cs.type,
status: cs.status
}))

console.log(mappingConnectionStrategies)

return (

Expand All @@ -99,6 +131,9 @@ import {
<TabsTrigger value="webhooks">
Webhooks
</TabsTrigger>
<TabsTrigger value="0auth">
0Auth Credentials
</TabsTrigger>
</TabsList>
<TabsContent value="linked-accounts" className="space-y-4">
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-12">
Expand Down Expand Up @@ -173,6 +208,24 @@ import {
</Card>
</div>
</TabsContent>

<TabsContent value="0auth" className="space-y-4">
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-12">
<AddAuthCredentials/>
<Card className="col-span-12">
<CardHeader>
<CardTitle className="text-left">Your Providers</CardTitle>
<CardDescription className="text-left">
Use and setup the credentials of your providers.
</CardDescription>
</CardHeader>
<Separator className="mb-10"/>
<CardContent>
<AuthCredentialsTable mappings={mappingConnectionStrategies} isLoading={false} />
</CardContent>
</Card>
</div>
</TabsContent>
</Tabs>
</div>

Expand Down
3 changes: 2 additions & 1 deletion apps/client-ts/src/app/events/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ export default function Layout({
}: Readonly<{
children: React.ReactNode;
}>) {
const { session } = useStytchSession();
const { session, isInitialized} = useStytchSession();
const router = useRouter();
useEffect(() => {

if(config.DISTRIBUTION !== "selfhost" && !session){
router.replace("/b2c/login");
}
Expand Down
66 changes: 66 additions & 0 deletions apps/client-ts/src/components/Configuration/AddAuthCredentials.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
'use client'

import { Button } from "@/components/ui/button"
import {
Dialog,
DialogContent,
DialogTrigger,
} from "@/components/ui/dialog"

import { PlusCircledIcon } from "@radix-ui/react-icons"
import { useState } from "react"
import useProjectStore from "@/state/projectStore"

import { cn } from "@/lib/utils"

import { usePostHog } from 'posthog-js/react'
import config from "@/lib/config"
// import { toast } from "@/components/ui/use-toast"

import AddAuthCredentialsForm from "./AddAuthCredentialsForm"




const AddAuthCredentials = () => {
const [open, setOpen] = useState(false);
const posthog = usePostHog()
const {idProject} = useProjectStore();




const handleOpenChange = (open: boolean) => {
setOpen(open)
// form.reset()
};



return (
<Dialog open={open} onOpenChange={handleOpenChange}>
<DialogTrigger asChild>
<Button
variant="outline"
role="combobox"
aria-expanded={open}
className={cn("w-[210px] justify-between")}
onClick={ () => {
posthog?.capture("add_webhook_button_clicked", {
id_project: idProject,
mode: config.DISTRIBUTION
})
}}
>
<PlusCircledIcon className=" h-5 w-5" />
Add 0Auth Credentials
</Button>
</DialogTrigger>
<DialogContent className="sm:w-[450px] lg:max-w-screen-lg overflow-y-scroll max-h-screen">
<AddAuthCredentialsForm performUpdate={false} closeDialog={() => setOpen(false)} />
</DialogContent>
</Dialog>
)
}

export default AddAuthCredentials;
Loading

0 comments on commit 0ff50da

Please sign in to comment.