feat(Editor): make server utilities their own pages

Signed-off-by: Katalina Okano <git@kat.cafe>
This commit is contained in:
41666 2021-07-17 19:23:35 -04:00
parent d52508a046
commit 4cc202b62a
8 changed files with 125 additions and 153 deletions

View file

@ -1,11 +1,10 @@
import { navigate, Redirect } from '@reach/router';
import { EditorErrors, EditorTemplate } from '@roleypoly/design-system/templates/editor';
import { EditorTemplate } from '@roleypoly/design-system/templates/editor';
import { GenericLoadingTemplate } from '@roleypoly/design-system/templates/generic-loading';
import {
GuildDataUpdate,
PresentableGuild,
UserGuildPermissions,
WebhookValidationStatus,
} from '@roleypoly/types';
import * as React from 'react';
import { useAppShellProps } from '../contexts/app-shell/AppShellContext';
@ -26,9 +25,6 @@ const Editor = (props: EditorProps) => {
const [guild, setGuild] = React.useState<PresentableGuild | null | false>(null);
const [pending, setPending] = React.useState(false);
const [errors, setErrors] = React.useState<EditorErrors>({
webhookValidation: WebhookValidationStatus.Ok,
});
React.useEffect(() => {
const shouldPullUncached = (): boolean => {
@ -104,28 +100,13 @@ const Editor = (props: EditorProps) => {
navigate(`/s/${props.serverID}`);
}
if (response.status === 400) {
const error = await response.json();
if (error.data.what === 'webhookValidationStatus') {
setErrors((errors) => ({
...errors,
webhookValidation: error.data.webhookValidationStatus,
}));
}
}
setPending(false);
};
return (
<>
<Title title={`Editing ${guild.guild.name} - Roleypoly`} />
<EditorTemplate
{...appShellProps}
guild={guild}
onGuildChange={onGuildChange}
errors={errors}
/>
<EditorTemplate {...appShellProps} guild={guild} onGuildChange={onGuildChange} />
</>
);
};