Skip to content

Commit

Permalink
page sub changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramchike committed Nov 15, 2024
1 parent 0f93ded commit 4014afd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
8 changes: 4 additions & 4 deletions frontend/src/app/providers/userProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ export default function UserProvider({ children }: IChildren) {
.then(setUser)
.catch(
(error: AxiosError) => {
console.log(error)
if (error.response?.data) {
const statusCode = (error.response.data as {code: number}).code.toString()
console.log(statusCode)
if (statusCode == '3004') {
setSub(false)
setLink(error.response.headers['X-channel'])
}
else {
setUser(null)
}
}
setUser(null)
})
}

Expand All @@ -50,8 +51,7 @@ export default function UserProvider({ children }: IChildren) {

if (!isSub) {
return <ChannelPage link={link}/>
}
return (
} else return (
<UserContext.Provider value={{ user, updateUser, setUser }}>
{children}
</UserContext.Provider>
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/pages/auth/ui/style.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,11 @@
}
}

.sub-button-list {
width: 100%;
display: flex;
align-items: center;
justify-content: center;
gap: 12px;
}

13 changes: 9 additions & 4 deletions frontend/src/pages/auth/ui/sub.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Button, Text } from "@gravity-ui/uikit"
import { Button, Icon, Text } from "@gravity-ui/uikit"
import styles from './style.module.scss'
import { useContext } from "react"
import { UserContext } from "../../../app/providers"
import { LogoTelegram } from "@gravity-ui/icons"

interface Props {
link: string
Expand All @@ -11,8 +12,12 @@ export function ChannelPage({link}: Props) {
const {updateUser} = useContext(UserContext)

return <main className={styles['main']}>
<Text variant="header-1">Вы не подписаны на Подслушано 2107 🐝</Text>
<Button onClick={() => Telegram.WebApp.openTelegramLink(link)}>Подписаться</Button>
<Button onClick={updateUser}>Обновить</Button>
<div className={styles['sub-container']}>
<Text variant="header-1">Вы не подписаны на Подслушано 2107 🐝</Text>
<div className={styles['sub-button-list']}>
<Button view="action" onClick={() => Telegram.WebApp.openTelegramLink(link)}>Подслушано 2107 <Icon data={LogoTelegram}/></Button>
<Button onClick={updateUser}>Обновить</Button>
</div>
</div>
</main>
}

0 comments on commit 4014afd

Please sign in to comment.