From b304749b21f340e03c94abc0cc91ccf82f559195 Mon Sep 17 00:00:00 2001 From: Anirban Kar Date: Sun, 8 Dec 2024 22:53:20 +0530 Subject: [PATCH 1/5] added backdrop and loading screen --- app/components/git/GitUrlImport.client.tsx | 21 +++++- app/components/ui/LoadingOverlay.tsx | 14 ++++ app/components/ui/Settings.tsx | 75 +++++++++++++--------- app/components/ui/SettingsSlider.tsx | 6 +- 4 files changed, 81 insertions(+), 35 deletions(-) create mode 100644 app/components/ui/LoadingOverlay.tsx diff --git a/app/components/git/GitUrlImport.client.tsx b/app/components/git/GitUrlImport.client.tsx index cbdeaa5..c2c949e 100644 --- a/app/components/git/GitUrlImport.client.tsx +++ b/app/components/git/GitUrlImport.client.tsx @@ -8,6 +8,8 @@ import { Chat } from '~/components/chat/Chat.client'; import { useGit } from '~/lib/hooks/useGit'; import { useChatHistory } from '~/lib/persistence'; import { createCommandsMessage, detectProjectCommands } from '~/utils/projectCommands'; +import { LoadingOverlay } from '~/components/ui/LoadingOverlay'; +import { toast } from 'react-toastify'; const IGNORE_PATTERNS = [ 'node_modules/**', @@ -38,6 +40,7 @@ export function GitUrlImport() { const { ready: historyReady, importChat } = useChatHistory(); const { ready: gitReady, gitClone } = useGit(); const [imported, setImported] = useState(false); + const [loading, setLoading] = useState(true); const importRepo = async (repoUrl?: string) => { if (!gitReady && !historyReady) { @@ -109,9 +112,23 @@ ${file.content} return; } - importRepo(url); + importRepo(url).catch((error) => { + console.error('Error importing repo:', error); + toast.error('Failed to import repository'); + setLoading(false); + window.location.href = '/'; + }); setImported(true); }, [searchParams, historyReady, gitReady, imported]); - return }>{() => }; + return ( + }> + {() => ( + <> + + {loading && } + + )} + + ); } diff --git a/app/components/ui/LoadingOverlay.tsx b/app/components/ui/LoadingOverlay.tsx new file mode 100644 index 0000000..6c69798 --- /dev/null +++ b/app/components/ui/LoadingOverlay.tsx @@ -0,0 +1,14 @@ +export const LoadingOverlay = ({ message = 'Loading...' }) => { + return ( +
+ {/* Loading content */} +
+
+

{message}

+
+
+ ); +}; diff --git a/app/components/ui/Settings.tsx b/app/components/ui/Settings.tsx index 109163d..58295eb 100644 --- a/app/components/ui/Settings.tsx +++ b/app/components/ui/Settings.tsx @@ -10,7 +10,6 @@ import { toast } from 'react-toastify'; import { useNavigate } from '@remix-run/react'; import commit from '~/commit.json'; import Cookies from 'js-cookie'; -import { SettingsSlider } from './SettingsSlider'; import '~/styles/components/SettingsSlider.scss'; import '~/styles/components/Settings.scss'; @@ -219,9 +218,7 @@ export const Settings = ({ open, onClose }: SettingsProps) => {