import type { CompanyDbModel } from '../Pages/Companies/Components/CompaniesComponents.helper';

export default function getCompanyType(
	selectedCompany: CompanyDbModel | null | undefined
): string | null {
	if (!selectedCompany || !selectedCompany.industry_type) return null;

	if (typeof selectedCompany.industry_type === 'string') {
		return selectedCompany.industry_type;
	}

	if (
		typeof selectedCompany.industry_type === 'object' &&
		'value' in selectedCompany.industry_type
	) {
		return (selectedCompany.industry_type as { value: string }).value || null;
	}

	return null;
}
