import { useTranslation } from "react-i18next";

import { ZoneModel } from "@/contracts/client.schemas";

export const useGetZoneName = (zones: ZoneModel[]) => {
	const { t } = useTranslation("translation");
	return {
		getName: (index?: number) => {
			const name = zones.find((x) => x.index === index)?.name;

			if (
				!name ||
				(name?.startsWith("Zone") &&
					name?.endsWith((index || 0)?.toFixed(0)))
			) {
				return `${t("zone")} ${index}`;
			}

			return name;
		},
	};
};
