commit
a5d34b970e
@ -50,6 +50,22 @@ const OrdersNew = () => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
|
// State for property options
|
||||||
|
const [propertyOptions, setPropertyOptions] = useState([]);
|
||||||
|
|
||||||
|
// Fetch property options from your backend API
|
||||||
|
useEffect(() => {
|
||||||
|
fetch('https://vres.flatlogic.app/api/properties') // <-- uses deployed api
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(data => {
|
||||||
|
const options = data.map(property => ({
|
||||||
|
value: property.id,
|
||||||
|
label: property.name,
|
||||||
|
}));
|
||||||
|
setPropertyOptions(options);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleSubmit = async (data) => {
|
const handleSubmit = async (data) => {
|
||||||
await dispatch(create(data));
|
await dispatch(create(data));
|
||||||
await router.push('/orders/orders-list');
|
await router.push('/orders/orders-list');
|
||||||
@ -88,9 +104,9 @@ const OrdersNew = () => {
|
|||||||
name='property'
|
name='property'
|
||||||
id='property'
|
id='property'
|
||||||
component={SelectField}
|
component={SelectField}
|
||||||
options={[]}
|
options={propertyOptions}
|
||||||
itemRef={'properties'}
|
itemRef={'properties'}
|
||||||
></Field>
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
<FormField label='RequestedDate'>
|
<FormField label='RequestedDate'>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user