File size: 2,271 Bytes
c10f8f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { useState } from "react";
import { WandSparkles } from "lucide-react";

import { Button } from "@/components/ui/button";
import { useEditor } from "@/hooks/useEditor";
import { useAi } from "@/hooks/useAi";
import {
  Dialog,
  DialogContent,
  DialogFooter,
  DialogTitle,
} from "@/components/ui/dialog";
import { ContentModal } from "./content-modal";
import { EnhancedSettings } from "@/types";

export const PromptBuilder = ({
  enhancedSettings,
  setEnhancedSettings,
}: {
  enhancedSettings: EnhancedSettings;
  setEnhancedSettings: (settings: EnhancedSettings) => void;
}) => {
  const { globalAiLoading } = useAi();
  const { globalEditorLoading } = useEditor();

  const [open, setOpen] = useState(false);
  return (
    <>
      <Button
        size="xs"
        variant="outline"
        className="!rounded-md !border-white/10 !bg-gradient-to-r from-sky-400/15 to-purple-400/15 light-sweep hover:brightness-110"
        disabled={globalAiLoading || globalEditorLoading}
        onClick={() => {
          setOpen(true);
        }}
      >
        <WandSparkles className="size-3.5 text-sky-500 relative z-10" />
        <span className="text-transparent bg-gradient-to-r from-sky-400 to-purple-400 bg-clip-text relative z-10">
          Enhance
        </span>
      </Button>
      <Dialog open={open} onOpenChange={() => setOpen(false)}>
        <DialogContent className="sm:max-w-xl !p-0 !rounded-3xl !bg-neutral-900 !border-neutral-800/80 !gap-0">
          <DialogTitle className="px-6 py-3.5 border-b border-neutral-800">
            <div className="flex items-center justify-start gap-2 text-neutral-200 text-base font-medium">
              <WandSparkles className="size-3.5" />
              <p>Enhance Prompt</p>
            </div>
          </DialogTitle>
          <ContentModal
            enhancedSettings={enhancedSettings}
            setEnhancedSettings={setEnhancedSettings}
          />
          <DialogFooter className="px-6 py-3.5 border-t border-neutral-800">
            <Button
              variant="bordered"
              size="default"
              onClick={() => setOpen(false)}
            >
              Close
            </Button>
          </DialogFooter>
        </DialogContent>
      </Dialog>
    </>
  );
};