mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-06 17:30:36 +01:00
feat: login with wargaming to generate url
This commit is contained in:
1 parent
7a8ad6c290
commit
71c9d1461f
4 files changed
+72
-11
No files matched your search
@@ -25,6 +25,7 @@ import { SizeWithout0 } from '../../../../components/Embeds/SizeWithout0';
|
|||||||
import { Slider } from '../../../../components/Embeds/Slider';
|
import { Slider } from '../../../../components/Embeds/Slider';
|
||||||
import { TextController } from '../../../../components/Embeds/TextController';
|
import { TextController } from '../../../../components/Embeds/TextController';
|
||||||
import { PageWrapper } from '../../../../components/PageWrapper';
|
import { PageWrapper } from '../../../../components/PageWrapper';
|
||||||
|
import { WargamingLoginButton } from '../../../../components/WargamingLoginButton';
|
||||||
import {
|
import {
|
||||||
configurations,
|
configurations,
|
||||||
extractEmbedConfigDefaults,
|
extractEmbedConfigDefaults,
|
||||||
@@ -59,6 +60,10 @@ export function Page({ embed }: PageProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Content({ embed }: PageProps) {
|
function Content({ embed }: PageProps) {
|
||||||
|
const wargaming = App.useDeferred(
|
||||||
|
(state) => state.logins.wargaming,
|
||||||
|
undefined,
|
||||||
|
);
|
||||||
const embedStateStore = EmbedState.useStore();
|
const embedStateStore = EmbedState.useStore();
|
||||||
const appStore = App.useStore();
|
const appStore = App.useStore();
|
||||||
const config = configurations[embed] as EmbedConfig;
|
const config = configurations[embed] as EmbedConfig;
|
||||||
@@ -96,6 +101,7 @@ function Content({ embed }: PageProps) {
|
|||||||
|
|
||||||
<Flex mb="6" gap="2" wrap="wrap">
|
<Flex mb="6" gap="2" wrap="wrap">
|
||||||
<CopyButton
|
<CopyButton
|
||||||
|
disabled={!wargaming}
|
||||||
copy={() => {
|
copy={() => {
|
||||||
const { wargaming } = appStore.getState().logins;
|
const { wargaming } = appStore.getState().logins;
|
||||||
|
|
||||||
@@ -120,8 +126,13 @@ function Content({ embed }: PageProps) {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Link2Icon />
|
<Link2Icon />
|
||||||
Copy URL
|
{wargaming ? 'Copy URL' : 'Log in to general URL'}
|
||||||
</CopyButton>
|
</CopyButton>
|
||||||
|
{!wargaming && (
|
||||||
|
<WargamingLoginButton>
|
||||||
|
Log in with Wargaming
|
||||||
|
</WargamingLoginButton>
|
||||||
|
)}
|
||||||
<CopyButton
|
<CopyButton
|
||||||
variant="outline"
|
variant="outline"
|
||||||
copy={() =>
|
copy={() =>
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import { ExclamationTriangleIcon } from '@radix-ui/react-icons';
|
||||||
|
import { Callout, Flex, Link } from '@radix-ui/themes';
|
||||||
|
import { PageWrapper } from '../../../components/PageWrapper';
|
||||||
|
import { WargamingLoginButton } from '../../../components/WargamingLoginButton';
|
||||||
|
import { configurations } from '../../../constants/embeds';
|
||||||
|
import { App, type WargamingLogin } from '../../../stores/app';
|
||||||
|
|
||||||
|
export function Page() {
|
||||||
|
return (
|
||||||
|
<App.Provider>
|
||||||
|
<Content />
|
||||||
|
</App.Provider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Content() {
|
||||||
|
const wargaming = App.useDeferred((state) => state.logins.wargaming, {
|
||||||
|
expires: 0,
|
||||||
|
id: 0,
|
||||||
|
token: '',
|
||||||
|
} satisfies WargamingLogin);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageWrapper color="red">
|
||||||
|
{!wargaming && (
|
||||||
|
<>
|
||||||
|
<Flex justify="center">
|
||||||
|
<Callout.Root size="1">
|
||||||
|
<Callout.Icon>
|
||||||
|
<ExclamationTriangleIcon />
|
||||||
|
</Callout.Icon>
|
||||||
|
|
||||||
|
<Callout.Text>
|
||||||
|
You must be logged in with your Wargaming account to export
|
||||||
|
embeds.
|
||||||
|
</Callout.Text>
|
||||||
|
</Callout.Root>
|
||||||
|
</Flex>
|
||||||
|
|
||||||
|
<Flex justify="center">
|
||||||
|
<WargamingLoginButton>Log in with Wargaming</WargamingLoginButton>
|
||||||
|
</Flex>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{Object.entries(configurations).map(([embed, config]) => (
|
||||||
|
<Link href={`/tools/embed/${embed}`}>{embed}</Link>
|
||||||
|
))}
|
||||||
|
</PageWrapper>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,16 +1,9 @@
|
|||||||
---
|
---
|
||||||
import { PageWrapper } from '../../../components/PageWrapper';
|
|
||||||
import { configurations } from '../../../constants/embeds';
|
|
||||||
import { embedTool } from '../../../constants/tools';
|
import { embedTool } from '../../../constants/tools';
|
||||||
import ToolLayout from '../../../layouts/ToolLayout.astro';
|
import ToolLayout from '../../../layouts/ToolLayout.astro';
|
||||||
|
import { Page } from './_index';
|
||||||
---
|
---
|
||||||
|
|
||||||
<ToolLayout tool={embedTool}>
|
<ToolLayout tool={embedTool}>
|
||||||
<PageWrapper>
|
<Page client:load />
|
||||||
{
|
|
||||||
Object.entries(configurations).map(([embed, config]) => (
|
|
||||||
<a href={`/tools/embed/${embed}`}>{embed}</a>
|
|
||||||
))
|
|
||||||
}
|
|
||||||
</PageWrapper>
|
|
||||||
</ToolLayout>
|
</ToolLayout>
|
||||||
@@ -3,11 +3,17 @@ import { create } from 'zustand';
|
|||||||
import { persist, subscribeWithSelector } from 'zustand/middleware';
|
import { persist, subscribeWithSelector } from 'zustand/middleware';
|
||||||
import { createContextualStore } from '../../core/zustand/createContextualStore';
|
import { createContextualStore } from '../../core/zustand/createContextualStore';
|
||||||
|
|
||||||
|
export interface WargamingLogin {
|
||||||
|
token: string;
|
||||||
|
id: number;
|
||||||
|
expires: number;
|
||||||
|
}
|
||||||
|
|
||||||
interface AppStore {
|
interface AppStore {
|
||||||
developerMode: boolean;
|
developerMode: boolean;
|
||||||
policiesAgreementIndex: number;
|
policiesAgreementIndex: number;
|
||||||
logins: {
|
logins: {
|
||||||
wargaming?: { token: string; id: number; expires: number };
|
wargaming?: WargamingLogin;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user