Skip to content

Commit

Permalink
🐛 Fix bugs and added copy feat for linkedUserId
Browse files Browse the repository at this point in the history
  • Loading branch information
mit-27 committed May 28, 2024
1 parent f95dca8 commit b50bde6
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,48 @@ import { ColumnDef } from "@tanstack/react-table";
import { ColumnLU } from "./schema";
import { DataTableColumnHeader } from "@/components/shared/data-table-column-header";
import { Badge } from "@/components/ui/badge";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import { toast } from "sonner";


const LinkedUserIdComponent = ({ row } : {row:any}) => {

const handleCopyLinkedUserId = () => {
navigator.clipboard.writeText(row.getValue("linked_user_id"));
toast.success("LinkedUser ID copied!", {
action: {
label: "Close",
onClick: () => console.log("Close"),
},
})
};

return (
<div className="cursor-pointer" onClick={handleCopyLinkedUserId}>
<TooltipProvider delayDuration={0}>
<Tooltip>
<TooltipTrigger>
<Badge variant="outline" >
{row.getValue("linked_user_id")}
</Badge>
</TooltipTrigger>
<TooltipContent>
<p className="text-sm">Copy</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</div>
)
}


export const columns: ColumnDef<ColumnLU>[] = [
{
accessorKey: "linked_user_id",
header: ({ column }) => (
<DataTableColumnHeader column={column} title="Linked User Id" />
),
cell: ({ row }) =>{
return (
<div className="">
<Badge variant="outline">{row.getValue("linked_user_id")}</Badge>
</div>
)
},
cell: LinkedUserIdComponent,
enableSorting: false,
enableHiding: false,
},
Expand Down
13 changes: 0 additions & 13 deletions apps/client-ts/src/components/Nav/main-nav-sm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export function SmallNav({
<SheetHeader className="flex items-center">
<SheetTitle className="mx-4 my-4">
<Link href="/" className="flex flex-row" onClick={() => setOpen(false)}>
{/* <img src="./../../../../public/logo.png" className="w-10 mr-1"/><span className="font-bold">Panora.</span> */}
{theme == "light" ? <img src="/logo-panora-black.png" className='w-12' /> : <img src="/logo-panora-white-hq.png" className='w-12' />}

</Link>
Expand All @@ -70,18 +69,6 @@ export function SmallNav({
<nav
className={`flex flex-col items-start mt-6`}
>
{/*<a
className={navItemClassName('quickstart')}
onClick={() => click('quickstart')}
>
<p className="mx-4">Quick Start</p>
</a>
<a
className={navItemClassName('dashboard')}
onClick={() => click('dashboard')}
>
<p className="mx-4">Dashboard</p>
</a>*/}
<a
className={navItemClassName('connections')}
onClick={() => click('connections')}
Expand Down
5 changes: 2 additions & 3 deletions apps/embedded-catalog/react/src/components/Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useState } from 'react'
import {PartyPopper, Unplug,X} from 'lucide-react'
import React from 'react'

const Modal = ({open,setOpen,children} : {open:boolean,setOpen: (op : boolean) => void,children: React.ReactNode}) => {
const Modal = ({open,setOpen,children} : {open:boolean,setOpen: React.Dispatch<React.SetStateAction<boolean>>,children: React.ReactNode}) => {
return (
<div
onClick={() => setOpen(false)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const DynamicCatalog = ({projectId,linkedUserId, category, optionalApiUrl} : Dyn
providerName: selectedProvider?.provider!,
vertical: selectedProvider?.category! as ConnectorCategory,
returnUrl: returnUrlWithWindow,
// returnUrl: returnUrl,
projectId: projectId,
linkedUserId: linkedUserId,
optionalApiUrl: optionalApiUrl,
Expand Down
24 changes: 13 additions & 11 deletions apps/embedded-catalog/react/src/hooks/useOAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,19 @@ type UseOAuthProps = {

const useOAuth = ({ providerName, vertical, returnUrl, projectId, linkedUserId, optionalApiUrl, onSuccess }: UseOAuthProps) => {
const [isReady, setIsReady] = useState(false);
const intervalRef = useRef<number | null>(null);
const intervalRef = useRef<number | ReturnType<typeof setInterval> | null>(null);
const authWindowRef = useRef<Window | null>(null);

const clearExistingInterval = (clearAuthWindow : boolean) => {
if (clearAuthWindow && authWindowRef.current && !authWindowRef.current.closed) {
authWindowRef.current.close();
}
if (intervalRef.current !== null) {
clearInterval(intervalRef.current);
intervalRef.current = null;
}
};

useEffect(() => {
// Perform any setup logic here
setTimeout(() => setIsReady(true), 1000); // Simulating async operation
Expand All @@ -31,15 +41,7 @@ const useOAuth = ({ providerName, vertical, returnUrl, projectId, linkedUserId,
};
}, []);

const clearExistingInterval = (clearAuthWindow : boolean) => {
if (clearAuthWindow && authWindowRef.current && !authWindowRef.current.closed) {
authWindowRef.current.close();
}
if (intervalRef.current !== null) {
clearInterval(intervalRef.current);
intervalRef.current = null;
}
};


const openModal = async (onWindowClose: () => void) => {
const apiUrl = optionalApiUrl ? optionalApiUrl : config.API_URL!;
Expand All @@ -48,7 +50,7 @@ const useOAuth = ({ providerName, vertical, returnUrl, projectId, linkedUserId,
});

if (!authUrl) {
throw new Error("Auth Url is Invalid " + authUrl);
throw new Error(`Auth Url is Invalid: ${authUrl}`);
}

const width = 600, height = 600;
Expand Down

0 comments on commit b50bde6

Please sign in to comment.