Skip to content

Commit

Permalink
fix: frontend build
Browse files Browse the repository at this point in the history
  • Loading branch information
rflihxyz committed Dec 23, 2024
1 parent 31f8bb3 commit 89b0e7b
Show file tree
Hide file tree
Showing 7 changed files with 218 additions and 183 deletions.
10 changes: 6 additions & 4 deletions apps/webapp/src/app/(Dashboard)/configuration/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default function Page() {
}, {} as Record<string, string>);
setLocalFrequencies(initialFrequencies);
}
}, [pullFrequencies]);
}, [pullFrequencies, VERTICALS]);

const handleFrequencyChange = (vertical: string, value: string) => {
setLocalFrequencies(prev => ({ ...prev, [vertical]: value }));
Expand Down Expand Up @@ -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);
}
Expand All @@ -187,7 +189,7 @@ export default function Page() {
<DialogHeader>
<DialogTitle>Confirm Sync Suspension</DialogTitle>
<DialogDescription>
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 &quot;suspend&quot; below.
</DialogDescription>
</DialogHeader>
<Input
Expand Down
20 changes: 10 additions & 10 deletions apps/webapp/src/app/b2c/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,21 @@ export default function Page() {
{
router.replace('/connections');
}

},[profile]);
},[profile, router]);

useEffect(() => {

if(!Cookies.get('access_token'))
{
setUserInitialized(false);
}
{
setUserInitialized(false);
}

if(Cookies.get('access_token') && !profile)
{
mutate(Cookies.get('access_token'),{
onError: () => setUserInitialized(false)
})
}

},[])
},[profile, mutate])

if (!mounted) {
return null;
Expand Down Expand Up @@ -107,12 +104,15 @@ export default function Page() {
</div>
<div className="space-y-4">
<p className="text-muted-foreground">
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 &amp; ERPs. Add revenue, not complexity to your operations.
</p>
<p className="text-muted-foreground">
Use one unified API to manage orders across Shopify, Amazon, and more. Let AI handle your inventory updates while you focus on growth.
</p>
<p className="text-muted-foreground">You'll wonder how you ever managed without it.</p>
<p className="text-muted-foreground">You&apos;ll wonder how you ever managed without it.</p>
<p className="text-sm text-muted-foreground">
Don&apos;t have an account? Create one now
</p>
</div>
</div>
</div>
Expand Down
145 changes: 74 additions & 71 deletions apps/webapp/src/components/ApiKeys/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
<Button
variant="ghost"
className="flex h-8 w-8 p-0 data-[state=open]:bg-muted"
onClick={() => setDialogOpen(true)}
>
<TrashIcon className="h-4 w-4 text-destructive" />
<span className="sr-only">Delete API key</span>
</Button>

<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
<DialogContent>
<DialogHeader>
<DialogTitle>Confirm API Key Deletion</DialogTitle>
<DialogDescription>
This will permanently delete this API key. To confirm, please type &quot;delete&quot; below.
</DialogDescription>
</DialogHeader>
<Input
value={confirmText}
onChange={(e) => setConfirmText(e.target.value)}
placeholder="Type 'delete' to confirm"
/>
<DialogFooter>
<Button
variant="ghost"
onClick={() => setDialogOpen(false)}
>
Cancel
</Button>
<Button
variant="destructive"
onClick={handleDelete}
disabled={confirmText.toLowerCase() !== 'delete'}
>
Delete API Key
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</>
);
};

export function useColumns() {
return [
{
Expand All @@ -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 (
<>
<Button
variant="ghost"
className="flex h-8 w-8 p-0 data-[state=open]:bg-muted"
onClick={() => setDialogOpen(true)}
>
<TrashIcon className="h-4 w-4 text-destructive" />
<span className="sr-only">Delete API key</span>
</Button>

<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
<DialogContent>
<DialogHeader>
<DialogTitle>Confirm API Key Deletion</DialogTitle>
<DialogDescription>
This will permanently delete this API key. To confirm, please type "delete" below.
</DialogDescription>
</DialogHeader>
<Input
value={confirmText}
onChange={(e) => setConfirmText(e.target.value)}
placeholder="Type 'delete' to confirm"
/>
<DialogFooter>
<Button
variant="ghost"
onClick={() => setDialogOpen(false)}
>
Cancel
</Button>
<Button
variant="destructive"
onClick={handleDelete}
disabled={confirmText.toLowerCase() !== 'delete'}
>
Delete API Key
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</>
);
},
cell: ({ row }) => <DeleteApiKeyCell row={row} />,
},
] as ColumnDef<ApiKey>[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -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!');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[];

Expand Down Expand Up @@ -133,7 +134,13 @@ export function CatalogWidget() {
<div className="flex w-full items-start justify-between">
<div className="flex flex-col gap-1">
<div className="flex items-center gap-2">
<img src={item.logoPath} className="w-8 h-8 rounded-lg" />
<Image
src={item.logoPath}
width={20}
height={20}
className="rounded-sm mr-2"
alt={`${item.name} logo`}
/>
<div className="font-semibold">{`${item.name.substring(0, 1).toUpperCase()}${item.name.substring(1)}`}</div>
</div>
<div className="line-clamp-2 text-xs text-muted-foreground">
Expand Down
Loading

0 comments on commit 89b0e7b

Please sign in to comment.