Added snackbars to subscription and copy link in the share popup
This commit is contained in:
parent
15e57950fe
commit
6871b1a146
|
@ -52,6 +52,7 @@
|
|||
"Cooperate": "Cooperate",
|
||||
"Copy": "Copy",
|
||||
"Copy link": "Copy link",
|
||||
"Link copied": "Link copied",
|
||||
"Corrections history": "Corrections history",
|
||||
"Create Chat": "Create Chat",
|
||||
"Create Group": "Create a group",
|
||||
|
@ -245,6 +246,7 @@
|
|||
"Terms of use": "Site rules",
|
||||
"Text checking": "Text checking",
|
||||
"Thank you": "Thank you",
|
||||
"Thank you for subscribing": "Thank you for subscribing",
|
||||
"This comment has not yet been rated": "This comment has not yet been rated",
|
||||
"This email is already taken. If it's you": "This email is already taken. If it's you",
|
||||
"This functionality is currently not available, we would like to work on this issue. Use the download link.": "This functionality is currently not available, we would like to work on this issue. Use the download link.",
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
"Cooperate": "Соучаствовать",
|
||||
"Copy": "Скопировать",
|
||||
"Copy link": "Скопировать ссылку",
|
||||
"Link copied": "Ссылка скопирована",
|
||||
"Corrections history": "История правок",
|
||||
"Create Chat": "Создать чат",
|
||||
"Create Group": "Создать группу",
|
||||
|
@ -259,6 +260,7 @@
|
|||
"Terms of use": "Правила сайта",
|
||||
"Text checking": "Проверка текста",
|
||||
"Thank you": "Благодарности",
|
||||
"Thank you for subscribing": "Спасибо, что подписались на рассылку",
|
||||
"This comment has not yet been rated": "Этот комментарий еще пока никто не оценил",
|
||||
"This email is already taken. If it's you": "Такой email уже зарегистрирован. Если это вы",
|
||||
"This functionality is currently not available, we would like to work on this issue. Use the download link.": "В данный момент этот функционал недоступен, мы работаем над этой проблемой. Воспользуйтесь загрузкой по ссылке.",
|
||||
|
|
|
@ -6,6 +6,7 @@ import type { PopupProps } from '../_shared/Popup'
|
|||
import { Popup } from '../_shared/Popup'
|
||||
import { useLocalize } from '../../context/localize'
|
||||
import { createEffect, createSignal } from 'solid-js'
|
||||
import { useSnackbar } from '../../context/snackbar'
|
||||
|
||||
type SharePopupProps = {
|
||||
title: string
|
||||
|
@ -24,6 +25,9 @@ export const getShareUrl = (params: { pathname?: string } = {}) => {
|
|||
export const SharePopup = (props: SharePopupProps) => {
|
||||
const { t } = useLocalize()
|
||||
const [isVisible, setIsVisible] = createSignal(false)
|
||||
const {
|
||||
actions: { showSnackbar }
|
||||
} = useSnackbar()
|
||||
|
||||
createEffect(() => {
|
||||
if (props.isVisible) {
|
||||
|
@ -36,8 +40,10 @@ export const SharePopup = (props: SharePopupProps) => {
|
|||
url: props.shareUrl,
|
||||
description: props.description
|
||||
}))
|
||||
|
||||
const copyLink = async () => {
|
||||
await navigator.clipboard.writeText(props.shareUrl)
|
||||
showSnackbar({ body: t('Link copied') })
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
@ -5,6 +5,7 @@ import { isValidEmail } from '../../utils/validators'
|
|||
import { Button } from '../_shared/Button'
|
||||
|
||||
import styles from './Subscribe.module.scss'
|
||||
import { useSnackbar } from '../../context/snackbar'
|
||||
|
||||
export default () => {
|
||||
const { t } = useLocalize()
|
||||
|
@ -12,6 +13,9 @@ export default () => {
|
|||
const [title, setTitle] = createSignal('')
|
||||
const [email, setEmail] = createSignal('')
|
||||
const [emailError, setEmailError] = createSignal<string>(null)
|
||||
const {
|
||||
actions: { showSnackbar }
|
||||
} = useSnackbar()
|
||||
|
||||
const validate = (): boolean => {
|
||||
if (!email()) {
|
||||
|
@ -52,6 +56,7 @@ export default () => {
|
|||
|
||||
if (response.ok) {
|
||||
setTitle(t('You are subscribed'))
|
||||
showSnackbar({ body: t('Thank you for subscribing') })
|
||||
} else {
|
||||
if (response.status === 400) {
|
||||
setEmailError(t('Please check your email address'))
|
||||
|
|
Loading…
Reference in New Issue
Block a user