Skip to content

Commit

Permalink
requested changes for update logic
Browse files Browse the repository at this point in the history
  • Loading branch information
JNicolao committed Oct 30, 2024
1 parent 5a9fae0 commit 06ebe2d
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions components/sessions/SpeakersDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'react-responsive-carousel/lib/styles/carousel.min.css'

export const SpeakersDetails = ({ session }: { session: Session }) => {
const [showChild, setShowChild] = useState(false)

useEffect(() => {
setShowChild(true)
}, [])
Expand All @@ -15,15 +16,12 @@ export const SpeakersDetails = ({ session }: { session: Session }) => {
return null
}

const getTwitterUsername = (url: string) => {
if (url.includes('twitter.com/')) {
return url.split('twitter.com/')[1]
}
if (url.includes('x.com/')) {
return url.split('x.com/')[1]
}
return null
const getTwitterUsername = (url: string): string | null => {
if (!url) return null
const match = url.match(/(?:twitter\.com|x\.com)\/([^/?#]+)/i)
return match?.[1] ?? null
}

return (
<div className="w-full flex-wrap lg:w-4/12 flex border-r-0 pr-0 lg:pr-4 mb-6 md:mb-0">
<div className="w-full py-4">
Expand Down Expand Up @@ -72,9 +70,8 @@ export const SpeakersDetails = ({ session }: { session: Session }) => {
className="text-primary dark:text-accent text-sm lowercase font-medium"
>
@
{speaker.twitter
? getTwitterUsername(speaker.twitter)
: speaker.name}
{getTwitterUsername(speaker.twitter ?? '') ||
speaker.name}
</a>
</a>
</p>
Expand Down

0 comments on commit 06ebe2d

Please sign in to comment.