chore: sync from legacy redo

This commit is contained in:
41666 2021-08-01 13:17:34 -04:00
parent dde05c402e
commit c4dda617b1
7 changed files with 67 additions and 2 deletions

View file

@ -0,0 +1,18 @@
import { respond } from '@roleypoly/api/utils/api-tools';
import { asEditor } from '@roleypoly/api/utils/guild';
import {
fetchLegacyServer,
transformLegacyGuild,
} from '@roleypoly/api/utils/import-from-legacy';
import { notFound } from '@roleypoly/api/utils/responses';
export const FetchFromLegacy = asEditor({}, (session, { guildID }) => async () => {
const legacyGuild = await fetchLegacyServer(guildID);
if (!legacyGuild) {
return notFound();
}
const transformedGuild = transformLegacyGuild(legacyGuild);
return respond(transformedGuild);
});

View file

@ -1,5 +1,6 @@
import { BotJoin } from './handlers/bot-join';
import { ClearGuildCache } from './handlers/clear-guild-cache';
import { FetchFromLegacy } from './handlers/fetch-from-legacy';
import { GetPickerData } from './handlers/get-picker-data';
import { GetSession } from './handlers/get-session';
import { GetSlug } from './handlers/get-slug';
@ -29,9 +30,12 @@ router.add('GET', 'get-slug', GetSlug);
router.add('GET', 'get-picker-data', GetPickerData);
router.add('PATCH', 'update-roles', UpdateRoles);
router.add('PATCH', 'update-guild', UpdateGuild);
router.add('POST', 'sync-from-legacy', SyncFromLegacy);
router.add('POST', 'clear-guild-cache', ClearGuildCache);
// Legacy sync stuff
router.add('POST', 'sync-from-legacy', SyncFromLegacy);
router.add('GET', 'fetch-from-legacy', FetchFromLegacy);
// Tester Routes
router.add('GET', 'x-headers', (request) => {
const headers: { [x: string]: string } = {};

View file

@ -168,7 +168,9 @@ export const getGuildData = async (id: string): Promise<GuildDataT> => {
};
if (!guildData) {
return empty;
return {
...empty,
};
}
return {

View file

@ -0,0 +1,13 @@
import { presentableGuild, roleypolyGuild } from '../../fixtures/storyData';
import { EditorSyncFromLegacy } from './EditorSyncFromLegacy';
export default {
title: 'Organisms/Editor/Sync From Legacy',
component: EditorSyncFromLegacy,
args: {
guild: presentableGuild,
guildSlug: roleypolyGuild,
},
};
export const syncFromLegacy = (args) => <EditorSyncFromLegacy {...args} />;

View file

@ -0,0 +1,2 @@
import styled from 'styled-components';
export const EditorSyncFromLegacyStyled = styled.div``;

View file

@ -0,0 +1,25 @@
import {
EditorUtilityProps,
EditorUtilityShell,
} from '@roleypoly/design-system/molecules/editor-utility-shell';
import { PresentableGuild } from '@roleypoly/types';
import { GoShield } from 'react-icons/go';
export type EditorSyncFromLegacyProps = {
guild: PresentableGuild;
} & EditorUtilityProps;
export const EditorAccessControl = (props: EditorSyncFromLegacyProps) => {
return (
<EditorUtilityShell
guildSlug={props.guild.guild}
title="Access Control"
icon={<GoShield />}
hasChanges={false}
onSubmit={props.onSubmit}
onExit={props.onExit}
>
<div>hi</div>
</EditorUtilityShell>
);
};

View file

@ -0,0 +1 @@
export * from './EditorSyncFromLegacy';