From 918f0fa0f3a56c8dbd0ee45a4fb7a2c2baa3e8e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Thu, 23 Jun 2022 14:14:03 -0300 Subject: [PATCH] Support multiple classes for a single assignment --- src/components/AssignmentCard.js | 37 ++++++++++++++++++++++++--- src/context/user.js | 43 ++++++++++++++++++++++++++++++++ src/screens/Home/index.js | 8 +++++- 3 files changed, 83 insertions(+), 5 deletions(-) diff --git a/src/components/AssignmentCard.js b/src/components/AssignmentCard.js index c8443a1..2889443 100644 --- a/src/components/AssignmentCard.js +++ b/src/components/AssignmentCard.js @@ -12,15 +12,30 @@ import dayjs from 'dayjs'; import { capitalizeFirstLetter } from '../utils/capitalizeFirstLetter'; function AssignmentCard({ title, classrooms, dueDate, scores, layoutType }) { + console.log(classrooms); switch (layoutType) { case 'desktop': return ( + {classrooms.length > 1 && + classrooms + .filter((_, i) => i > 0) + .map(c => ( +
+ ))} - {classrooms.map(c => c.name).join(',')} + {classrooms.map(c => c.name).join(', ')} Valor: - {scores.map(s => s.value).join(',')} pts + {scores.map(s => s.value).join(', ')} pts @@ -85,10 +100,24 @@ function AssignmentCard({ title, classrooms, dueDate, scores, layoutType }) { > + {classrooms.length > 1 && + classrooms + .filter((_, i) => i > 0) + .map(c => ( +
+ ))} - {classrooms.map(c => c.name).join(',')} + {classrooms.map(c => c.name).join(', ')} Valor: - {scores.map(s => s.value).join(',')} pts + {scores.map(s => s.value).join(', ')} pts diff --git a/src/context/user.js b/src/context/user.js index 4a97767..c6242ca 100644 --- a/src/context/user.js +++ b/src/context/user.js @@ -194,6 +194,49 @@ const getAssignments = userId => }, ], }, + { + id: '1717', + title: 'Trabalho interdisciplinar', + dueDate: '2022-08-20 23:59', + scores: [ + { + classroomId: '666', + value: 20, + }, + { + classroomId: '321', + value: 30, + }, + ], + classrooms: [ + { + id: '666', + name: 'Banco de Dados II', + abbreviation: 'BDII', + color: '#FF7A00', + teachers: [ + { + name: 'Cristiane Norbiato Targa', + avatar: + 'https://lh3.googleusercontent.com/a-/AOh14GhwNeQ0h2eKl2WXGuwyDzvLWtrvyrG2kJtZ7A1EBw=s75-c', + }, + ], + }, + { + id: '321', + name: 'Introdução à Ciência de Dados', + abbreviation: 'ICD', + color: '#006FF2', + teachers: [ + { + name: 'Carlos Alexandre Silva', + avatar: + 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=50&q=80', + }, + ], + }, + ], + }, ], }; }); diff --git a/src/screens/Home/index.js b/src/screens/Home/index.js index f0b50d9..665ec23 100644 --- a/src/screens/Home/index.js +++ b/src/screens/Home/index.js @@ -70,7 +70,13 @@ function Home() {

Atividades

Atribuídas

- + {assignments === null ? ( Array(6) .fill()