import React from "react";
import styles from "./postswitched.module.css";
import { PiHandDepositLight } from "react-icons/pi";
import { useRouter } from "next/navigation";
import Button from "@/components/ui/Button/button";

const PostSwitched = (props) => {
  const router = useRouter();

  return (
    <div className={styles.container}>
      <div className={styles.icon_container}>
        <PiHandDepositLight className={styles.icon} />
      </div>
      <div className={styles.message}>
        <p>
          This post is now being edited by{" "}
          {props?.data?.user?.name || "someone"}.
        </p>
        <p>The changes you made will not be saved.</p>
      </div>
      <Button
        className={styles.button}
        onClick={() => {
          router.push("/dashboard/posts");
          props.action.close();
        }}>
        Posts List
      </Button>
    </div>
  );
};

export default PostSwitched;
