Temporary fix on date/data payment

This commit is contained in:
Joao Ramos
2023-12-12 22:48:38 +00:00
parent 4cbd045502
commit 1cff6fe242

View File

@@ -18,7 +18,10 @@ const auth = getAuth(app);
export default withIronSessionApiRoute(handler, sessionOptions);
const addPaymentRecord = async (data: Payment) => {
// TODO: Data is set as any as data cannot be parsed to Payment
// because the id is not a par of the hash and payment expects date to be of type Date
// but if it is not inserted as a string, some UI components will not work (Invalid Date)
const addPaymentRecord = async (data: any) => {
const shortUID = new ShortUniqueId();
await setDoc(doc(db, "payments", shortUID.randomUUID(8)), data);
}
@@ -33,8 +36,8 @@ const managePaymentRecords = async (user: User, userId: string | undefined): Pro
currency: user.corporateInformation.payment!.currency,
value: user.corporateInformation.payment!.value,
isPaid: false,
date: new Date(),
} as Payment;
date: new Date().toISOString(),
};
const corporatePayments = await getDocs(query(collection(db, "payments"), where("corporate", "==", userId)));
if(corporatePayments.docs.length === 0) {