2026-10-08 22:27:19 +00:00
|
|
|
import type { AssetDTO } from "@metis/assets/common";
|
|
|
|
|
import type { ResourceDTO } from "@metis/resources/common";
|
|
|
|
|
|
|
|
|
|
import type { CompanyDTO } from "../../../../common";
|
|
|
|
|
import type { RemoteConnectionInput } from "../../../../common/remote-connections";
|
|
|
|
|
|
|
|
|
|
export function remoteEndpoints(
|
|
|
|
|
values: RemoteConnectionInput,
|
|
|
|
|
company: CompanyDTO,
|
|
|
|
|
assets: readonly AssetDTO[],
|
|
|
|
|
resources: readonly ResourceDTO[],
|
|
|
|
|
t: (key: string) => string
|
|
|
|
|
) {
|
|
|
|
|
const source =
|
|
|
|
|
values.sourceKind === "company_asset"
|
|
|
|
|
? (assets.find((item) => item.id === values.sourceAssetId)?.values.name ??
|
|
|
|
|
values.sourceAssetId ??
|
|
|
|
|
"—")
|
|
|
|
|
: t(`remote.${values.sourceKind}`);
|
|
|
|
|
const target =
|
|
|
|
|
values.targetKind === "network"
|
|
|
|
|
? `${t("remote.network")} · ${company.sites.find((site) => site.id === values.siteId)?.name ?? company.name}`
|
|
|
|
|
: values.targetKind === "asset"
|
|
|
|
|
? (assets.find((item) => item.id === values.targetId)?.values.name ??
|
|
|
|
|
values.targetId ??
|
|
|
|
|
"—")
|
|
|
|
|
: (resources.find((item) => item.id === values.targetId)?.values.name ??
|
|
|
|
|
values.targetId ??
|
|
|
|
|
"—");
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-08 22:27:19 +00:00
|
|
|
return { source, target };
|
|
|
|
|
}
|