import { FC } from "react";
import { useTranslation } from "react-i18next";

import { InformationView } from "@/shared";

import { IdName } from "../models/IdName";

export interface ObjectInfo {
	equipmentIds?: string;
	name?: string;
	shortDescription?: string;
	country?: string;
	region?: string;
	city?: string;
	street?: string;
	house?: string;
	building?: string;
	gateCode?: string;
	intercomCode?: string;
	appNumber?: string;
	owner?: string;
	phone1?: string;
	phone2?: string;
	ownerPassword?: string;
	contractNumber?: string;
	contractDate?: string;
	description?: string;
	groups: IdName[];
	imei?: string;
}
export interface ObjectInformationProps {
	object: ObjectInfo;
}

export const ObjectInformation: FC<ObjectInformationProps> = ({ object }) => {
	const { t } = useTranslation("translation");

	return (
		<InformationView
			groups={[
				{
					key: "information",
					label: t("Information about object"),
					items: [
						{
							key: "full-name",
							label: t("Full name"),
							value: object.name || "-",
						},
						{
							key: "description",
							label: t("description"),
							value: object.description || "-",
						},
					],
					direction: "column",
				},
				{
					key: "location",
					label: t("Location"),
					items: [
						{
							key: "region",
							label: t("Region"),
							value: object.region || "-",
						},
						{
							key: "city",
							label: t("City"),
							value: object.city || "-",
						},
						{
							key: "street",
							label: t("Street/Avenue"),
							value: object.street || "-",
						},
						{
							key: "house",
							label: t("House/Building"),
							value: object.house || "-",
						},
					],
					direction: "row",
				},
				{
					key: "contacts",
					label: t("Contacts"),
					items: [
						{
							key: "email",
							label: t("Email"),
							value: object.owner || "-",
						},
						{
							key: "phone-number-1",
							label: t("Phone number 1"),
							value: object.phone1 || "-",
						},
						{
							key: "phone-number-2",
							label: t("Phone number 2"),
							value: object.phone2 || "-",
						},
					],
					direction: "row",
				},
				{
					key: "comments",
					label: t("Commentary"),
					items: [
						{
							key: "email",
							label: "",
							value: object.shortDescription || "-",
						},
					],
					direction: "row",
				},
			]}
		/>
	);
};
