diff --git a/app/components/AddWebsite.tsx b/app/components/AddWebsite.tsx deleted file mode 100644 index 0caf873..0000000 --- a/app/components/AddWebsite.tsx +++ /dev/null @@ -1,115 +0,0 @@ -'use client' -import { useState } from 'react' -import { PinnedWebsite } from '../types/types' - -export default function AddWebsite() { - const [url, setUrl] = useState('') - const [title, setTitle] = useState('') - const [isAdding, setIsAdding] = useState(false) - - const formatUrl = (inputUrl: string) => { - // Remove leading/trailing whitespace - let formattedUrl = inputUrl.trim() - - // If URL doesn't start with a protocol, add https:// - if (!formattedUrl.match(/^https?:\/\//i)) { - formattedUrl = 'https://' + formattedUrl - } - - return formattedUrl - } - - const handleSubmit = (e: React.FormEvent) => { - e.preventDefault() - - const formattedUrl = formatUrl(url) - - // Validate URL - try { - new URL(formattedUrl) - } catch { - alert('Please enter a valid URL') - return - } - - const newWebsite: PinnedWebsite = { - id: Date.now().toString(), - title: title || formattedUrl, - url: formattedUrl, - addedAt: Date.now() - } - - // Load existing websites - const existingWebsites = JSON.parse(localStorage.getItem('pinnedWebsites') || '[]') - - // Add new website - localStorage.setItem('pinnedWebsites', JSON.stringify([...existingWebsites, newWebsite])) - - // Reset form - setUrl('') - setTitle('') - setIsAdding(false) - - // Reload page to show new website - window.location.reload() - } - - return ( -
- {!isAdding ? ( - - ) : ( -
-
- - setUrl(e.target.value)} - placeholder="example.com" - className="w-full bg-zinc-700 text-white rounded-md border border-gray-600 p-2" - required - /> -

- HTTPS will be added automatically if not provided -

-
-
- - setTitle(e.target.value)} - placeholder="My Website" - className="w-full bg-zinc-700 text-white rounded-md border border-gray-600 p-2" - /> -
-
- - -
-
- )} -
- ) -} \ No newline at end of file