import { useContext, useEffect, useState } from "react";
import { useNavigate, useParams } from "react-router-dom";
import { CourseDetailContext } from "../PostDetailContext";
import { api } from "@nice/client";
import {
	DeleteTwoTone,
	EditTwoTone,
	ExclamationCircleFilled,
} from "@ant-design/icons";
import toast from "react-hot-toast";
import JoinButton from "./JoinButton";
import { Modal } from "antd";
import { useQueryClient } from "@tanstack/react-query";
import { getQueryKey } from "@trpc/react-query";

export default function CourseOperationBtns() {
	const navigate = useNavigate();
	const { post, canEdit } = useContext(CourseDetailContext);
	return (
		<>
			<JoinButton></JoinButton>
			{canEdit && (
				<>
					<div
						className="flex gap-1 px-1 py-0.5 text-primary hover:cursor-pointer"
						onClick={() => {
							const url = post?.id
								? `/course/${post?.id}/editor`
								: "/course/editor";
							navigate(url);
						}}>
						<EditTwoTone></EditTwoTone>
						{"编辑课程"}
					</div>
				</>


			)}
		</>
	);
}
