#42 formatting date

This commit is contained in:
Dominic Villemure
2024-05-18 12:06:17 -04:00
parent 768ab72713
commit ef0d1a041d
3 changed files with 24 additions and 5 deletions

View File

@@ -146,7 +146,6 @@ const currentUserName = ref("INVITÉ");
let currentUser = null;
const headers = ref([
{ title: 'Transaction', value: 'index', width: '10%' },
{ title: 'Montant', value: 'amount', width: '10%' },
{ title: 'Date', value: 'created', width: '10%' },
{ title: 'Message', value: 'tipMessage', width: '60%' }

View File

@@ -7,9 +7,18 @@ export default class MyUserModel
lastName = "";
userName = "";
totalBalance = "";
userTransactions = new UserTransactionsModel()
userTransactions = [];
static createFromApiResult(apiResult){
return Object.assign(new MyUserModel(), apiResult);
const userModel = Object.assign(new MyUserModel(), apiResult);
const notMapperTransaction = Object.freeze(userModel.userTransactions);
userModel.userTransactions = [];
for (const transaction of notMapperTransaction) {
userModel.userTransactions.push(UserTransactionsModel.createFromApiResult(transaction))
}
return userModel;
}
}

View File

@@ -6,7 +6,18 @@ export default class UserTransactionsModel
created = "";
createFromApiResult(apiResult){
return Object.assign(apiResult, new UserTransactionsModel())
static createFromApiResult(apiResult){
const userTransactionModel = Object.assign(new UserTransactionsModel(), apiResult)
const date = new Date(userTransactionModel.created);
const options = {
year: 'numeric',
month: 'long',
day: 'numeric',
timeZone: 'America/Montreal'
};
userTransactionModel.created = new Intl.DateTimeFormat('fr-CA', options).format(date);
return userTransactionModel;
}
}