diff --git a/frontend/src/pages/Home.tsx b/frontend/src/pages/Home.tsx index c36325c..0b159ad 100644 --- a/frontend/src/pages/Home.tsx +++ b/frontend/src/pages/Home.tsx @@ -22,7 +22,13 @@ const Home: React.FC = () => { /* methods */ const handleKeyDown = (e: React.KeyboardEvent) => { - if (e.key === 'Enter' && url.trim() !== '') { + if (e.key === 'Enter') { + handleSubmit(); + } + }; + + const handleSubmit = () => { + if (url.trim() !== '') { dispatch(shortenUrl(url)); } }; @@ -35,52 +41,75 @@ const Home: React.FC = () => { } }; + const handleClear = () => { + dispatch(clearShortUrl()) + }; + return ( -
+
+ {/* Top Section (Static Position) */}

minxa.lol

- setUrl(e.target.value)} - onKeyDown={handleKeyDown} - className="w-80 p-3 rounded-md text-lg border border-gray-300 shadow-sm focus:outline-none focus:ring-2 focus:ring-orange-400" - /> +
+ setUrl(e.target.value)} + onKeyDown={handleKeyDown} + className="w-80 p-3 rounded-md text-lg border border-gray-300 shadow-sm focus:outline-none focus:ring-2 focus:ring-orange-400" + /> + +
- {/* Loading State */} {status === 'loading' && (

Shortening your URL...

)} - {/* Error Message */} {status === 'failed' && (

{error}

)} +
- {/* Short URL Display */} - {status === 'succeeded' && shortUrl && ( -
-

- Your short URL: - - {shortUrl} - -

+ {/* Spacer to ensure result doesn't push up the input */} +
+ + {/* Result Section (Appears Below) */} + {status === 'succeeded' && shortUrl && ( +
+

+ Your short URL: + + {shortUrl} + +

+
+
- )} -
+
+ )}
); };