Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/user-banning-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
"supertokens-js-override": "^0.0.4"
},
"peerDependencies": {
"react": ">=18.3.1",
"react-dom": ">=18.3.1",
"react": ">=19.0.0",
"react-dom": ">=19.0.0",
Comment on lines +25 to +26
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did we need to update this?

"supertokens-auth-react": ">=0.50.0",
"supertokens-web-js": ">=0.16.0"
},
"devDependencies": {
"@shared/eslint": "*",
"@shared/tsconfig": "*",
"@shared/ui": "*",
"@types/react": "^17.0.20",
"prettier": "2.0.5",
"pretty-quick": "^3.1.1",
Expand Down
212 changes: 97 additions & 115 deletions packages/user-banning-react/src/pages/BanUserPage.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { Button, Callout, Card, TextInput, ThemeProvider } from "@shared/ui";
import React from "react";
import { useCallback, useState } from "react";
import { SessionAuth } from "supertokens-auth-react/recipe/session";
import { PermissionClaim } from "supertokens-auth-react/recipe/userroles";

import { usePluginContext } from "../plugin";
import { getErrorMessage, ThemeBase } from "../utils";

// @ts-ignore
import styles from "./style.css?inline";
import { getErrorMessage } from "../utils";

export function BanUserPage() {
const { api, pluginConfig, t } = usePluginContext();
Expand Down Expand Up @@ -67,41 +65,32 @@ export function BanUserPage() {
[tenantId, email]
);

const onCheckStatus = useCallback(
(e: React.MouseEvent<HTMLButtonElement>) => {
e.preventDefault();

if (!email) {
setError("Email is required");
return;
}
const onCheckStatus = useCallback(() => {
if (!email) {
setError("Email is required");
return;
}

getBanStatus(email);
},
[getBanStatus, email]
);
getBanStatus(email);
}, [getBanStatus, email]);

const onBanUser = useCallback(
(e: React.MouseEvent<HTMLButtonElement>) => {
e.preventDefault();
updateBanStatus(true);
},
[updateBanStatus]
);
const onBanUser = useCallback(() => {
if (!email) {
setError("Email is required");
return;
}

const onUnbanUser = useCallback(
(e: React.MouseEvent<HTMLButtonElement>) => {
e.preventDefault();
updateBanStatus(true);
}, [updateBanStatus]);

if (!email) {
setError("Email is required");
return;
}
const onUnbanUser = useCallback(() => {
if (!email) {
setError("Email is required");
return;
}

updateBanStatus(false);
},
[updateBanStatus, email]
);
updateBanStatus(false);
}, [updateBanStatus, email]);

return (
<SessionAuth
Expand All @@ -112,87 +101,80 @@ export function BanUserPage() {
onFailureRedirection: () => pluginConfig.onPermissionFailureRedirectPath,
},
]}>
<ThemeBase userStyles={[styles]}>
<div className="supertokens-plugin-user-banning">
<div className="container">
<div className="row">
<div className="headerTitle">{t("PL_UB_BAN_PAGE_TITLE")}</div>
<p>{t("PL_UB_BAN_PAGE_DESCRIPTION")}</p>

<div className="divider"></div>

{Boolean(error) && <div className="errorMessage">{error}</div>}

<form noValidate>
<div className="formRow">
<div className="label">{t("PL_UB_BAN_PAGE_TENANT_ID_LABEL")}</div>
<div className="inputContainer">
<div className="inputWrapper">
<input
type="text"
value={tenantId}
autoComplete="on"
placeholder={t("PL_UB_BAN_PAGE_TENANT_ID_PLACEHOLDER")}
onChange={(e) => {
setTenantId(e.target.value);
setBanStatus(null);
}}
/>
</div>
</div>
</div>

<div className="formRow">
<div className="label">{t("PL_UB_BAN_PAGE_EMAIL_LABEL")}</div>
<div className="inputContainer">
<div className="inputWrapper">
<input
type="email"
value={email}
disabled={!tenantId}
autoComplete="on"
placeholder={t("PL_UB_BAN_PAGE_EMAIL_PLACEHOLDER")}
onChange={(e) => {
setEmail(e.target.value);
setBanStatus(null);
}}
/>
</div>
</div>
</div>

{typeof banStatus === "boolean" && (
<div className="formRow">
{banStatus ? (
<div className="errorMessage">{t("PL_UB_BAN_PAGE_BANNED_STATUS")}</div>
) : (
<div className="successMessage">{t("PL_UB_BAN_PAGE_NOT_BANNED_STATUS")}</div>
)}
</div>
)}

<div className="formRow">
<button className="button" onClick={onCheckStatus} disabled={!tenantId || !email}>
{t("PL_UB_BAN_PAGE_CHECK_STATUS_BUTTON")}
</button>
</div>

{typeof banStatus === "boolean" && (
<div className="formRow" style={{ flexDirection: "row" }}>
<button className="button" disabled={banStatus} onClick={onBanUser} style={{ marginRight: "20px" }}>
{t("PL_UB_BAN_PAGE_BAN_BUTTON")}
</button>

<button className="button" disabled={!banStatus} onClick={onUnbanUser}>
{t("PL_UB_BAN_PAGE_UNBAN_BUTTON")}
</button>
</div>
)}
</form>
</div>
</div>
</div>
</ThemeBase>
<ThemeProvider>
<Card
title={t("PL_UB_BAN_PAGE_TITLE")}
description={t("PL_UB_BAN_PAGE_DESCRIPTION")}
style={{ width: "460px" }}>
{Boolean(error) && (
<Callout size="small" variant="danger" appearance="filled">
{error}
</Callout>
)}
<TextInput
id=""
required
label={t("PL_UB_BAN_PAGE_TENANT_ID_LABEL")}
value={tenantId}
onChange={(value) => {
setTenantId(value);
setBanStatus(null);
}}
/>
<br />
<TextInput
id=""
required
label={t("PL_UB_BAN_PAGE_EMAIL_LABEL")}
value={email ?? ""}
placeholder="[email protected]"
onChange={(value) => {
setEmail(value);
setBanStatus(null);
}}
/>
<br />

{typeof banStatus === "boolean" && (
<>
{banStatus ? (
<Callout size="small" variant="danger" appearance="filled">
{t("PL_UB_BAN_PAGE_BANNED_STATUS")}
</Callout>
) : (
<Callout size="small" variant="success" appearance="filled">
{t("PL_UB_BAN_PAGE_NOT_BANNED_STATUS")}
</Callout>
)}
<br />
</>
)}

{typeof banStatus !== "boolean" && (
<>
<Button variant="brand" onClick={onCheckStatus} disabled={!tenantId || !email}>
{t("PL_UB_BAN_PAGE_CHECK_STATUS_BUTTON")}
</Button>
<br />
</>
)}

{typeof banStatus === "boolean" && (
<>
{banStatus ? (
<Button variant="brand" onClick={onUnbanUser}>
{t("PL_UB_BAN_PAGE_UNBAN_BUTTON")}
</Button>
) : (
<Button variant="brand" onClick={onBanUser}>
{t("PL_UB_BAN_PAGE_BAN_BUTTON")}
</Button>
)}
<br />
</>
)}
</Card>
</ThemeProvider>
</SessionAuth>
);
}
140 changes: 0 additions & 140 deletions packages/user-banning-react/src/pages/style.css
Original file line number Diff line number Diff line change
@@ -1,140 +0,0 @@
.supertokens-plugin-user-banning .container {
margin: 12px auto;
margin-top: 26px;
margin-bottom: 26px;
width: 420px;
text-align: center;
border-radius: 8px;
box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.16);
background-color: rgb(255, 255, 255);
}

