Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dashboard bugg #9

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
82473f3
installation
Jan 18, 2022
16c27ce
rajout des .catch dans Login.js
Jan 19, 2022
47c7631
sortedBilled OK
Jan 19, 2022
392121d
error and lodin page tests
Jan 19, 2022
2ce444d
tests Bills.js terminé
Jan 19, 2022
5e5bd9c
commentaire
Jan 19, 2022
44a3178
début des newBills Tests
Jan 19, 2022
8d72426
test git
Jan 19, 2022
4c51cce
tests handleSubmit NewBills ok
Jan 19, 2022
07ca246
test du format de l'image lors de la soumission d'un newBill
Jan 20, 2022
3821bf0
commentaire et modif code
Jan 20, 2022
27212e4
commentaire + test si la modale s'ouvre lors du clique sur un oeil
Jan 21, 2022
3d8d7d6
commentaire
Jan 21, 2022
5d382e8
ajout des tests d'intégration de bills.js
Jan 21, 2022
b541439
ajout de commantaires istanbul ignore next
Jan 21, 2022
1a97cfc
ajout de la vérification de 'licone mail en surbrillance si on est su…
Jan 21, 2022
9be8c77
modif commentaire
Jan 21, 2022
0b2238d
com
Jan 22, 2022
e1e638e
modif css image justif (width à 100%)
Jan 22, 2022
b508695
css image justif dashboard + com
Jan 22, 2022
b027dd1
fix bug newBill
Jan 23, 2022
9e66b69
fix vertical navbar srcoll
Jan 23, 2022
4a74f88
commentaire dashboard.js
Jan 23, 2022
46260c3
com
Jan 23, 2022
e6ccb5b
fix bug 4
Jan 24, 2022
0f21464
fix bug 4
Jan 24, 2022
a2ddf40
test d(integration post
Jan 25, 2022
5b01834
com
Jan 25, 2022
5e9a673
ras
Jan 25, 2022
72a3b69
ajout d ela balise accept sur le justificatif
Jan 25, 2022
be5eef6
100% ok
Jan 26, 2022
576bd67
dernier réglages
Jan 26, 2022
5efea78
commentaire
Feb 1, 2022
f5a1e55
ajout des tests e2e
Feb 1, 2022
bccace6
derniere retouche
Feb 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
commentaire dashboard.js
  • Loading branch information
kirmann committed Jan 23, 2022
commit 4a74f88c46eb93331674567740af9c5bebed39cc
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 8080
}
1 change: 0 additions & 1 deletion src/__tests__/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,3 @@ describe("Given I am a user connected as Admin", () => {
})
})
})

54 changes: 39 additions & 15 deletions src/containers/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ import BigBilledIcon from '../assets/svg/big_billed.js'
import { ROUTES_PATH } from '../constants/routes.js'
import USERS_TEST from '../constants/usersTest.js'
import Logout from "./Logout.js"

// ???
/**
*
* @param {Object} data données a traiter
* @param {string} status status de la note de frais
* @returns
*/
export const filteredBills = (data, status) => {
return (data && data.length) ?
data.filter(bill => {
let selectCondition

// in jest environment
if (typeof jest !== 'undefined') {
selectCondition = (bill.status === status)
Expand All @@ -18,13 +23,18 @@ export const filteredBills = (data, status) => {
const userEmail = JSON.parse(localStorage.getItem("user")).email
selectCondition =
(bill.status === status) &&
![...USERS_TEST, userEmail].includes(bill.email)
}

![...USERS_TEST, userEmail].includes(bill.email)

}

return selectCondition
}) : []
}

/**
*
* @param {Object} bill note de frais a afficher
* @returns
*/
export const card = (bill) => {
const firstAndLastNames = bill.email.split('@')[0]
const firstName = firstAndLastNames.includes('.') ?
Expand All @@ -49,7 +59,11 @@ export const card = (bill) => {
</div>
`)
}

/**
*
* @param {Object} bills tableau d'objets a afficher
* @returns
*/
export const cards = (bills) => {
return bills && bills.length ? bills.map(bill => card(bill)).join("") : ""
}
Expand All @@ -70,11 +84,12 @@ export default class {
this.document = document
this.onNavigate = onNavigate
this.store = store
$('#arrow-icon1').click((e) => this.handleShowTickets(e, bills, 1))
$('#arrow-icon1').click((e) => this.handleShowTickets(e, bills, 1)) // lance la méthode handleShowTicket au click sur la flèche
$('#arrow-icon2').click((e) => this.handleShowTickets(e, bills, 2))
$('#arrow-icon3').click((e) => this.handleShowTickets(e, bills, 3))
this.getBillsAllUsers()
new Logout({ localStorage, onNavigate })

}

handleClickIconEye = () => {
Expand All @@ -88,8 +103,8 @@ export default class {
if (this.counter === undefined || this.id !== bill.id) this.counter = 0
if (this.id === undefined || this.id !== bill.id) this.id = bill.id
if (this.counter % 2 === 0) {
bills.forEach(b => {
$(`#open-bill${b.id}`).css({ background: '#0D5AE5' })
bills.forEach(bill => { //modif b en bill
$(`#open-bill${bill.id}`).css({ background: '#0D5AE5' }) // modif b en bill
})
$(`#open-bill${bill.id}`).css({ background: '#2A2B35' })
$('.dashboard-right-container div').html(DashboardFormUI(bill))
Expand Down Expand Up @@ -128,15 +143,23 @@ export default class {
this.updateBill(newBill)
this.onNavigate(ROUTES_PATH['Dashboard'])
}

/**
*
* @param {Event} e
* @param {Object} bills données a traiter récupérées de la bdd
* @param {*} index index de la flèche cliquée
* @returns
*/
handleShowTickets(e, bills, index) {
if (this.counter === undefined || this.index !== index) this.counter = 0
if (this.index === undefined || this.index !== index) this.index = index
if (this.counter % 2 === 0) {
if (this.counter === undefined || this.index !== index) this.counter = 0 // declare un compteur de click, si on ne clique pas sur la même flèeche le compteur se remet a 0
if (this.index === undefined || this.index !== index) this.index = index // défini l'index de la flèche sur laquelle on clique
if (this.counter % 2 === 0) { // crée un toggle pour afficher ou masquer le contenu
$(`#arrow-icon${this.index}`).css({ transform: 'rotate(0deg)'})
console.log($(`#arrow-icon${this.index}`));
$(`#status-bills-container${this.index}`)
.html(cards(filteredBills(bills, getStatus(this.index))))
this.counter ++
console.log(this.counter);
} else {
$(`#arrow-icon${this.index}`).css({ transform: 'rotate(90deg)'})
$(`#status-bills-container${this.index}`)
Expand All @@ -147,6 +170,7 @@ export default class {
bills.forEach(bill => {
$(`#open-bill${bill.id}`).click((e) => this.handleEditTicket(e, bill, bills))
})
console.log(bills.length);

return bills

Expand All @@ -166,7 +190,7 @@ export default class {
date: doc.date,
status: doc.status
}))
return bills
return bills //retourne les données a traiter de la bdd
})
.catch(console.log)
}
Expand Down