diff --git a/src/components/Common/Playground/Message.tsx b/src/components/Common/Playground/Message.tsx index bcdbd23..b21bbe1 100644 --- a/src/components/Common/Playground/Message.tsx +++ b/src/components/Common/Playground/Message.tsx @@ -14,6 +14,7 @@ import { EditMessageForm } from "./EditMessageForm" import { useTranslation } from "react-i18next" import { MessageSource } from "./MessageSource" import { useTTS } from "@/hooks/useTTS" +import { tagColors } from "@/utils/color" type Props = { message: string @@ -37,14 +38,6 @@ type Props = { isTTSEnabled?: boolean } -const tagColors = { - summary: "blue", - explain: "green", - translate: "purple", - custom: "orange", - rephrase: "yellow" -} - export const PlaygroundMessage = (props: Props) => { const [isBtnPressed, setIsBtnPressed] = React.useState(false) const [editMode, setEditMode] = React.useState(false) diff --git a/src/components/Option/Prompt/index.tsx b/src/components/Option/Prompt/index.tsx index f0d1c19..90642b8 100644 --- a/src/components/Option/Prompt/index.tsx +++ b/src/components/Option/Prompt/index.tsx @@ -8,12 +8,15 @@ import { Input, Form, Switch, - Segmented + Segmented, + Tag } from "antd" import { Trash2, Pen, Computer, Zap } from "lucide-react" import { useState } from "react" import { useTranslation } from "react-i18next" import { deletePromptById, getAllPrompts, savePrompt, updatePrompt } from "@/db" +import { getAllCopilotPrompts } from "@/services/application" +import { tagColors } from "@/utils/color" export const PromptBody = () => { const queryClient = useQueryClient() @@ -22,7 +25,7 @@ export const PromptBody = () => { const [editId, setEditId] = useState("") const [createForm] = Form.useForm() const [editForm] = Form.useForm() - const { t } = useTranslation("settings") + const { t } = useTranslation(["settings", "common"]) const [selectedSegment, setSelectedSegment] = useState<"custom" | "copilot">( "custom" ) @@ -31,6 +34,11 @@ export const PromptBody = () => { queryFn: getAllPrompts }) + const { data: copilotData, status: copilotStatus } = useQuery({ + queryKey: ["fetchCopilotPrompts"], + queryFn: getAllCopilotPrompts + }) + const { mutate: deletePrompt } = useMutation({ mutationFn: deletePromptById, onSuccess: () => { @@ -197,6 +205,63 @@ export const PromptBody = () => { ) } + + function copilotPrompts() { + return ( +
+ {copilotStatus === "pending" && } + + {copilotStatus === "success" && ( + ( + + + {t(`common:copilot.${content}`)} + + + ) + }, + { + title: t("managePrompts.columns.prompt"), + dataIndex: "prompt", + key: "prompt", + render: (content) => ( + {content} + ) + }, + { + title: t("managePrompts.columns.actions"), + render: (_, record) => ( +
+ + + +
+ ) + } + ]} + bordered + dataSource={copilotData} + rowKey={(record) => record.key} + /> + )} + + ) + } + return (
@@ -218,6 +283,7 @@ export const PromptBody = () => { />
{selectedSegment === "custom" && customPrompts()} + {selectedSegment === "copilot" && copilotPrompts()}