.supertokens-plugin-user-banning .row {
margin: 0 auto;
width: 76%;
padding-top: 30px;
padding-bottom: 10px;
}

.supertokens-plugin-user-banning .headerTitle {
font-size: 24px;
line-height: 27.6px;
letter-spacing: 0.58px;
font-weight: 700;
margin-bottom: 20px;
color: rgb(0, 0, 0);
}

.supertokens-plugin-user-banning .divider {
margin-top: 1.5em;
margin-bottom: 1.5em;
border-bottom: 0.3px solid #dddddd;
align-items: center;
padding-bottom: 5px;
}

.supertokens-plugin-user-banning .formRow {
display: flex;
flex-direction: column;
padding-top: 0px;
padding-bottom: 20px;
}

.supertokens-plugin-user-banning .formRow .label {
text-align: left;
font-weight: 700;
font-size: 12px;
line-height: 24px;
color: rgb(0, 0, 0);
}

.supertokens-plugin-user-banning .formRow .inputContainer {
margin-top: 6px;
}

.supertokens-plugin-user-banning .formRow .inputWrapper {
box-sizing: border-box;
width: 100%;
display: flex;
align-items: center;
background-color: rgb(250, 250, 250);
height: 34px;
border-radius: 6px;
border: 1px solid rgb(224, 224, 224);
}

.supertokens-plugin-user-banning .formRow input {
box-sizing: border-box;
padding-left: 15px;
filter: none;
color: rgb(0, 0, 0);
background-color: transparent;
border-radius: 6px;
font-size: 14px;
border: none;
padding-right: 25px;
letter-spacing: 1.2px;
flex: 9 1 75%;
width: 75%;
height: 32px;
-webkit-text-fill-color: rgb(0, 0, 0);
}
.supertokens-plugin-user-banning .formRow input:focus {
border: none;
outline: none;
}

.supertokens-plugin-user-banning .button {
font-family: "Arial", sans-serif;
background-color: rgb(28, 34, 42);
color: rgb(255, 255, 255);
width: 100%;
height: 34px;
font-weight: 600;
border-width: 1px;
border-style: solid;
border-radius: 6px;
border-color: rgb(45, 54, 68);
background-position: center;
transition: all 0.4s;
background-size: 12000%;
cursor: pointer;
}

.supertokens-plugin-user-banning .button:disabled {
border: none;
cursor: no-drop;
opacity: 0.7;
}

.errorMessage {
background: rgb(255, 241, 235);
padding-top: 10px;
padding-bottom: 10px;
margin-bottom: 10px;
margin-top: 24px;
padding-left: 18px;
padding-right: 18px;
letter-spacing: 0.2px;
font-size: 14px;
border-radius: 8px;
color: rgb(255, 23, 23);
animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
word-wrap: break-word;
}

.successMessage {
background: rgb(235, 255, 235);
padding-top: 10px;
padding-bottom: 10px;
margin-bottom: 10px;
margin-top: 24px;
padding-left: 18px;
padding-right: 18px;
letter-spacing: 0.2px;
font-size: 14px;
border-radius: 8px;
color: rgb(23, 255, 23);
animation: swing-in-top-fwd 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
word-wrap: break-word;
}
Loading
Loading