LAD patch

This commit is contained in:
Joao Victor 2022-01-17 11:50:11 -03:00
parent 16ca899fcc
commit 79e96c0adc
3 changed files with 11 additions and 9 deletions

View File

@ -10,7 +10,7 @@ function Card(props) {
try {
React.Children.only(children);
icons = (
<div className={`p-2 text-orange-500 rounded-full ${iconClass}`}>
<div className={`p-2 rounded-full ${iconClass || 'text-orange-500'}`}>
{ children }
</div>
);
@ -23,7 +23,7 @@ function Card(props) {
offset = index === (React.Children.count(children) - 1) ? 0 : offset;
return (
<div className={`flex justify-center transform translate-x-${offset} border-2 border-white p-2 text-orange-500 rounded-full z-${index * 10} ${iconClass}`}>
<div className={`flex justify-center transform translate-x-${offset} border-2 border-white p-2 rounded-full z-${index * 10} ${iconClass || 'text-orange-500'}`}>
{ child }
</div>
);

View File

@ -9,7 +9,9 @@ class PollsTable extends React.Component {
function getUserAnswer(user, poll) {
if (typeof user.answers[poll.pollId] !== 'undefined') {
return user.answers[poll.pollId];
return Array.isArray(user.answers[poll.pollId])
? user.answers[poll.pollId]
: [user.answers[poll.pollId]];
}
return [];
}
@ -17,7 +19,7 @@ class PollsTable extends React.Component {
if (typeof polls === 'object' && Object.values(polls).length === 0) {
return (
<div className="flex flex-col items-center py-24">
<div className="mb-1 p-3 text-orange-500 rounded-full bg-blue-100 text-blue-500">
<div className="mb-1 p-3 rounded-full bg-blue-100 text-blue-500">
<svg
xmlns="http://www.w3.org/2000/svg"
className="h-6 w-6"

View File

@ -46,8 +46,10 @@ export function getActivityScore(user, allUsers, totalOfPolls) {
export function getSumOfTime(eventsArr) {
return eventsArr.reduce((prevVal, elem) => {
if (elem.stoppedOn > 0) return prevVal + (elem.stoppedOn - elem.startedOn);
return prevVal + (new Date().getTime() - elem.startedOn);
if ((elem.stoppedOn || elem.registeredOn) > 0) {
return prevVal + ((elem.stoppedOn || elem.leftOn) - (elem.startedOn || elem.registeredOn));
}
return prevVal + (new Date().getTime() - (elem.startedOn || elem.registeredOn));
}, 0);
}
@ -118,9 +120,7 @@ export function makeUserCSVData(users, polls, intl) {
for (let i = 0; i < userValues.length; i += 1) {
const user = userValues[i];
const webcam = getSumOfTime(user.webcams);
const duration = user.leftOn > 0
? user.leftOn - user.registeredOn
: (new Date()).getTime() - user.registeredOn;
const duration = getSumOfTime(Object.values(user.intIds));
const userData = {
name: user.name,