maintopic-limit-hotfix

This commit is contained in:
Untone 2024-02-05 22:05:49 +03:00
parent 7c2f8370b5
commit d39872281e
8 changed files with 25 additions and 8 deletions

View File

@ -1,5 +1,5 @@
{ {
"*.{js,ts,cjs,mjs,d.mts,jsx,tsx,json,jsonc,scss,css}": [ "*.{js,ts,cjs,mjs,d.mts,jsx,tsx,json,jsonc,scss,css}": [
"npm run check" "npx @biomejs/biome check ./src && tsc"
] ]
} }

2
package-lock.json generated
View File

@ -24,7 +24,7 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "7.23.3", "@babel/core": "7.23.3",
"@biomejs/biome": "1.5.3", "@biomejs/biome": "^1.5.3",
"@graphql-codegen/cli": "5.0.0", "@graphql-codegen/cli": "5.0.0",
"@graphql-codegen/typescript": "4.0.1", "@graphql-codegen/typescript": "4.0.1",
"@graphql-codegen/typescript-operations": "4.0.1", "@graphql-codegen/typescript-operations": "4.0.1",

View File

@ -281,6 +281,7 @@
"Please enter password": "Please enter a password", "Please enter password": "Please enter a password",
"Please enter password again": "Please enter password again", "Please enter password again": "Please enter password again",
"Please, confirm email": "Please confirm email", "Please, confirm email": "Please confirm email",
"Please, set the main topic first": "Please, set the main topic first",
"Podcasts": "Podcasts", "Podcasts": "Podcasts",
"Poetry": "Poetry", "Poetry": "Poetry",
"Popular": "Popular", "Popular": "Popular",

View File

@ -295,6 +295,7 @@
"Please enter password": "Пожалуйста, введите пароль", "Please enter password": "Пожалуйста, введите пароль",
"Please enter password again": "Пожалуйста, введите пароль ещё рез", "Please enter password again": "Пожалуйста, введите пароль ещё рез",
"Please, confirm email": "Пожалуйста, подтвердите электронную почту", "Please, confirm email": "Пожалуйста, подтвердите электронную почту",
"Please, set the main topic first": "Пожалуйста, сначала выберите главную тему",
"Podcasts": "Подкасты", "Podcasts": "Подкасты",
"Poetry": "Поэзия", "Poetry": "Поэзия",
"Popular": "Популярное", "Popular": "Популярное",

View File

@ -25,7 +25,11 @@ export const Draft = (props: Props) => {
const handlePublishLinkClick = (e) => { const handlePublishLinkClick = (e) => {
e.preventDefault() e.preventDefault()
props.onPublish(props.shout) if (props.shout.main_topic) {
props.onPublish(props.shout)
} else {
showSnackbar({ body: t('Please, set the main topic first') })
}
} }
const handleDeleteLinkClick = async (e) => { const handleDeleteLinkClick = async (e) => {

View File

@ -14,6 +14,7 @@ import { Button } from '../../_shared/Button'
import { DarkModeToggle } from '../../_shared/DarkModeToggle' import { DarkModeToggle } from '../../_shared/DarkModeToggle'
import { Icon } from '../../_shared/Icon' import { Icon } from '../../_shared/Icon'
import { useSnackbar } from '../../../context/snackbar'
import styles from './Panel.module.scss' import styles from './Panel.module.scss'
const typograf = new Typograf({ locale: ['ru', 'en-US'] }) const typograf = new Typograf({ locale: ['ru', 'en-US'] })
@ -46,9 +47,10 @@ export const Panel = (props: Props) => {
const handleSaveClick = () => { const handleSaveClick = () => {
saveShout(form) saveShout(form)
} }
const { showSnackbar } = useSnackbar()
const handlePublishClick = () => { const handlePublishClick = () => {
publishShout(form) if (form.mainTopic) publishShout(form)
else showSnackbar({ body: t('Please, set the main topic first') })
} }
const html = useEditorHTML(() => editorRef.current()) const html = useEditorHTML(() => editorRef.current())

View File

@ -16,6 +16,7 @@ import { ShowOnlyOnClient } from '../_shared/ShowOnlyOnClient'
import { ProfilePopup } from './ProfilePopup' import { ProfilePopup } from './ProfilePopup'
import { useSnackbar } from '../../context/snackbar'
import styles from './Header/Header.module.scss' import styles from './Header/Header.module.scss'
type Props = { type Props = {
@ -62,9 +63,10 @@ export const HeaderAuth = (props: Props) => {
const handleSaveButtonClick = () => { const handleSaveButtonClick = () => {
saveShout(form) saveShout(form)
} }
const { showSnackbar } = useSnackbar()
const handlePublishButtonClick = () => { const handlePublishButtonClick = () => {
publishShout(form) if (form.mainTopic) publishShout(form)
else showSnackbar({ body: t('Please, set the main topic first') })
} }
const [width, setWidth] = createSignal(0) const [width, setWidth] = createSignal(0)

View File

@ -17,6 +17,7 @@ import { Button } from '../../_shared/Button'
import { Icon } from '../../_shared/Icon' import { Icon } from '../../_shared/Icon'
import { Image } from '../../_shared/Image' import { Image } from '../../_shared/Image'
import { useSnackbar } from '../../../context/snackbar'
import stylesBeside from '../../Feed/Beside.module.scss' import stylesBeside from '../../Feed/Beside.module.scss'
import styles from './PublishSettings.module.scss' import styles from './PublishSettings.module.scss'
@ -53,6 +54,7 @@ export const PublishSettings = (props: Props) => {
const { t } = useLocalize() const { t } = useLocalize()
const { author } = useSession() const { author } = useSession()
const { sortedTopics } = useTopicsStore() const { sortedTopics } = useTopicsStore()
const { showSnackbar } = useSnackbar()
const [topics, setTopics] = createSignal<Topic[]>(sortedTopics()) const [topics, setTopics] = createSignal<Topic[]>(sortedTopics())
const composeDescription = () => { const composeDescription = () => {
@ -124,7 +126,12 @@ export const PublishSettings = (props: Props) => {
handleBackClick() handleBackClick()
} }
const handlePublishSubmit = () => { const handlePublishSubmit = () => {
publishShout({ ...props.form, ...settingsForm }) const shoutData = { ...props.form, ...settingsForm }
if (!shoutData?.mainTopic) {
showSnackbar({ body: t('Please, set the main topic first') })
} else {
publishShout(shoutData)
}
} }
const handleSaveDraft = () => { const handleSaveDraft = () => {
saveShout({ ...props.form, ...settingsForm }) saveShout({ ...props.form, ...settingsForm })