mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-04-25 03:49:11 +00:00
fix linting issues
This commit is contained in:
parent
8cf3b2c78d
commit
b73bd1e664
3 changed files with 47 additions and 41 deletions
|
@ -5,34 +5,35 @@ import { GuildData } from '../utils/kv';
|
|||
import { lowPermissions, missingParameters, notFound, ok } from '../utils/responses';
|
||||
|
||||
export const UpdateGuild = withSession(
|
||||
(session: SessionData) => async (request: Request): Promise<Response> => {
|
||||
const url = new URL(request.url);
|
||||
const [, , guildID] = url.pathname.split('/');
|
||||
if (!guildID) {
|
||||
return missingParameters();
|
||||
(session: SessionData) =>
|
||||
async (request: Request): Promise<Response> => {
|
||||
const url = new URL(request.url);
|
||||
const [, , guildID] = url.pathname.split('/');
|
||||
if (!guildID) {
|
||||
return missingParameters();
|
||||
}
|
||||
|
||||
const guildUpdate = (await request.json()) as GuildDataUpdate;
|
||||
|
||||
const guild = session.guilds.find((guild) => guild.id === guildID);
|
||||
if (!guild) {
|
||||
return notFound();
|
||||
}
|
||||
|
||||
if (
|
||||
guild?.permissionLevel !== UserGuildPermissions.Manager &&
|
||||
guild?.permissionLevel !== UserGuildPermissions.Admin
|
||||
) {
|
||||
return lowPermissions();
|
||||
}
|
||||
|
||||
const newGuildData = {
|
||||
...(await getGuildData(guildID)),
|
||||
...guildUpdate,
|
||||
};
|
||||
|
||||
await GuildData.put(guildID, newGuildData);
|
||||
|
||||
return ok();
|
||||
}
|
||||
|
||||
const guildUpdate = (await request.json()) as GuildDataUpdate;
|
||||
|
||||
const guild = session.guilds.find((guild) => guild.id === guildID);
|
||||
if (!guild) {
|
||||
return notFound();
|
||||
}
|
||||
|
||||
if (
|
||||
guild?.permissionLevel !== UserGuildPermissions.Manager &&
|
||||
guild?.permissionLevel !== UserGuildPermissions.Admin
|
||||
) {
|
||||
return lowPermissions();
|
||||
}
|
||||
|
||||
const newGuildData = {
|
||||
...(await getGuildData(guildID)),
|
||||
...guildUpdate,
|
||||
};
|
||||
|
||||
await GuildData.put(guildID, newGuildData);
|
||||
|
||||
return ok();
|
||||
}
|
||||
);
|
||||
|
|
|
@ -37,15 +37,25 @@ export const EditorShell = (props: EditorShellProps) => {
|
|||
});
|
||||
};
|
||||
|
||||
const hasChanges = React.useMemo(() => !deepEqual(guild.data, props.guild.data), [
|
||||
guild.data,
|
||||
props.guild.data,
|
||||
]);
|
||||
const hasChanges = React.useMemo(
|
||||
() => !deepEqual(guild.data, props.guild.data),
|
||||
[guild.data, props.guild.data]
|
||||
);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Space />
|
||||
<TabView initialTab={0} masthead={<EditorMasthead guild={guild} />}>
|
||||
<TabView
|
||||
initialTab={0}
|
||||
masthead={
|
||||
<EditorMasthead
|
||||
guild={guild}
|
||||
onReset={reset}
|
||||
onSubmit={() => props.onGuildChange?.(guild)}
|
||||
showSaveReset={hasChanges}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Tab title="Guild Details">
|
||||
{() => (
|
||||
<EditorDetailsTab
|
||||
|
|
|
@ -7,13 +7,8 @@ import {
|
|||
export const EditorTemplate = (
|
||||
props: EditorShellProps & Omit<AppShellProps, 'children'>
|
||||
) => {
|
||||
const {
|
||||
guild,
|
||||
onCategoryChange,
|
||||
onMessageChange,
|
||||
onGuildChange,
|
||||
...appShellProps
|
||||
} = props;
|
||||
const { guild, onCategoryChange, onMessageChange, onGuildChange, ...appShellProps } =
|
||||
props;
|
||||
return (
|
||||
<AppShell {...appShellProps} activeGuildId={guild.id}>
|
||||
<EditorShell guild={guild} onGuildChange={onGuildChange} />
|
||||
|
|
Loading…
Add table
Reference in a new issue