Skip to content

Commit

Permalink
Merge pull request #443 from panoratech/feat/fix-build
Browse files Browse the repository at this point in the history
💚 Fix build
  • Loading branch information
naelob authored May 20, 2024
2 parents aa7b540 + 507b16a commit 1ce71bd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
25 changes: 21 additions & 4 deletions apps/client-ts/src/app/(Dashboard)/b2c/profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,27 @@ import Cookies from 'js-cookie';
import useProfileStore from "@/state/profileStore";
import useProjectStore from "@/state/projectStore"
import { useQueryClient } from '@tanstack/react-query';
import { useState } from "react";


const Profile = () => {
const [copied, setCopied] = useState(false);
const { profile, setProfile } = useProfileStore();
const { setIdProject } = useProjectStore();
const queryClient = useQueryClient();

const router = useRouter();

const handleCopy = async (email: string) => {
try {
await navigator.clipboard.writeText(email)
setCopied(true);
setTimeout(() => setCopied(false), 2000); // Reset copied state after 2 seconds
} catch (err) {
console.error('Failed to copy: ', err);
}
};

const onLogout = () => {
router.push('/b2c/login')
Cookies.remove("access_token")
Expand All @@ -33,7 +45,7 @@ const Profile = () => {
}

return (
<div className="ml-[200px] p-10">
<div className="p-10">
<Card>
<CardHeader>
<CardTitle>Profile</CardTitle>
Expand All @@ -48,13 +60,18 @@ const Profile = () => {

<div className="flex space-x-2">
<Input value={`${profile?.email}`} readOnly />
<Button variant="secondary" className="shrink-0">
Copy
<Button type="button" onClick={() => handleCopy(profile?.email!)}>
{copied ? 'Copied!' : (
<>
<p className="mr-1" >Copy</p>
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5 2V1H10V2H5ZM4.75 0C4.33579 0 4 0.335786 4 0.75V1H3.5C2.67157 1 2 1.67157 2 2.5V12.5C2 13.3284 2.67157 14 3.5 14H11.5C12.3284 14 13 13.3284 13 12.5V2.5C13 1.67157 12.3284 1 11.5 1H11V0.75C11 0.335786 10.6642 0 10.25 0H4.75ZM11 2V2.25C11 2.66421 10.6642 3 10.25 3H4.75C4.33579 3 4 2.66421 4 2.25V2H3.5C3.22386 2 3 2.22386 3 2.5V12.5C3 12.7761 3.22386 13 3.5 13H11.5C11.7761 13 12 12.7761 12 12.5V2.5C12 2.22386 11.7761 2 11.5 2H11Z" fill="currentColor" fillRule="evenodd" clipRule="evenodd"></path></svg>
</>
)}
</Button>
</div>
<Separator className="my-4" />
<div className="pt-4">
<Button onClick={() => onLogout()}>
<Button onClick={() => onLogout()} size="sm" className="h-7 gap-1">
Log Out
</Button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,6 @@ export const columns: ColumnDef<Mapping>[] = [
},
{
id: "actions",
cell: ({ row }) => <DataTableRowActions row={row} />,
cell: ({ row }) => <DataTableRowActions row={row} object={"field-mapping"} />,
},
]
10 changes: 6 additions & 4 deletions apps/client-ts/src/components/shared/data-table-row-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import useDeleteWebhook from "@/hooks/delete/useDeleteWebhook"

interface DataTableRowActionsProps<TData> {
row: Row<TData>;
object: "webhook" | "api-key"
object: "webhook" | "api-key" | "field-mapping"
}

export function DataTableRowActions<TData>({
Expand All @@ -31,14 +31,16 @@ export function DataTableRowActions<TData>({
switch(object) {
case 'webhook':
removeWebhook({
id_webhook: row.original.id_webhook_endpoint
id_webhook: (row.original as any).id_webhook_endpoint
})
break;
case 'api-key':
removeApiKey({
id_api_key: row.original.id_api_key
id_api_key: (row.original as any).id_api_key
})
break;
break;
default:
break;
}
}

Expand Down

0 comments on commit 1ce71bd

Please sign in to comment.