diff --git a/src/app/me/page.tsx b/src/app/me/page.tsx index ccc453f..723ceee 100644 --- a/src/app/me/page.tsx +++ b/src/app/me/page.tsx @@ -145,7 +145,7 @@ const Login = () => { Discord - +
{
Последний раз кэшировано {formatDate(new Date(data.connections?.minecraft?.last_cached))} - @@ -233,26 +223,12 @@ const Connections = ({ data, refetch }: { data: SettingsResponse, refetch(): voi
: <> -

Привяжите свою учётную запись Minecraft к учетной записи PPLBandage для управления кэшем скинов и настройками видимости - вашего никнейма в поиске.

-

- Зайдите на Minecraft сервер  - { navigator.clipboard?.writeText("oauth.pplbandage.ru"); }}> - oauth.pplbandage.ru -  (версия 1.8-текущая) и получите там 6-значный код.

- -
-
- { - const target = document.getElementById('code') as HTMLInputElement; - if (target.value.length > 6) target.value = target.value.slice(0, 6) - }} /> - -
-

-
+

Подключите свой аккаунт Minecraft, чтобы управлять кэшем скинов и настройками видимости вашего никнейма в поиске.

+ + + }
diff --git a/src/app/modules/components/EditConfirmation.tsx b/src/app/modules/components/EditConfirmation.tsx new file mode 100644 index 0000000..12f1b6b --- /dev/null +++ b/src/app/modules/components/EditConfirmation.tsx @@ -0,0 +1,101 @@ +import { useState } from "react"; +import { CSSTransition } from "react-transition-group" +import style_base from '@/app/styles/minecraftConnect.module.css'; +import style from '@/app/styles/EditConfirmation.module.css'; +import { IconArchive, IconTrash, IconX } from "@tabler/icons-react"; + +interface EditConfirmationProps { + children: JSX.Element, + onInput(): Promise, + confirm_code: string, + action: 'delete' | 'archive' +} + +const EditConfirmation = ({ action, confirm_code, children, onInput }: EditConfirmationProps) => { + const [expanded, setExpanded] = useState(false); + const [available, setAvailable] = useState(false); + + const titles = { + delete: 'Подтвердите удаление', + archive: 'Подтвердите архивацию' + } + + const icons = { + delete: , + archive: + } + + const action_confirm = { + delete: 'Удалить', + archive: 'Архивировать' + } + + return ( + <> +
setExpanded(true)}> + {children} +
+ +
+ + + +
+
+
+

{icons[action]}{titles[action]}

+ setExpanded(false)} /> +
+

Это действие имеет необратимый характер!

+

Для продолжения введите `{confirm_code}` ниже

+ + setAvailable(e.target.value === confirm_code)} /> + + + +

+

