diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx
new file mode 100644
index 0000000..7e3a280
--- /dev/null
+++ b/src/pages/_app.tsx
@@ -0,0 +1,10 @@
+// src/pages/_app.tsx
+
+import type { AppProps } from 'next/app';
+import '../../styles/globals.css';
+
+function MyApp({ Component, pageProps }: AppProps) {
+ return ;
+}
+
+export default MyApp;
diff --git a/src/pages/index.tsx b/src/pages/index.tsx
index aeb42a6..900c352 100644
--- a/src/pages/index.tsx
+++ b/src/pages/index.tsx
@@ -9,6 +9,7 @@ const HomePage = () => {
const handleSubmit = async (e: { preventDefault: () => void; }) => {
e.preventDefault();
+ setTinyUrl('');
setError('');
try {
const response = await fetch('http://localhost:3000/url-shortener/shorten', {
@@ -21,7 +22,7 @@ const HomePage = () => {
const data = await response.json();
if (response.ok && data.status === 201) {
- setTinyUrl(data.data); // Just store the tiny URL part
+ setTinyUrl(data.data);
} else {
setError(data.error || 'An error occurred while shortening the URL');
}
@@ -31,29 +32,31 @@ const HomePage = () => {
};
return (
-
-
Shorten Your URL
-
- {tinyUrl && (
-
- Shortened URL:
-
- {tinyUrl}
-
-
- )}
- {error &&
{error}
}
+
+
+
Shorten Your URL
+
+ {tinyUrl && (
+
+ Shortened URL:
+
+ {tinyUrl}
+
+
+ )}
+ {error &&
{error}
}
+
);
};
diff --git a/styles/globals.css b/styles/globals.css
new file mode 100644
index 0000000..bd6213e
--- /dev/null
+++ b/styles/globals.css
@@ -0,0 +1,3 @@
+@tailwind base;
+@tailwind components;
+@tailwind utilities;
\ No newline at end of file