webapp/src/components/AuthModal/AuthModalHeader/AuthModalHeader.tsx

86 lines
2.4 KiB
TypeScript
Raw Normal View History

2024-06-24 17:50:27 +00:00
import { useSearchParams } from '@solidjs/router'
import { Show } from 'solid-js'
2024-07-05 13:34:19 +00:00
import { useLocalize } from '~/context/localize'
import styles from './AuthModalHeader.module.scss'
type Props = {
modalType: 'login' | 'register'
}
export const AuthModalHeader = (props: Props) => {
const { t } = useLocalize()
2024-06-24 17:50:27 +00:00
const [searchParams] = useSearchParams<{ source: string }>()
const generateModalTextsFromSource = (
2024-06-26 08:22:05 +00:00
modalType: 'login' | 'register'
): { title: string; description: string } => {
2024-07-03 17:38:43 +00:00
const title = modalType === 'login' ? 'Welcome to Discours' : 'Sign up'
2024-06-24 17:50:27 +00:00
switch (searchParams?.source) {
2023-08-13 12:27:30 +00:00
case 'create': {
return {
title: t(`${title} to publish articles`),
2024-06-26 08:22:05 +00:00
description: ''
2023-08-13 12:27:30 +00:00
}
}
case 'bookmark': {
return {
title: t(`${title} to add to your bookmarks`),
description: t(
2024-07-05 19:40:54 +00:00
'In bookmarks, you can save favorite discussions and materials that you want to return to'
2024-06-26 08:22:05 +00:00
)
}
}
case 'discussions': {
return {
title: t(`${title} to participate in discussions`),
description: t(
2024-07-05 19:40:54 +00:00
"You ll be able to participate in discussions, rate others' comments and learn about new responses"
2024-06-26 08:22:05 +00:00
)
}
}
case 'follow': {
return {
title: t(`${title} to subscribe`),
description: t(
2024-07-05 19:40:54 +00:00
'This way you ll be able to subscribe to authors, interesting topics and customize your feed'
2024-06-26 08:22:05 +00:00
)
}
}
case 'subscribe': {
return {
title: t(`${title} to subscribe to new publications`),
description: t(
2024-07-05 19:40:54 +00:00
'This way you ll be able to subscribe to authors, interesting topics and customize your feed'
2024-06-26 08:22:05 +00:00
)
}
}
case 'vote': {
return {
title: t(`${title} to vote`),
description: t(
2024-07-05 19:40:54 +00:00
'This way we ll realize that you re a real person and ll take your vote into account. And you ll see how others voted'
2024-06-26 08:22:05 +00:00
)
}
}
default: {
return {
title: t(title),
2024-06-26 08:22:05 +00:00
description: ''
}
}
}
}
const { title, description } = generateModalTextsFromSource(props.modalType)
return (
<>
2023-09-27 21:28:32 +00:00
<h4 class={styles.authFormHeader}>{title}</h4>
<Show when={description}>
<p class={styles.authFormDescription} innerHTML={description} />
</Show>
</>
)
}