commit
a5d34b970e
@ -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('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) => {
|
||||
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'>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user