Fetch property options for new orders page

This commit is contained in:
lora322 2025-09-11 11:58:33 -04:00 committed by GitHub
parent 07c7c345d8
commit 6de7feefc1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -50,6 +50,22 @@ const OrdersNew = () => {
const router = useRouter();
const dispatch = useAppDispatch();
// State for property options
const [propertyOptions, setPropertyOptions] = useState([]);
// Fetch property options from your backend API
useEffect(() => {
fetch('/api/properties') // <-- update as appropriate
.then(res => res.json())
.then(data => {
const options = data.map(property => ({
value: property.id,
label: property.name,
}));
setPropertyOptions(options);
});
}, []);
const handleSubmit = async (data) => {
await dispatch(create(data));
await router.push('/orders/orders-list');
@ -88,9 +104,9 @@ const OrdersNew = () => {
name='property'
id='property'
component={SelectField}
options={[]}
options={propertyOptions}
itemRef={'properties'}
></Field>
/>
</FormField>
<FormField label='RequestedDate'>