"use client";

import React from "react";
import { observer } from "mobx-react-lite";
import Link from "next/link";
import Image from "next/image";
import { useTheme } from "next-themes";
// ui
import { Button, getButtonStyling } from "@plane/ui";
// helpers
import { resolveGeneralTheme } from "helpers/common.helper";
// icons
import TakeoffIconLight from "/public/logos/takeoff-icon-light.svg";
import TakeoffIconDark from "/public/logos/takeoff-icon-dark.svg";

type Props = {
  isOpen: boolean;
  onClose?: () => void;
};

export const CreateWorkspacePopup: React.FC<Props> = observer((props) => {
  const { isOpen, onClose } = props;
  // theme
  const { resolvedTheme } = useTheme();

  const handleClose = () => {
    onClose && onClose();
  };

  if (!isOpen) return null;

  return (
    <div className="absolute bottom-8 right-6 p-6 w-96 border border-custom-border-100 shadow-md rounded-xl bg-custom-background-100 z-20">
      <div className="flex gap-4">
        <div className="grow">
          <div className="text-base font-semibold">Create workspace</div>
          <div className="py-2 text-sm font-medium text-custom-text-300">
            Instance setup done! Welcome to Plane instance portal. Start your journey with by creating your first
            workspace, you will need to login again.
          </div>
          <div className="flex items-center gap-4 pt-2">
            <Link href="/create-workspace" className={getButtonStyling("primary", "sm")}>
              Create workspace
            </Link>
            <Button variant="neutral-primary" size="sm" onClick={handleClose}>
              Close
            </Button>
          </div>
        </div>
        <div className="shrink-0 flex items-center justify-center">
          <Image
            src={resolveGeneralTheme(resolvedTheme) === "dark" ? TakeoffIconDark : TakeoffIconLight}
            height={80}
            width={80}
            alt="Plane icon"
          />
        </div>
      </div>
    </div>
  );
});
