diff --git a/packages/fakeyou/src/v2/view/moderation/moderation_ip_ban_list/ModerationIpBanListFc.tsx b/packages/fakeyou/src/v2/view/moderation/moderation_ip_ban_list/ModerationIpBanListFc.tsx index bd9db7f438..58830460e0 100644 --- a/packages/fakeyou/src/v2/view/moderation/moderation_ip_ban_list/ModerationIpBanListFc.tsx +++ b/packages/fakeyou/src/v2/view/moderation/moderation_ip_ban_list/ModerationIpBanListFc.tsx @@ -1,32 +1,32 @@ -import React, { useEffect, useState } from 'react'; -import { Link, useHistory } from 'react-router-dom'; -import { ApiConfig } from '@storyteller/components'; -import { SessionWrapper } from '@storyteller/components/src/session/SessionWrapper'; -import { formatDistance } from 'date-fns'; -import { BackLink } from '../../_common/BackLink'; -import { FrontendUrlConfig } from '../../../../common/FrontendUrlConfig'; +import React, { useEffect, useState } from "react"; +import { Link, useHistory } from "react-router-dom"; +import { ApiConfig } from "@storyteller/components"; +import { SessionWrapper } from "@storyteller/components/src/session/SessionWrapper"; +import { formatDistance } from "date-fns"; +import { BackLink } from "../../_common/BackLink"; +import { FrontendUrlConfig } from "../../../../common/FrontendUrlConfig"; interface Props { - sessionWrapper: SessionWrapper, + sessionWrapper: SessionWrapper; } interface IpBanListResponse { - success: boolean, - ip_address_bans: Array, + success: boolean; + ip_address_bans: Array; } interface IpBanListItem { - ip_address: string, - maybe_target_user_token: string, - maybe_target_username: string, + ip_address: string; + maybe_target_user_token: string; + maybe_target_username: string; - mod_user_token: string, - mod_username: string, - mod_display_name: string, - mod_notes: string, + mod_user_token: string; + mod_username: string; + mod_display_name: string; + mod_notes: string; - created_at: string, - updated_at: string, + created_at: string; + updated_at: string; } function ModerationIpBanListFc(props: Props) { @@ -43,35 +43,35 @@ function ModerationIpBanListFc(props: Props) { const endpointUrl = api.getModerationIpBanList(); fetch(endpointUrl, { - method: 'GET', + method: "GET", headers: { - 'Accept': 'application/json', + Accept: "application/json", }, - credentials: 'include', + credentials: "include", }) - .then(res => res.json()) - .then(res => { - const response : IpBanListResponse = res; - if (!response.success) { - return; - } + .then((res) => res.json()) + .then((res) => { + const response: IpBanListResponse = res; + if (!response.success) { + return; + } - setIpBanList(response.ip_address_bans) - }) - .catch(e => { - //this.props.onSpeakErrorCallback(); - }); + setIpBanList(response.ip_address_bans); + }) + .catch((e) => { + //this.props.onSpeakErrorCallback(); + }); }, []); // NB: Empty array dependency sets to run ONLY on mount const handleNewIpAddressChange = (ev: React.FormEvent) => { - setNewIpAddress((ev.target as HTMLInputElement).value) + setNewIpAddress((ev.target as HTMLInputElement).value); }; const handleModNotesChange = (ev: React.FormEvent) => { - setModNotes((ev.target as HTMLInputElement).value) + setModNotes((ev.target as HTMLInputElement).value); }; - const handleFormSubmit = (ev: React.FormEvent) : boolean => { + const handleFormSubmit = (ev: React.FormEvent): boolean => { ev.preventDefault(); const api = new ApiConfig(); @@ -80,41 +80,43 @@ function ModerationIpBanListFc(props: Props) { const request = { ip_address: newIpAddress, mod_notes: modNotes, - } + }; fetch(endpointUrl, { - method: 'POST', + method: "POST", headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', + Accept: "application/json", + "Content-Type": "application/json", }, - credentials: 'include', + credentials: "include", body: JSON.stringify(request), }) - .then(res => res.json()) - .then(res => { - if (res.success) { - history.go(0); // NB: Force reload - } - }) - .catch(e => {}); + .then((res) => res.json()) + .then((res) => { + if (res.success) { + history.go(0); // NB: Force reload + } + }) + .catch((e) => {}); return false; - } + }; if (!props.sessionWrapper.canBanUsers()) { return

Unauthorized

; } const now = new Date(); - let rows : Array = []; + let rows: Array = []; - ipBanList.forEach(ban => { + ipBanList.forEach((ban) => { const modUserLink = `/profile/${ban.mod_username}`; const viewBanLink = `/moderation/ip_bans/${ban.ip_address}`; const createTime = new Date(ban.created_at); - const relativeCreateTime = formatDistance(createTime, now, { addSuffix: true }); + const relativeCreateTime = formatDistance(createTime, now, { + addSuffix: true, + }); rows.push( @@ -125,94 +127,104 @@ function ModerationIpBanListFc(props: Props) { {ban.mod_notes} {relativeCreateTime} - view / edit + + View/Edit + - ) + ); }); return (
-

Moderation Ip Ban List

- -

- -

- -
- -

IP Address bans will prevent bad actors from using and abusing the website.

- -
- -

Create Ban

+
+

Moderation IP Ban List

+

+ IP Address bans will prevent bad actors from using and abusing the + website. +

+
+ +
+
-
- -
- - - - - - - +
+
+

Create Ban

+
+
+
+ +
+ + + + + + + +
+ {/*

{invalidReason}

*/} +
+
+ +
+ + + + + + + +
+ {/*

{invalidReason}

*/} +
+
+
- {/*

{invalidReason}

*/}
- -
- -
- - - - - - - -
- {/*

{invalidReason}

*/} +
+
- - - -
-
- -

Existing Bans

- - - - - - - - - - - - - {rows} - -
IP AddressModeratorModerator NotesCreated AtView / Edit
+
+
+

Existing Bans

+
+ + + + + + + + + + + {rows} +
IP AddressModeratorModerator NotesCreated AtView / Edit
+
+
+
- ) + ); } export { ModerationIpBanListFc };