landing
This commit is contained in:
@@ -81,6 +81,21 @@ export default function Signup() {
|
|||||||
setError('')
|
setError('')
|
||||||
|
|
||||||
// Validation
|
// Validation
|
||||||
|
if (!formData.businessName.trim()) {
|
||||||
|
setError('Please enter your business name')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (formData.slug.length < 3) {
|
||||||
|
setError('URL slug must be at least 3 characters')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slugAvailable === false) {
|
||||||
|
setError('This URL is already taken. Please choose another.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (formData.password !== formData.confirmPassword) {
|
if (formData.password !== formData.confirmPassword) {
|
||||||
setError('Passwords do not match')
|
setError('Passwords do not match')
|
||||||
return
|
return
|
||||||
@@ -91,18 +106,25 @@ export default function Signup() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!slugAvailable) {
|
|
||||||
setError('Please choose a different URL slug')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (formData.slug.length < 3) {
|
|
||||||
setError('URL slug must be at least 3 characters')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
|
||||||
|
// Double-check slug availability before creating
|
||||||
|
try {
|
||||||
|
const response = await databases.listDocuments(
|
||||||
|
DATABASE_ID,
|
||||||
|
COLLECTIONS.CLIENTS,
|
||||||
|
[Query.equal('slug', formData.slug)]
|
||||||
|
)
|
||||||
|
if (response.documents.length > 0) {
|
||||||
|
setError('This URL was just taken. Please choose another.')
|
||||||
|
setSlugAvailable(false)
|
||||||
|
setLoading(false)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
// Continue with creation if check fails
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Create client record
|
// Create client record
|
||||||
const clientId = generateId()
|
const clientId = generateId()
|
||||||
@@ -396,7 +418,7 @@ export default function Signup() {
|
|||||||
{/* Submit Button */}
|
{/* Submit Button */}
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={loading || !slugAvailable}
|
disabled={loading || slugAvailable === false}
|
||||||
className="w-full py-4 bg-gradient-to-r from-blue-500 to-purple-600 text-white rounded-xl font-semibold hover:shadow-lg hover:shadow-purple-500/25 transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2"
|
className="w-full py-4 bg-gradient-to-r from-blue-500 to-purple-600 text-white rounded-xl font-semibold hover:shadow-lg hover:shadow-purple-500/25 transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2"
|
||||||
>
|
>
|
||||||
{loading ? (
|
{loading ? (
|
||||||
|
|||||||
Reference in New Issue
Block a user