import React from "react";

import styles from "@/app/(Admin)/dashboard/(Posts Zone)/tags/[slug]/tags.add.module.css";

import Link from "next/link";
import { notFound } from "next/navigation";

import { getTagById } from "@/models/term";
import { BsArrowLeft } from "react-icons/bs";
import TagEditor from "@/components/administrator/TagEditor/tag.editor";

const TagItem = async ({ params }) => {
  try {
    const query = await params;
    const id = query.slug;

    const tag = await getTagById(id);

    return (
      <div className={styles.container}>
        <div className={styles.header}>
          <Link
            className={styles.back}
            href="/dashboard/tags">
            <BsArrowLeft /> back
          </Link>
        </div>
        <div className={styles.body}>
          <TagEditor data={tag} />
        </div>
      </div>
    );
  } catch (error) {
    console.log(error);
    return notFound();
  }
};

export default TagItem;
