feat: add test emoji page

This commit is contained in:
Paul Makles
2022-07-07 17:33:33 +01:00
parent a766183f01
commit b541301cb1
7 changed files with 205 additions and 32 deletions

View File

@@ -99,7 +99,7 @@ export default function MemberList({
)}
{entry.type !== "no_offline" && (
<>
{" - "}
{" "}
{entry.users.length}
</>
)}

View File

@@ -0,0 +1,61 @@
import { Server } from "revolt.js";
import { useState } from "preact/hooks";
import { Form } from "@revoltchat/ui";
import { FileUploader } from "../../../controllers/client/jsx/legacy/FileUploads";
interface Props {
server: Server;
}
export function EmojiUploader({ server }: Props) {
const [fileId, setFileId] = useState<string>();
return (
<>
<h3>Upload Emoji</h3>
<Form
schema={{
name: "text",
file: "custom",
}}
data={{
name: {
field: "Name",
palette: "secondary",
},
file: {
element: (
<FileUploader
style="icon"
width={100}
height={100}
fileType="emojis"
behaviour="upload"
previewAfterUpload
maxFileSize={500000}
remove={async () => void setFileId("")}
onUpload={async (id) => void setFileId(id)}
/>
),
},
}}
submitBtn={{
children: "Save",
palette: "secondary",
disabled: !fileId,
}}
onSubmit={async ({ name }) => {
await server.client.api.put(`/custom/emoji/${fileId}`, {
name,
parent: { type: "Server", id: server._id },
});
setFileId("");
}}
/>
</>
);
}