feat: disable tools on opentest

This commit is contained in:
TrèsAbhi committed 2024-08-27 14:55:43 -05:00
1 parent 48dcbbc227
commit b9c978548a
20 files changed
+107 -99

No files matched your search

+4 -4
View File
@@ -1,5 +1,5 @@
import { NextResponse } from 'next/server';
import { assertSecrete } from '../../../../../core/blitzkit/secrete';
import { assertSecret } from '../../../../../core/blitzkit/secret';
export async function GET(
request: Request,
@@ -8,11 +8,11 @@ export async function GET(
const response = await fetch(
`https://www.patreon.com/api/oauth2/token?code=${
params.code
}&grant_type=authorization_code&client_id=${assertSecrete(
}&grant_type=authorization_code&client_id=${assertSecret(
process.env.NEXT_PUBLIC_PATREON_CLIENT_ID,
)}&client_secret=${assertSecrete(
)}&client_secret=${assertSecret(
process.env.PATREON_CLIENT_SECRET,
)}&redirect_uri=${assertSecrete(process.env.NEXT_PUBLIC_PATREON_REDIRECT_URI)}`,
)}&redirect_uri=${assertSecret(process.env.NEXT_PUBLIC_PATREON_REDIRECT_URI)}`,
{
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
@@ -1,5 +1,5 @@
import { NextResponse } from 'next/server';
import { assertSecrete } from '../../../../../core/blitzkit/secrete';
import { assertSecret } from '../../../../../core/blitzkit/secret';
interface PatreonMembershipResponse {
data: {
@@ -69,7 +69,7 @@ export async function GET(
(item) =>
item.type === 'member' &&
item.relationships.campaign.data.id ===
assertSecrete(process.env.PATREON_CAMPAIGN_ID) &&
assertSecret(process.env.PATREON_CAMPAIGN_ID) &&
item.attributes.patron_status === 'active_patron',
),
);
+3 -3
View File
@@ -1,5 +1,5 @@
import { NextResponse } from 'next/server';
import { assertSecrete } from '../../../../../core/blitzkit/secrete';
import { assertSecret } from '../../../../../core/blitzkit/secret';
export async function GET(
request: Request,
@@ -8,9 +8,9 @@ export async function GET(
const response = await fetch(
`https://www.patreon.com/api/oauth2/token?grant_type=refresh_token&refresh_token=${
params.token
}&client_id=${assertSecrete(
}&client_id=${assertSecret(
process.env.NEXT_PUBLIC_PATREON_CLIENT_ID,
)}&client_secret=${assertSecrete(process.env.PATREON_CLIENT_SECRET)}`,
)}&client_secret=${assertSecret(process.env.PATREON_CLIENT_SECRET)}`,
{ method: 'POST' },
);
const json = await response.json();
+40 -55
View File
@@ -2,14 +2,16 @@ import { CaretRightIcon } from '@radix-ui/react-icons';
import {
Box,
Button,
Code,
Flex,
FlexProps,
Heading,
Link,
Text,
} from '@radix-ui/themes';
import { Link } from '../../components/Link';
import { Tool } from '../../constants/tools';
import { ImgurSize, imgur } from '../../core/blitzkit/imgur';
import { assertSecret } from '../../core/blitzkit/secret';
type ToolCardProps = FlexProps & {
tool: Tool;
@@ -19,10 +21,14 @@ export function ToolCard({ tool, style, ...props }: ToolCardProps) {
const size = tool.significant
? ImgurSize.HugeThumbnail
: ImgurSize.LargeThumbnail;
const unavailableOnBranch = tool.branches?.every(
(branch) => branch !== assertSecret(process.env.NEXT_PUBLIC_ASSET_BRANCH),
);
return (
<Flex
style={{
opacity: unavailableOnBranch ? 0.25 : 1,
position: 'relative',
borderRadius: 'var(--radius-2)',
overflow: 'hidden',
@@ -33,17 +39,11 @@ export function ToolCard({ tool, style, ...props }: ToolCardProps) {
...style,
}}
flexGrow={tool.significant ? undefined : '1'}
flexBasis={
tool.significant
? undefined
: {
initial: undefined,
sm: '0',
}
}
flexBasis={tool.significant ? undefined : { initial: undefined, sm: '0' }}
{...props}
>
<Link
disabled={unavailableOnBranch}
href={tool.href ?? `/tools/${tool.id}`}
target={tool.href ? '_blank' : undefined}
style={{
@@ -65,22 +65,13 @@ export function ToolCard({ tool, style, ...props }: ToolCardProps) {
/>
<Flex
px={{
initial: '6',
md: tool.significant ? '8' : '6',
}}
py={{
initial: '4',
sm: tool.significant ? '6' : '4',
}}
px={{ initial: '6', md: tool.significant ? '8' : '6' }}
py={{ initial: '4', sm: tool.significant ? '6' : '4' }}
gap="4"
align="center"
justify="between"
width="100%"
direction={{
initial: 'column',
xs: 'row',
}}
direction={{ initial: 'column', xs: 'row' }}
style={{
backgroundColor: 'var(--color-panel-translucent)',
backdropFilter: 'blur(64px)',
@@ -90,52 +81,46 @@ export function ToolCard({ tool, style, ...props }: ToolCardProps) {
<Flex
direction="column"
justify="center"
align={{
initial: 'center',
xs: 'start',
}}
align={{ initial: 'center', xs: 'start' }}
>
<Heading
align={{
initial: 'center',
sm: 'left',
}}
size={{
initial: '6',
sm: tool.significant ? '7' : '5',
}}
align={{ initial: 'center', sm: 'left' }}
size={{ initial: '6', sm: tool.significant ? '7' : '5' }}
weight="medium"
>
{tool.title}
</Heading>
<Text
align={{
initial: 'center',
sm: 'left',
}}
size={{
initial: '3',
sm: tool.significant ? '4' : '3',
}}
align={{ initial: 'center', sm: 'left' }}
size={{ initial: '3', sm: tool.significant ? '4' : '3' }}
color="gray"
>
{tool.description}
{unavailableOnBranch ? (
<>
Unavailable on{' '}
<Code>
{assertSecret(process.env.NEXT_PUBLIC_ASSET_BRANCH)}
</Code>
</>
) : (
tool.description
)}
</Text>
</Flex>
<Button
size={{
initial: undefined,
sm: tool.significant ? '3' : undefined,
}}
color={tool.button.color}
style={{
cursor: 'inherit',
}}
>
{tool.button.text}
<CaretRightIcon />
</Button>
{!unavailableOnBranch && (
<Button
size={{
initial: undefined,
sm: tool.significant ? '3' : undefined,
}}
color={tool.button.color}
style={{ cursor: 'inherit' }}
>
{tool.button.text}
<CaretRightIcon />
</Button>
)}
</Flex>
</Link>
</Flex>
+2 -2
View File
@@ -3,7 +3,7 @@ import Markdown from 'markdown-to-jsx';
import { use } from 'react';
import { Link } from '../../../../components/Link';
import PageWrapper from '../../../../components/PageWrapper';
import { assertSecrete } from '../../../../core/blitzkit/secrete';
import { assertSecret } from '../../../../core/blitzkit/secret';
export default function Page({
params,
@@ -12,7 +12,7 @@ export default function Page({
}) {
const markdown = use(
fetch(
`https://raw.githubusercontent.com/tresabhi/blitzkit/${assertSecrete(
`https://raw.githubusercontent.com/tresabhi/blitzkit/${assertSecret(
process.env.NEXT_PUBLIC_ASSET_BRANCH,
)}/docs/${params.directory}/${params.document}.md`,
).then((response) => response.text()),