feat: Add park operators and owners to form

This commit is contained in:
gpt-engineer-app[bot]
2025-09-30 00:14:24 +00:00
parent 0ddae7493c
commit 28feea6264
4 changed files with 292 additions and 22 deletions

View File

@@ -200,4 +200,76 @@ export function useCompanyHeadquarters() {
}, []);
return { headquarters, loading };
}
export function useOperators() {
const [operators, setOperators] = useState<ComboboxOption[]>([]);
const [loading, setLoading] = useState(false);
useEffect(() => {
async function fetchOperators() {
setLoading(true);
try {
const { data, error } = await supabase
.from('companies')
.select('id, name')
.eq('company_type', 'operator')
.order('name');
if (error) throw error;
setOperators(
(data || []).map(company => ({
label: company.name,
value: company.id
}))
);
} catch (error) {
console.error('Error fetching operators:', error);
setOperators([]);
} finally {
setLoading(false);
}
}
fetchOperators();
}, []);
return { operators, loading };
}
export function usePropertyOwners() {
const [propertyOwners, setPropertyOwners] = useState<ComboboxOption[]>([]);
const [loading, setLoading] = useState(false);
useEffect(() => {
async function fetchPropertyOwners() {
setLoading(true);
try {
const { data, error } = await supabase
.from('companies')
.select('id, name')
.eq('company_type', 'property_owner')
.order('name');
if (error) throw error;
setPropertyOwners(
(data || []).map(company => ({
label: company.name,
value: company.id
}))
);
} catch (error) {
console.error('Error fetching property owners:', error);
setPropertyOwners([]);
} finally {
setLoading(false);
}
}
fetchPropertyOwners();
}, []);
return { propertyOwners, loading };
}