mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-04-25 03:49:11 +00:00
chore: sync from legacy redo
This commit is contained in:
parent
dde05c402e
commit
c4dda617b1
7 changed files with 67 additions and 2 deletions
18
packages/api/handlers/fetch-from-legacy.ts
Normal file
18
packages/api/handlers/fetch-from-legacy.ts
Normal 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);
|
||||||
|
});
|
|
@ -1,5 +1,6 @@
|
||||||
import { BotJoin } from './handlers/bot-join';
|
import { BotJoin } from './handlers/bot-join';
|
||||||
import { ClearGuildCache } from './handlers/clear-guild-cache';
|
import { ClearGuildCache } from './handlers/clear-guild-cache';
|
||||||
|
import { FetchFromLegacy } from './handlers/fetch-from-legacy';
|
||||||
import { GetPickerData } from './handlers/get-picker-data';
|
import { GetPickerData } from './handlers/get-picker-data';
|
||||||
import { GetSession } from './handlers/get-session';
|
import { GetSession } from './handlers/get-session';
|
||||||
import { GetSlug } from './handlers/get-slug';
|
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('GET', 'get-picker-data', GetPickerData);
|
||||||
router.add('PATCH', 'update-roles', UpdateRoles);
|
router.add('PATCH', 'update-roles', UpdateRoles);
|
||||||
router.add('PATCH', 'update-guild', UpdateGuild);
|
router.add('PATCH', 'update-guild', UpdateGuild);
|
||||||
router.add('POST', 'sync-from-legacy', SyncFromLegacy);
|
|
||||||
router.add('POST', 'clear-guild-cache', ClearGuildCache);
|
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
|
// Tester Routes
|
||||||
router.add('GET', 'x-headers', (request) => {
|
router.add('GET', 'x-headers', (request) => {
|
||||||
const headers: { [x: string]: string } = {};
|
const headers: { [x: string]: string } = {};
|
||||||
|
|
|
@ -168,7 +168,9 @@ export const getGuildData = async (id: string): Promise<GuildDataT> => {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!guildData) {
|
if (!guildData) {
|
||||||
return empty;
|
return {
|
||||||
|
...empty,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -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} />;
|
|
@ -0,0 +1,2 @@
|
||||||
|
import styled from 'styled-components';
|
||||||
|
export const EditorSyncFromLegacyStyled = styled.div``;
|
|
@ -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>
|
||||||
|
);
|
||||||
|
};
|
|
@ -0,0 +1 @@
|
||||||
|
export * from './EditorSyncFromLegacy';
|
Loading…
Add table
Reference in a new issue