I’m doing a CRUD. I want to modify an Order so the form has to show the current date.
<code>const response = await axios.get(`http://localhost:8000/api/orders/${id}/`, {
headers: {
'Authorization': `Token ${Cookies.get('token')}`
}
});
const orderDetails = response.data;
setFormData({
supplier: orderDetails.supplier,
date: orderDetails.date,
total: orderDetails.total,
description: orderDetails.description
});
</code>
<code>const response = await axios.get(`http://localhost:8000/api/orders/${id}/`, {
headers: {
'Authorization': `Token ${Cookies.get('token')}`
}
});
const orderDetails = response.data;
setFormData({
supplier: orderDetails.supplier,
date: orderDetails.date,
total: orderDetails.total,
description: orderDetails.description
});
</code>
const response = await axios.get(`http://localhost:8000/api/orders/${id}/`, {
headers: {
'Authorization': `Token ${Cookies.get('token')}`
}
});
const orderDetails = response.data;
setFormData({
supplier: orderDetails.supplier,
date: orderDetails.date,
total: orderDetails.total,
description: orderDetails.description
});
I have the DatePicker from NextUI
<code><div className="w-full max-w-xl flex flex-row gap-4">
<DatePicker
label='Fecha'
showMonthAndYearPickers
value={formData.date}
onChange={(value) => handleDateChange(value)}
/>
</div>
</code>
<code><div className="w-full max-w-xl flex flex-row gap-4">
<DatePicker
label='Fecha'
showMonthAndYearPickers
value={formData.date}
onChange={(value) => handleDateChange(value)}
/>
</div>
</code>
<div className="w-full max-w-xl flex flex-row gap-4">
<DatePicker
label='Fecha'
showMonthAndYearPickers
value={formData.date}
onChange={(value) => handleDateChange(value)}
/>
</div>
when I choose an Order I get the error: TypeError: value.toDate is not a function
I tried with new Date(formData.date)
and with parseAbsoluteToLocal(orderDetails.date)
but It’s doesn’t work.