+
+
+ + ); +} + +export default EditConfirmation; \ No newline at end of file diff --git a/src/app/modules/components/MeSidebar.tsx b/src/app/modules/components/MeSidebar.tsx index a5ba8c4..9a11522 100644 --- a/src/app/modules/components/MeSidebar.tsx +++ b/src/app/modules/components/MeSidebar.tsx @@ -97,7 +97,7 @@ export const Me = ({ children, user_data }: { children: JSX.Element, user_data?: return (
-
+
{!!data && diff --git a/src/app/modules/components/MinecraftConnect.tsx b/src/app/modules/components/MinecraftConnect.tsx index 574aa40..8e6dfda 100644 --- a/src/app/modules/components/MinecraftConnect.tsx +++ b/src/app/modules/components/MinecraftConnect.tsx @@ -2,14 +2,14 @@ import { useState } from "react"; import { CSSTransition } from "react-transition-group" import style from '@/app/styles/minecraftConnect.module.css'; import { IconBrandMinecraft, IconCheck, IconX } from "@tabler/icons-react"; -import ApiManager from "../utils/apiManager"; interface MinecraftConnectProps { children: JSX.Element, - onInput(code: string): Promise + onInput(code: string): Promise, + login?: boolean } -const MinecraftConnect = ({ children, onInput }: MinecraftConnectProps) => { +const MinecraftConnect = ({ login, children, onInput }: MinecraftConnectProps) => { const [expanded, setExpanded] = useState(false); const selectText = (nodeId: string) => { @@ -23,6 +23,8 @@ const MinecraftConnect = ({ children, onInput }: MinecraftConnectProps) => { } } + const title = login ? 'Войти через Minecraft' : 'Подключить аккаунт Minecraft'; + return ( <>
setExpanded(true)}> @@ -54,10 +56,10 @@ const MinecraftConnect = ({ children, onInput }: MinecraftConnectProps) => {
-

Войти через Minecraft

+

{title}

setExpanded(false)} />
-

Этот способ будет работать, если вы привязали аккаунт Minecraft в личном кабинете.

+ {login &&

Этот способ будет работать, если вы привязали аккаунт Minecraft в личном кабинете.

}

Зайдите на Minecraft сервер ` selectText('oauth_name')}> oauth.pplbandage.ru @@ -80,6 +82,7 @@ const MinecraftConnect = ({ children, onInput }: MinecraftConnectProps) => { if (target.value.length != 6) return; onInput(target.value) + .then(() => setExpanded(false)) .catch(response => { const data = response.data as { message: string }; const err = document.getElementById('error') as HTMLParagraphElement; diff --git a/src/app/modules/utils/apiManager.ts b/src/app/modules/utils/apiManager.ts index 06717b7..0b1c573 100644 --- a/src/app/modules/utils/apiManager.ts +++ b/src/app/modules/utils/apiManager.ts @@ -167,12 +167,12 @@ class ApiManager { } /* Set public profile */ - static async setPublicProfile(params: { state: boolean }): Promise { - return (await this.doRequest({ + static async setPublicProfile(params: { state: boolean }): Promise { + await this.doRequest({ url: `/user/me`, method: 'PATCH', data: { public: params.state } - })).data.new_data; + }); } /* Set user profile theme */ diff --git a/src/app/styles/EditConfirmation.module.css b/src/app/styles/EditConfirmation.module.css new file mode 100644 index 0000000..b8f9fbe --- /dev/null +++ b/src/app/styles/EditConfirmation.module.css @@ -0,0 +1,25 @@ +.button { + color: var(--main-text-color); + background-color: var(--main-card-color); + border-radius: 10px; + border: 1px var(--main-element-color) solid; + height: 2.4rem; + box-sizing: border-box; + cursor: auto; + transition: background-color 250ms, border 150ms; + font-weight: 600; + font-family: inherit; + font-size: 1rem; + display: flex; + align-items: center; + flex-direction: row; + justify-content: center; +} + +.available { + cursor: pointer; +} + +.available:hover { + background-color: #ED4245; +} \ No newline at end of file diff --git a/src/app/styles/me/me.module.css b/src/app/styles/me/me.module.css index 121d029..1f3a349 100644 --- a/src/app/styles/me/me.module.css +++ b/src/app/styles/me/me.module.css @@ -49,10 +49,8 @@ .login_main { position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; + inset: 0; + z-index: 2; display: flex; align-items: center; diff --git a/src/app/styles/minecraftConnect.module.css b/src/app/styles/minecraftConnect.module.css index df6b098..7017b53 100644 --- a/src/app/styles/minecraftConnect.module.css +++ b/src/app/styles/minecraftConnect.module.css @@ -11,7 +11,7 @@ position: fixed; inset: 0; z-index: 9000; - background-color: rgba(0, 0, 0, 0.4); + background-color: rgba(0, 0, 0, 0.6); } .container { diff --git a/src/app/workshop/[id]/client.tsx b/src/app/workshop/[id]/client.tsx index 43f2987..ed5348b 100644 --- a/src/app/workshop/[id]/client.tsx +++ b/src/app/workshop/[id]/client.tsx @@ -217,7 +217,7 @@ export default function Home({ data, referrer }: { data: Interfaces.Bandage, ref

diff --git a/src/app/workshop/[id]/components/edit.tsx b/src/app/workshop/[id]/components/edit.tsx index 4b47790..f9a1978 100644 --- a/src/app/workshop/[id]/components/edit.tsx +++ b/src/app/workshop/[id]/components/edit.tsx @@ -6,6 +6,7 @@ import style from "@/app/styles/editor/page.module.css"; import * as Interfaces from "@/app/interfaces"; import Select from 'react-select'; import { IconArchive, IconX } from "@tabler/icons-react"; +import EditConfirmation from "@/app/modules/components/EditConfirmation"; const lstrip = (string: string) => string.replace(/^\s+/, ''); @@ -62,21 +63,26 @@ const EditElement = ({ }); } - const deleteBandage = () => { - const first = confirm(`Вы собираетесь удалить повязку ${bandage.title}! Это действе необратимо! Подтверждаете?`); - if (!first) return; - const second = confirm('Последний шанс! Удалить?'); - if (!second) return; - ApiManager.deleteBandage(bandage.external_id) - .then(() => router.replace('/workshop')) - .catch(err => alert(err.data.message)); + const deleteBandage = async (): Promise => { + return new Promise((resolve, reject) => { + ApiManager.deleteBandage(bandage.external_id) + .then(() => { + resolve(); + router.replace('/workshop'); + }) + .catch(err => reject(err.data.message)) + }); } - const archiveBandage = () => { - if (!confirm('Заархивировать повязку? После архивации её будет невозможно изменить!')) return; - ApiManager.archiveBandage(bandage.external_id) - .then(() => window.location.reload()) - .catch(err => alert(err.data?.message || err.message)); + const archiveBandage = (): Promise => { + return new Promise((resolve, reject) => { + ApiManager.archiveBandage(bandage.external_id) + .then(() => { + resolve(); + window.location.reload(); + }) + .catch(err => reject(err.data.message)) + }); } return
@@ -125,10 +131,16 @@ const EditElement = ({ marginTop: '1rem', marginBottom: '.4rem' }}> -
- - -
+ +
+ + +
+

Удалить повязку

- + + +

Архивировать