From 89b0e7b86210e7a4607348700f22874f4eb86958 Mon Sep 17 00:00:00 2001 From: Rachid Flih Date: Sun, 22 Dec 2024 23:06:44 -0300 Subject: [PATCH] fix: frontend build --- .../app/(Dashboard)/configuration/page.tsx | 10 +- apps/webapp/src/app/b2c/login/page.tsx | 20 +- .../webapp/src/components/ApiKeys/columns.tsx | 145 +++++++------ .../CustomLoginComponent/CreateUserForm.tsx | 7 +- .../Configuration/Catalog/CatalogWidget.tsx | 9 +- .../src/components/Connection/columns.tsx | 202 ++++++++++-------- apps/webapp/src/components/Events/columns.tsx | 8 +- 7 files changed, 218 insertions(+), 183 deletions(-) diff --git a/apps/webapp/src/app/(Dashboard)/configuration/page.tsx b/apps/webapp/src/app/(Dashboard)/configuration/page.tsx index f3d3b1f66..efee2b607 100644 --- a/apps/webapp/src/app/(Dashboard)/configuration/page.tsx +++ b/apps/webapp/src/app/(Dashboard)/configuration/page.tsx @@ -123,7 +123,7 @@ export default function Page() { }, {} as Record); setLocalFrequencies(initialFrequencies); } - }, [pullFrequencies]); + }, [pullFrequencies, VERTICALS]); const handleFrequencyChange = (vertical: string, value: string) => { setLocalFrequencies(prev => ({ ...prev, [vertical]: value })); @@ -166,8 +166,10 @@ export default function Page() { const handleConfirmSuspend = async () => { try { - await saveFrequency(selectedVertical, '0'); - setDialogOpen(false); + if (selectedVertical) { + await saveFrequency(selectedVertical, '0'); + setDialogOpen(false); + } } catch (error) { console.error('Error suspending sync:', error); } @@ -187,7 +189,7 @@ export default function Page() { Confirm Sync Suspension - This will stop all automatic syncs for {selectedVertical?.toUpperCase()}. To confirm, please type "suspend" below. + This will stop all automatic syncs for {selectedVertical?.toUpperCase()}. To confirm, please type "suspend" below. { - if(!Cookies.get('access_token')) - { - setUserInitialized(false); - } + { + setUserInitialized(false); + } if(Cookies.get('access_token') && !profile) { @@ -66,8 +64,7 @@ export default function Page() { onError: () => setUserInitialized(false) }) } - - },[]) + },[profile, mutate]) if (!mounted) { return null; @@ -107,12 +104,15 @@ export default function Page() {

- Connect your warehouse to any e-commerce platform and let AI automate data entry into your WMS & ERPs. Add revenue, not complexity to your operations. + Connect your warehouse to any e-commerce platform and let AI automate data entry into your WMS & ERPs. Add revenue, not complexity to your operations.

Use one unified API to manage orders across Shopify, Amazon, and more. Let AI handle your inventory updates while you focus on growth.

-

You'll wonder how you ever managed without it.

+

You'll wonder how you ever managed without it.

+

+ Don't have an account? Create one now +

diff --git a/apps/webapp/src/components/ApiKeys/columns.tsx b/apps/webapp/src/components/ApiKeys/columns.tsx index 40f5ee704..4cd519934 100644 --- a/apps/webapp/src/components/ApiKeys/columns.tsx +++ b/apps/webapp/src/components/ApiKeys/columns.tsx @@ -20,6 +20,79 @@ import { Input } from "@/components/ui/input" import useDeleteApiKey from "@/hooks/delete/useDeleteApiKey" import { useQueryClient } from "@tanstack/react-query" +// Create a proper React component for the actions cell +const DeleteApiKeyCell = ({ row }: { row: any }) => { + const [dialogOpen, setDialogOpen] = useState(false); + const [confirmText, setConfirmText] = useState(''); + const { deleteApiKeyPromise } = useDeleteApiKey(); + const queryClient = useQueryClient(); + + const handleDelete = async () => { + if (confirmText.toLowerCase() === 'delete') { + try { + await toast.promise( + deleteApiKeyPromise({ + id_api_key: row.original.id_api_key, + }), + { + loading: 'Deleting API key...', + success: 'API key deleted successfully', + error: 'Failed to delete API key' + } + ); + queryClient.invalidateQueries({ queryKey: ['api-keys'] }); + setDialogOpen(false); + } catch (error) { + console.error('Failed to delete API key:', error); + } + } + }; + + return ( + <> + + + + + + Confirm API Key Deletion + + This will permanently delete this API key. To confirm, please type "delete" below. + + + setConfirmText(e.target.value)} + placeholder="Type 'delete' to confirm" + /> + + + + + + + + ); +}; + export function useColumns() { return [ { @@ -33,77 +106,7 @@ export function useColumns() { }, { id: "actions", - cell: ({ row }) => { - const [dialogOpen, setDialogOpen] = useState(false); - const [confirmText, setConfirmText] = useState(''); - const { deleteApiKeyPromise } = useDeleteApiKey(); - const queryClient = useQueryClient(); - - const handleDelete = async () => { - if (confirmText.toLowerCase() === 'delete') { - try { - await toast.promise( - deleteApiKeyPromise({ - id_api_key: row.original.id_api_key, - }), - { - loading: 'Deleting API key...', - success: 'API key deleted successfully', - error: 'Failed to delete API key' - } - ); - queryClient.invalidateQueries({ queryKey: ['api-keys'] }); - setDialogOpen(false); - } catch (error) { - console.error('Failed to delete API key:', error); - } - } - }; - - return ( - <> - - - - - - Confirm API Key Deletion - - This will permanently delete this API key. To confirm, please type "delete" below. - - - setConfirmText(e.target.value)} - placeholder="Type 'delete' to confirm" - /> - - - - - - - - ); - }, + cell: ({ row }) => , }, ] as ColumnDef[]; } diff --git a/apps/webapp/src/components/Auth/CustomLoginComponent/CreateUserForm.tsx b/apps/webapp/src/components/Auth/CustomLoginComponent/CreateUserForm.tsx index b0f16acc3..0d17b7377 100644 --- a/apps/webapp/src/components/Auth/CustomLoginComponent/CreateUserForm.tsx +++ b/apps/webapp/src/components/Auth/CustomLoginComponent/CreateUserForm.tsx @@ -117,7 +117,12 @@ const CreateUserForm = () => { // Set the access token if (loginResponse.access_token) { Cookies.set('access_token', loginResponse.access_token); - setProfile(loginResponse.user); + setProfile({ + id_user: loginResponse.user.id, + email: loginResponse.user.email, + first_name: loginResponse.user.first_name, + last_name: loginResponse.user.last_name + }); router.replace('/connections'); toast.success('Logged in successfully!'); } diff --git a/apps/webapp/src/components/Configuration/Catalog/CatalogWidget.tsx b/apps/webapp/src/components/Configuration/Catalog/CatalogWidget.tsx index 8755a7174..e87381a9f 100644 --- a/apps/webapp/src/components/Configuration/Catalog/CatalogWidget.tsx +++ b/apps/webapp/src/components/Configuration/Catalog/CatalogWidget.tsx @@ -12,6 +12,7 @@ import useProjectStore from "@/state/projectStore" import useUpdateProjectConnectors from "@/hooks/update/useUpdateProjectConnectors" import useProjectConnectors from "@/hooks/get/useProjectConnectors" import { toast } from "sonner" +import Image from 'next/image'; export const verticals = categoriesVerticals as string[]; @@ -133,7 +134,13 @@ export function CatalogWidget() {
- + {`${item.name}
{`${item.name.substring(0, 1).toUpperCase()}${item.name.substring(1)}`}
diff --git a/apps/webapp/src/components/Connection/columns.tsx b/apps/webapp/src/components/Connection/columns.tsx index 48167a0e4..db7e731eb 100644 --- a/apps/webapp/src/components/Connection/columns.tsx +++ b/apps/webapp/src/components/Connection/columns.tsx @@ -27,6 +27,7 @@ import { } from "@/components/ui/dialog" import { Input } from "@/components/ui/input" import useResync from "@/hooks/create/useResync" +import Image from 'next/image'; const formatDate = (dateString: string) => { const date = new Date(dateString); @@ -217,7 +218,13 @@ const Customizer = ({
- + {`${name}
{`${name.substring(0, 1).toUpperCase()}${name.substring(1)}`} {authStrategy} @@ -279,6 +286,97 @@ const Customizer = ({ ) } +const ConnectionActionsCell = ({ row }: { row: any }) => { + const { resyncPromise } = useResync(); + const [dialogOpen, setDialogOpen] = useState(false); + const [confirmText, setConfirmText] = useState(''); + + const handleResync = async () => { + try { + toast.promise( + resyncPromise({ + vertical: row.getValue("vertical"), + provider: row.getValue("app"), + linkedUserId: row.getValue("linkedUser") + }), + { + loading: 'Syncing...', + success: 'Sync initiated successfully', + error: 'Failed to sync' + } + ); + } catch (error) { + console.error('Failed to resync:', error); + } + }; + + const handleDisconnectClick = () => { + setConfirmText(''); + setDialogOpen(true); + }; + + const handleConfirmDisconnect = () => { + if (confirmText.toLowerCase() === 'delete') { + // TODO: Implement disconnect logic here + toast.success('Connection deleted successfully'); + setDialogOpen(false); + } + }; + + return ( + <> + + + + Confirm Connection Deletion + + This will permanently delete the integration for {row.getValue("app")}. To confirm, please type "delete" below. + + + setConfirmText(e.target.value)} + placeholder="Type 'delete' to confirm" + /> + + + + + + + + + + + + + + + Resync + + + + Delete + + + + + ); +}; + export const columns: ColumnDef[] = [ { accessorKey: "app", @@ -290,8 +388,13 @@ export const columns: ColumnDef[] = [ return (
- + {`${provider} {provider}
@@ -352,97 +455,6 @@ export const columns: ColumnDef[] = [ header: ({ column }) => ( '' ), - cell: ({ row }) => { - const { resyncPromise } = useResync(); - const [dialogOpen, setDialogOpen] = useState(false); - const [confirmText, setConfirmText] = useState(''); - - const handleResync = async () => { - try { - toast.promise( - resyncPromise({ - vertical: row.getValue("vertical"), - provider: row.getValue("app"), - linkedUserId: row.getValue("linkedUser") - }), - { - loading: 'Syncing...', - success: 'Sync initiated successfully', - error: 'Failed to sync' - } - ); - } catch (error) { - console.error('Failed to resync:', error); - } - }; - - const handleDisconnectClick = () => { - setConfirmText(''); - setDialogOpen(true); - }; - - const handleConfirmDisconnect = () => { - if (confirmText.toLowerCase() === 'delete') { - // TODO: Implement disconnect logic here - toast.success('Connection deleted successfully'); - setDialogOpen(false); - } - }; - - return ( - <> - - - - Confirm Connection Deletion - - This will permanently delete the integration for {row.getValue("app")}. To confirm, please type "delete" below. - - - setConfirmText(e.target.value)} - placeholder="Type 'delete' to confirm" - /> - - - - - - - - - - - - - - Resync - - - - Delete - - - - - ) - }, - filterFn: (row, id, value) => { - return value.includes(row.getValue(id)) - }, + cell: ({ row }) => } ]; \ No newline at end of file diff --git a/apps/webapp/src/components/Events/columns.tsx b/apps/webapp/src/components/Events/columns.tsx index 373a75eaa..13d42d563 100644 --- a/apps/webapp/src/components/Events/columns.tsx +++ b/apps/webapp/src/components/Events/columns.tsx @@ -7,6 +7,7 @@ import { Event } from "./schema" import { getLogoURL } from "@panora/shared" import { formatISODate } from "@/lib/utils" import { toast } from "sonner" +import Image from 'next/image'; const formatDate = (dateString: string) => { const date = new Date(dateString); @@ -161,7 +162,12 @@ export const columns: ColumnDef[] = [ return (
- {`${provider} {provider}