updated backend
This commit is contained in:
@@ -6,3 +6,11 @@ export function overrideTailwindClasses(
|
|||||||
) {
|
) {
|
||||||
return otc(classNamesString, optionsArgs).trim()
|
return otc(classNamesString, optionsArgs).trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function plural(
|
||||||
|
n: number,
|
||||||
|
singular: string,
|
||||||
|
plural: string = singular + 's'
|
||||||
|
) {
|
||||||
|
return n === 1 ? singular : plural
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,15 +3,18 @@ import { Link } from "react-router-dom"
|
|||||||
import { authFetch, useAuthFetchRepeat } from "../authorization"
|
import { authFetch, useAuthFetchRepeat } from "../authorization"
|
||||||
import { SVGPlus, SVGx } from "../components/Icons"
|
import { SVGPlus, SVGx } from "../components/Icons"
|
||||||
import { Button, InputPassword } from "../components/Inputs"
|
import { Button, InputPassword } from "../components/Inputs"
|
||||||
import { overrideTailwindClasses } from "../general"
|
import { overrideTailwindClasses, plural } from "../general"
|
||||||
|
|
||||||
interface DiscordBot {
|
interface DiscordBot {
|
||||||
id: string
|
user: {
|
||||||
username: string
|
id: string
|
||||||
discriminator: string
|
username: string
|
||||||
avatar: string
|
discriminator: string
|
||||||
bot: boolean
|
avatar: string
|
||||||
verified: boolean
|
bot: boolean
|
||||||
|
verified: boolean
|
||||||
|
}
|
||||||
|
token_count: number
|
||||||
}
|
}
|
||||||
|
|
||||||
function BotContainer({ children, ...props }: { children: React.ReactNode } & React.HTMLAttributes<HTMLDivElement>) {
|
function BotContainer({ children, ...props }: { children: React.ReactNode } & React.HTMLAttributes<HTMLDivElement>) {
|
||||||
@@ -37,18 +40,19 @@ function BotContainer({ children, ...props }: { children: React.ReactNode } & Re
|
|||||||
|
|
||||||
function Bot({ bot }: { bot: DiscordBot }) {
|
function Bot({ bot }: { bot: DiscordBot }) {
|
||||||
console.log(bot)
|
console.log(bot)
|
||||||
|
const { user, token_count } = bot
|
||||||
return (
|
return (
|
||||||
<Link to={`/bot/${bot.id}`}>
|
<Link to={`/bot/${user.id}`}>
|
||||||
<BotContainer>
|
<BotContainer>
|
||||||
<img
|
<img
|
||||||
src={`https://cdn.discordapp.com/avatars/${bot.id}/${bot.avatar}.png`}
|
src={`https://cdn.discordapp.com/avatars/${user.id}/${user.avatar}.png`}
|
||||||
className="w-full" />
|
className="w-full" />
|
||||||
<div className="text-2xl flex-grow inline-flex justify-center items-center">
|
<div className="text-2xl flex-grow inline-flex justify-center items-center">
|
||||||
<span className="text-gray-300">{bot.username}</span>
|
<span className="text-gray-300">{user.username}</span>
|
||||||
<span className="text-gray-300">#{bot.discriminator}</span>
|
<span className="text-gray-300">#{user.discriminator}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="text-l flex-grow inline-flex justify-center items-center">
|
<div className="text-l flex-grow inline-flex justify-center items-center">
|
||||||
<span className="text-gray-400">X Assigned tokens</span>
|
<span className="text-gray-400">{token_count} Assigned {plural(token_count, 'Token')}</span>
|
||||||
</div>
|
</div>
|
||||||
</BotContainer>
|
</BotContainer>
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { useAuthFetch } from "../../authorization"
|
import { useAuthFetch } from "../../authorization"
|
||||||
|
import { plural } from "../../general"
|
||||||
|
|
||||||
interface LoginToken {
|
interface LoginToken {
|
||||||
id: string
|
id: string
|
||||||
@@ -24,7 +25,7 @@ export function LoginTokensMini() {
|
|||||||
return tokens && (
|
return tokens && (
|
||||||
<div>
|
<div>
|
||||||
<span>
|
<span>
|
||||||
{tokens.length} Login Token{tokens.length === 1 ? "" : "s"}
|
{tokens.length} Login {plural(tokens.length, 'Token')}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user