2023-07-30 12:31:54 +00:00
|
|
|
import { Show } from 'solid-js'
|
2023-11-14 15:10:00 +00:00
|
|
|
|
2023-07-30 12:31:54 +00:00
|
|
|
import { useLocalize } from '../../../../context/localize'
|
|
|
|
import { useRouter } from '../../../../stores/router'
|
|
|
|
import { AuthModalSearchParams } from '../types'
|
|
|
|
|
2023-11-14 15:10:00 +00:00
|
|
|
import styles from './AuthModalHeader.module.scss'
|
|
|
|
|
2023-07-30 12:31:54 +00:00
|
|
|
type Props = {
|
|
|
|
modalType: 'login' | 'register'
|
|
|
|
}
|
|
|
|
|
|
|
|
export const AuthModalHeader = (props: Props) => {
|
|
|
|
const { t } = useLocalize()
|
|
|
|
const { searchParams } = useRouter<AuthModalSearchParams>()
|
|
|
|
const { source } = searchParams()
|
|
|
|
|
|
|
|
const generateModalTextsFromSource = (
|
2023-11-14 15:10:00 +00:00
|
|
|
modalType: 'login' | 'register',
|
2023-07-30 12:31:54 +00:00
|
|
|
): { title: string; description: string } => {
|
2023-10-16 09:54:14 +00:00
|
|
|
const title = modalType === 'login' ? 'Welcome to Discours' : 'Create account'
|
2023-07-30 12:31:54 +00:00
|
|
|
|
|
|
|
switch (source) {
|
2023-08-13 12:27:30 +00:00
|
|
|
case 'create': {
|
|
|
|
return {
|
|
|
|
title: t(`${title} to publish articles`),
|
2023-11-14 15:10:00 +00:00
|
|
|
description: '',
|
2023-08-13 12:27:30 +00:00
|
|
|
}
|
|
|
|
}
|
2023-07-30 12:31:54 +00:00
|
|
|
case 'bookmark': {
|
|
|
|
return {
|
|
|
|
title: t(`${title} to add to your bookmarks`),
|
|
|
|
description: t(
|
2023-11-14 15:10:00 +00:00
|
|
|
'In bookmarks, you can save favorite discussions and materials that you want to return to',
|
|
|
|
),
|
2023-07-30 12:31:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case 'discussions': {
|
|
|
|
return {
|
|
|
|
title: t(`${title} to participate in discussions`),
|
|
|
|
description: t(
|
2023-11-14 15:10:00 +00:00
|
|
|
"You ll be able to participate in discussions, rate others' comments and learn about new responses",
|
|
|
|
),
|
2023-07-30 12:31:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case 'follow': {
|
|
|
|
return {
|
|
|
|
title: t(`${title} to subscribe`),
|
|
|
|
description: t(
|
2023-11-14 15:10:00 +00:00
|
|
|
'This way you ll be able to subscribe to authors, interesting topics and customize your feed',
|
|
|
|
),
|
2023-07-30 12:31:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case 'subscribe': {
|
|
|
|
return {
|
|
|
|
title: t(`${title} to subscribe to new publications`),
|
|
|
|
description: t(
|
2023-11-14 15:10:00 +00:00
|
|
|
'This way you ll be able to subscribe to authors, interesting topics and customize your feed',
|
|
|
|
),
|
2023-07-30 12:31:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case 'vote': {
|
|
|
|
return {
|
|
|
|
title: t(`${title} to vote`),
|
|
|
|
description: t(
|
2023-11-14 15:10:00 +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',
|
|
|
|
),
|
2023-07-30 12:31:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
return {
|
|
|
|
title: t(title),
|
2023-11-14 15:10:00 +00:00
|
|
|
description: '',
|
2023-07-30 12:31:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const { title, description } = generateModalTextsFromSource(props.modalType)
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2023-09-27 21:28:32 +00:00
|
|
|
<h4 class={styles.authFormHeader}>{title}</h4>
|
2023-07-30 12:31:54 +00:00
|
|
|
<Show when={description}>
|
|
|
|
<p class={styles.authFormDescription} innerHTML={description} />
|
|
|
|
</Show>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|