mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-15 09:09:10 +00:00
feat(Editor): make server utilities their own pages
Signed-off-by: Katalina Okano <git@kat.cafe>
This commit is contained in:
parent
d52508a046
commit
4cc202b62a
8 changed files with 125 additions and 153 deletions
|
@ -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} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue