From ef0d1a041d410d1c416f854db38583d99d2ed7bb Mon Sep 17 00:00:00 2001 From: Dominic Villemure Date: Sat, 18 May 2024 12:06:17 -0400 Subject: [PATCH 1/4] #42 formatting date --- src/layouts/DefaultLayout.vue | 1 - src/models/myUserModel.js | 13 +++++++++++-- src/models/userTransactionsModel.js | 15 +++++++++++++-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/layouts/DefaultLayout.vue b/src/layouts/DefaultLayout.vue index d59a345..c034870 100644 --- a/src/layouts/DefaultLayout.vue +++ b/src/layouts/DefaultLayout.vue @@ -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%' } diff --git a/src/models/myUserModel.js b/src/models/myUserModel.js index cb4d0b2..0763628 100644 --- a/src/models/myUserModel.js +++ b/src/models/myUserModel.js @@ -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; } } \ No newline at end of file diff --git a/src/models/userTransactionsModel.js b/src/models/userTransactionsModel.js index 6195496..83ecaeb 100644 --- a/src/models/userTransactionsModel.js +++ b/src/models/userTransactionsModel.js @@ -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; } } \ No newline at end of file From 35b43a300dc85b416e18ae6a81e11f093a78c93d Mon Sep 17 00:00:00 2001 From: Dominic Villemure Date: Sat, 18 May 2024 12:08:59 -0400 Subject: [PATCH 2/4] #42 width 20% + 20% + 60% --- src/layouts/DefaultLayout.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/layouts/DefaultLayout.vue b/src/layouts/DefaultLayout.vue index c034870..fd6981e 100644 --- a/src/layouts/DefaultLayout.vue +++ b/src/layouts/DefaultLayout.vue @@ -146,8 +146,8 @@ const currentUserName = ref("INVITÉ"); let currentUser = null; const headers = ref([ - { title: 'Montant', value: 'amount', width: '10%' }, - { title: 'Date', value: 'created', width: '10%' }, + { title: 'Montant', value: 'amount', width: '20%' }, + { title: 'Date', value: 'created', width: '20%' }, { title: 'Message', value: 'tipMessage', width: '60%' } ]); From bb4d032ae93228ae4a0b8b4aa3901e5138e8411e Mon Sep 17 00:00:00 2001 From: Dominic Villemure Date: Sat, 18 May 2024 12:11:22 -0400 Subject: [PATCH 3/4] #42 added ordering on amount and created --- src/layouts/DefaultLayout.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/layouts/DefaultLayout.vue b/src/layouts/DefaultLayout.vue index fd6981e..338d740 100644 --- a/src/layouts/DefaultLayout.vue +++ b/src/layouts/DefaultLayout.vue @@ -146,8 +146,8 @@ const currentUserName = ref("INVITÉ"); let currentUser = null; const headers = ref([ - { title: 'Montant', value: 'amount', width: '20%' }, - { title: 'Date', value: 'created', width: '20%' }, + { title: 'Montant', value: 'amount', width: '20%', key: "amount" }, + { title: 'Date', value: 'created', width: '20%', key: "created" }, { title: 'Message', value: 'tipMessage', width: '60%' } ]); From 5bc01f90da9a6b5a9f0db5e386ab05da7c9f3b85 Mon Sep 17 00:00:00 2001 From: Dominic Villemure Date: Sat, 18 May 2024 12:19:45 -0400 Subject: [PATCH 4/4] #42 with fixed headers --- src/layouts/DefaultLayout.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layouts/DefaultLayout.vue b/src/layouts/DefaultLayout.vue index 338d740..66dfd39 100644 --- a/src/layouts/DefaultLayout.vue +++ b/src/layouts/DefaultLayout.vue @@ -71,7 +71,7 @@ -