From 2382294e8baa0a014a6a642f0f7642dcdd9e2bdf Mon Sep 17 00:00:00 2001
From: jenku <80538856+jenkuuuuuu@users.noreply.github.com>
Date: Thu, 1 Aug 2024 09:57:00 +0100
Subject: [PATCH] Decor: add copy preset id button (#2737)

Co-authored-by: v <vendicated@riseup.net>
---
 .../decor/ui/modals/ChangeDecorationModal.tsx | 23 +++++++++++++++----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/plugins/decor/ui/modals/ChangeDecorationModal.tsx b/src/plugins/decor/ui/modals/ChangeDecorationModal.tsx
index 5fbe165c..6501e0fe 100644
--- a/src/plugins/decor/ui/modals/ChangeDecorationModal.tsx
+++ b/src/plugins/decor/ui/modals/ChangeDecorationModal.tsx
@@ -8,7 +8,7 @@ import ErrorBoundary from "@components/ErrorBoundary";
 import { Flex } from "@components/Flex";
 import { openInviteModal } from "@utils/discord";
 import { Margins } from "@utils/margins";
-import { classes } from "@utils/misc";
+import { classes, copyWithToast } from "@utils/misc";
 import { closeAllModals, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
 import { findComponentByCodeLazy } from "@webpack";
 import { Alerts, Button, FluxDispatcher, Forms, GuildStore, NavigationRouter, Parser, Text, Tooltip, useEffect, UserStore, UserUtils, useState } from "@webpack/common";
@@ -45,7 +45,11 @@ interface Section {
     authorIds?: string[];
 }
 
-function SectionHeader({ section }: { section: Section; }) {
+interface SectionHeaderProps {
+    section: Section;
+}
+
+function SectionHeader({ section }: SectionHeaderProps) {
     const hasSubtitle = typeof section.subtitle !== "undefined";
     const hasAuthorIds = typeof section.authorIds !== "undefined";
 
@@ -62,6 +66,7 @@ function SectionHeader({ section }: { section: Section; }) {
         })();
     }, [section.authorIds]);
 
+
     return <div>
         <Flex>
             <Forms.FormTitle style={{ flexGrow: 1 }}>{section.title}</Forms.FormTitle>
@@ -74,8 +79,7 @@ function SectionHeader({ section }: { section: Section; }) {
                 size={16}
                 showUserPopout
                 className={Margins.bottom8}
-            />
-            }
+            />}
         </Flex>
         {hasSubtitle &&
             <Forms.FormText type="description" className={Margins.bottom8}>
@@ -204,7 +208,16 @@ function ChangeDecorationModal(props: ModalProps) {
                             {activeSelectedDecoration?.alt}
                         </Text>
                     }
-                    {activeDecorationHasAuthor && <Text key={`createdBy-${activeSelectedDecoration.authorId}`}>Created by {Parser.parse(`<@${activeSelectedDecoration.authorId}>`)}</Text>}
+                    {activeDecorationHasAuthor && (
+                        <Text key={`createdBy-${activeSelectedDecoration.authorId}`}>
+                            Created by {Parser.parse(`<@${activeSelectedDecoration.authorId}>`)}
+                        </Text>
+                    )}
+                    {isActiveDecorationPreset && (
+                        <Button onClick={() => copyWithToast(activeDecorationPreset.id)}>
+                            Copy Preset ID
+                        </Button>
+                    )}
                 </div>
             </ErrorBoundary>
         </ModalContent>