payouts
This commit is contained in:
@@ -28,9 +28,24 @@ const RentItem: React.FC = () => {
|
||||
|
||||
const [totalCost, setTotalCost] = useState(0);
|
||||
|
||||
const convertToUTC = (dateString: string, timeString: string): string => {
|
||||
if (!dateString || !timeString) {
|
||||
throw new Error("Date and time are required");
|
||||
}
|
||||
|
||||
// Create date in user's local timezone
|
||||
const localDateTime = new Date(`${dateString}T${timeString}`);
|
||||
|
||||
// Return UTC ISO string
|
||||
return localDateTime.toISOString();
|
||||
};
|
||||
|
||||
const formatDate = (dateString: string) => {
|
||||
if (!dateString) return "";
|
||||
return new Date(dateString).toLocaleDateString();
|
||||
// Use safe date parsing to avoid timezone issues
|
||||
const [year, month, day] = dateString.split("-");
|
||||
const date = new Date(parseInt(year), parseInt(month) - 1, parseInt(day));
|
||||
return date.toLocaleDateString();
|
||||
};
|
||||
|
||||
const formatTime = (timeString: string) => {
|
||||
@@ -167,10 +182,14 @@ const RentItem: React.FC = () => {
|
||||
itemName={item.name}
|
||||
rentalData={{
|
||||
itemId: item.id,
|
||||
startDate: manualSelection.startDate,
|
||||
endDate: manualSelection.endDate,
|
||||
startTime: manualSelection.startTime,
|
||||
endTime: manualSelection.endTime,
|
||||
startDateTime: convertToUTC(
|
||||
manualSelection.startDate,
|
||||
manualSelection.startTime
|
||||
),
|
||||
endDateTime: convertToUTC(
|
||||
manualSelection.endDate,
|
||||
manualSelection.endTime
|
||||
),
|
||||
totalAmount: totalCost,
|
||||
deliveryMethod: "pickup",
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user