diff --git a/src/app/[username]/page.js b/src/app/[username]/page.js index 1e0be97..cc5ba78 100644 --- a/src/app/[username]/page.js +++ b/src/app/[username]/page.js @@ -43,6 +43,12 @@ function HomePage({ params }) { const [showCreatorOptions, setShowCreatorOptions] = useState(false); const [hoveredOption, setHoveredOption] = useState(null); const [status, setStatus] = useState(''); + const [discord, setDiscord] = useState(''); + const [selectedSocialLink, setSelectedSocialLink] = useState(''); + const [link, setLink] = useState(''); + const [guestdiscord, setGuestDiscord] = useState(''); + const [guestselectedSocialLink, setGuestSelectedSocialLink] = useState(''); + const [guestlink, setGuestLink] = useState(''); const apikey = process.env.NEXT_PUBLIC_MORALIS_API_KEY; const baseUri = process.env.NEXT_PUBLIC_URI || 'https://app.myriadflow.com'; @@ -106,6 +112,9 @@ function HomePage({ params }) { setGuestX(data.x); setGuestInstagram(data.instagram); setGuestWalletAddress(data.wallet_address); + setGuestDiscord(data.discord); + setGuestSelectedSocialLink(data.selected_social_link); + setGuestLink(data.link); } else { console.log('No user found'); } @@ -139,6 +148,9 @@ function HomePage({ params }) { setX(data.x); setInstagram(data.instagram); setBaseName(data.basename); + setDiscord(data.discord); + setSelectedSocialLink(data.selected_social_link); + setLink(data.link); } else { console.log('No user found'); } @@ -519,6 +531,51 @@ function HomePage({ params }) { Instagram )} + {discord && ( + + Instagram + + )} + {selectedSocialLink === "youtube" && link && ( + + Instagram + + )} + {selectedSocialLink === "telegram" && link && ( + + Instagram + + )} + {selectedSocialLink === "linkedin" && link && ( + + Instagram + + )} + {selectedSocialLink === "whatsapp" && link && ( + + Instagram + + )} + {selectedSocialLink === "google" && link && ( + + Instagram + + )} + {selectedSocialLink === "tiktok" && link && ( + + Instagram + + )} + {selectedSocialLink === "snapchat" && link && ( + + Instagram + + )} + {selectedSocialLink === "pinterest" && link && ( + + Instagram + + )}
@@ -863,6 +920,51 @@ function HomePage({ params }) { Instagram )} + {guestdiscord && ( + + Instagram + + )} + {guestselectedSocialLink === "youtube" && guestlink && ( + + Instagram + + )} + {guestselectedSocialLink === "telegram" && guestlink && ( + + Instagram + + )} + {guestselectedSocialLink === "linkedin" && guestlink && ( + + Instagram + + )} + {guestselectedSocialLink === "whatsapp" && guestlink && ( + + Instagram + + )} + {guestselectedSocialLink === "google" && guestlink && ( + + Instagram + + )} + {guestselectedSocialLink === "tiktok" && guestlink && ( + + Instagram + + )} + {guestselectedSocialLink === "snapchat" && guestlink && ( + + Instagram + + )} + {guestselectedSocialLink === "pinterest" && guestlink && ( + + Instagram + + )}
diff --git a/src/app/elevate-africa/page.tsx b/src/app/elevate-africa/page.tsx index 2b106c7..da24809 100644 --- a/src/app/elevate-africa/page.tsx +++ b/src/app/elevate-africa/page.tsx @@ -38,6 +38,7 @@ export default function Home() { const [email, setEmail] = useState('') const [tosChecked, setTosChecked] = useState(false) const [newsletterChecked, setNewsletterChecked] = useState(false) + const [allusernames, setAllUsernames] = useState([]); const baseUri = process.env.NEXT_PUBLIC_URI || 'https://app.myriadflow.com' @@ -76,6 +77,35 @@ export default function Home() { checkEmailExists() }, [address]) + useEffect(() => { + if (address) { + const getAllProfile = async () => { + try { + const usernameData = await fetch(`${baseUri}/profiles/all`, { + method: "GET", + headers: { + 'Content-Type': 'application/json', + }, + }); + + if (usernameData.ok) { + const usernamedata = await usernameData.json(); + setAllUsernames(usernamedata); + } + } catch (error) { + console.error('Error fetching address data', error); + } + }; + + getAllProfile(); + } + }, [address]) + + interface Profile { + username: string; + } + const allusername: Profile[] = allusernames; + const handleSubmit = async () => { if (userName.length < 4) { setValidationError('Username must be at least 4 characters long.') @@ -86,7 +116,13 @@ export default function Home() { } else if (userName.includes(' ')) { setValidationError('Username cannot contain spaces.') return - } else { + } else if (allusername.some(profile => profile.username === userName)) { + setValidationError('This username is already taken.'); + return; + } else if (!/^[a-z]+$/.test(userName)) { + setValidationError('Username can only contain letters (no special characters).'); + return; + } else { setValidationError('') } diff --git a/src/app/page.tsx b/src/app/page.tsx index b18afc3..702310b 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -38,6 +38,7 @@ export default function Home() { const [email, setEmail] = useState('') const [tosChecked, setTosChecked] = useState(false) const [newsletterChecked, setNewsletterChecked] = useState(false) + const [allusernames,setAllUsernames] = useState([]); const baseUri = process.env.NEXT_PUBLIC_URI || 'https://app.myriadflow.com' @@ -76,6 +77,35 @@ export default function Home() { checkEmailExists() }, [address]) + useEffect(() => { + if (address) { + const getAllProfile = async () => { + try { + const usernameData = await fetch(`${baseUri}/profiles/all`, { + method: "GET", + headers: { + 'Content-Type': 'application/json', + }, + }); + + if (usernameData.ok) { + const usernamedata = await usernameData.json(); + setAllUsernames(usernamedata); + } + } catch (error) { + console.error('Error fetching address data', error); + } + }; + + getAllProfile(); + } + }, [address]) + + interface Profile { + username: string; + } + const allusername: Profile[] = allusernames; + const handleSubmit = async () => { if (userName.length < 4) { setValidationError('Username must be at least 4 characters long.') @@ -86,7 +116,13 @@ export default function Home() { } else if (userName.includes(' ')) { setValidationError('Username cannot contain spaces.') return - } else { + } else if (allusername.some(profile => profile.username === userName)) { + setValidationError('This username is already taken.'); + return; + } else if (!/^[a-z]+$/.test(userName)) { + setValidationError('Username can only contain letters (no special characters).'); + return; + } else { setValidationError('') } diff --git a/src/app/profile-setting/page.js b/src/app/profile-setting/page.js index f3180ab..f8e206b 100644 --- a/src/app/profile-setting/page.js +++ b/src/app/profile-setting/page.js @@ -17,6 +17,8 @@ function ProfileSettingsPage() { const [website, setWebsite] = useState(''); const [x, setx] = useState(''); const [instagram, setInstagram] = useState(''); + const [discord, setDiscord] = useState(''); + const [allusernames,setAllUsernames] = useState([]); const [coverImage, setCoverImage] = useState(''); const [profileImage, setProfileImage] = useState(''); const [email, setEmail] = useState(''); @@ -118,6 +120,12 @@ function ProfileSettingsPage() { } else if (userName.includes(' ')) { setValidationError('Username cannot contain spaces.'); return; + } else if (allusernames.some(profile => profile.username === userName)) { + setValidationError('This username is already taken.'); + return; + } else if (!/^[a-z]+$/.test(userName)) { + setValidationError('Username can only contain letters (no special characters).'); + return; } else { setValidationError(''); } @@ -130,6 +138,7 @@ function ProfileSettingsPage() { website: website, x: x, instagram: instagram, + discord: discord, cover_image: coverImage, profile_image: profileImage, selected_social_link: selectedSocialLink, @@ -266,6 +275,7 @@ function ProfileSettingsPage() { setWebsite(data.website); setx(data.x); setInstagram(data.instagram); + setDiscord(data.discord); setSelectedSocialLink(data.selected_social_link); setLink(data.link); setEmail(data.email); @@ -304,6 +314,30 @@ function ProfileSettingsPage() { } }, [profileid]) + useEffect(() => { + if (address) { + const getAllProfile = async () => { + try { + const usernameData = await fetch(`${baseUri}/profiles/all`, { + method: "GET", + headers: { + 'Content-Type': 'application/json', + }, + }); + + if (usernameData.ok) { + const usernamedata = await usernameData.json(); + setAllUsernames(usernamedata); + } + } catch (error) { + console.error('Error fetching address data', error); + } + }; + + getAllProfile(); + } + }, [address]) + return ( <>
@@ -541,6 +575,18 @@ function ProfileSettingsPage() { style={{ padding: '10px', borderRadius: '8px', border: '1px solid #D1D5DB', width: '50%', marginBottom: '20px' }} /> + + { + setDiscord(e.target.value); + setIsEditing(true); + }} + style={{ padding: '10px', borderRadius: '8px', border: '1px solid #D1D5DB', width: '50%', marginBottom: '20px' }} + /> + { handleAddressChange(index, 'country', e.target.value); setIsEditing(true); }} style={{ display: 'block', marginBottom: '10px', padding: '10px', borderRadius: '8px', border: '1px solid #D1D5DB' }} - > - - {countries.map((country, i) => ( - - ))} - + />