Skip to content

Commit

Permalink
Merge branch 'dev' into ui/add-menu
Browse files Browse the repository at this point in the history
# Conflicts:
#	frontend/app_student/pubspec.yaml
  • Loading branch information
PHPLukaas committed Mar 14, 2024
2 parents 523712b + 174f24d commit 05145f3
Show file tree
Hide file tree
Showing 28 changed files with 205 additions and 196 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
.vscode/
backend/vendor/
backend/vendor/
/backend/.php-cs-fixer.cache
4 changes: 2 additions & 2 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
###< symfony/framework-bundle ###

###> friendsofphp/php-cs-fixer ###
/.php-cs-fixer.php
/.php-cs-fixer.cache
.php-cs-fixer.php
.php-cs-fixer.cache
###< friendsofphp/php-cs-fixer ###
1 change: 0 additions & 1 deletion backend/.php-cs-fixer.cache

This file was deleted.

15 changes: 15 additions & 0 deletions backend/src/Entity/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class Event
#[ORM\JoinColumn(nullable: false)]
private ?DaySchedule $daySchedule = null;

#[ORM\Column]
private ?bool $repas = null;

public function getId(): ?int
{
return $this->id;
Expand Down Expand Up @@ -131,4 +134,16 @@ public function setDaySchedule(?DaySchedule $daySchedule): static

return $this;
}

public function isRepas(): ?bool
{
return $this->repas;
}

public function setRepas(bool $repas): static
{
$this->repas = $repas;

return $this;
}
}
1 change: 1 addition & 0 deletions backend/src/Service/TimetableService.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public function parseData(array $parsedData): array
$event->setCouleur($creneau['Couleur'] ?? '#000000');
$event->setHoraire($eventHours);
$event->setSalle($creneau['Salles'] ?? '');
$event->setRepas('3' === $creneau['Creneau'] && empty($creneau['Activite']));
$event->setVisio(str_contains($creneau['Salles'] ?? null, 'Teams'));

$daySchedule->addEvent($event);
Expand Down
40 changes: 30 additions & 10 deletions frontend/app_student/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
# app_student
# Application Flutter pour l'emploi du temps et les notes - Groupe 3iL

A new Flutter project.
Ce projet est une application mobile développée en Flutter par des étudiants du Groupe 3iL. Elle vise à fournir aux étudiants un accès facile à leur emploi du temps et à leurs notes.

## Getting Started
## Configuration

This project is a starting point for a Flutter application.
### Environnements

A few resources to get you started if this is your first Flutter project:
L'application est configurée pour fonctionner dans deux environnements différents : développement (dev) et production (prod). Chaque environnement utilise une API distincte.

- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
- **Dev**: Utilise une API de développement pour tester et déboguer l'application.
- **Prod**: Utilise une API de production pour une utilisation en direct.

For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
## Version de Flutter

Ce projet utilise Flutter version 3.19.2.

## Internationalisation (i18n)

L'application utilise la fonctionnalité de localisation (l10n) de Flutter pour supporter plusieurs langues. N'oubliez pas de générer les fichiers de localisation en exécutant `flutter gen-l10n` avant de construire l'application.

## Pré-requis

Avant de pousser votre code, assurez-vous de respecter les points suivants :

- Utilisez `dart format` pour formater votre code.
- Exécutez `flutter analyze` pour détecter tout problème dans votre code.
- Assurez-vous d'exécuter `pub get` pour installer toutes les dépendances du projet.

## Contributions

Les contributions des autres étudiants sont les bienvenues! N'hésitez pas à proposer des améliorations, des corrections de bugs ou de nouvelles fonctionnalités en soumettant des pull requests.

## Licence

Ce projet est destiné à des fins éducatives.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '../../events/entities/event_entity.dart';
import 'package:app_student/api/events/models/event_model.dart';
import '../entities/day_schedule_entity.dart';

class DayScheduleModel {
Expand All @@ -10,7 +10,8 @@ class DayScheduleModel {

int get jour => entity.jour;

List<EventEntity> get events => entity.events;
List<EventModel> get events =>
entity.events.map((e) => EventModel(entity: e)).toList();

factory DayScheduleModel.fromEntity(DayScheduleEntity entity) {
return DayScheduleModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ class EventModel {
String get couleur => entity.couleur;
EventHoursModel get horaires => EventHoursModel(entity: entity.horaires);
String get salle => entity.salle;
bool get visio => entity.visio;
}
6 changes: 2 additions & 4 deletions frontend/app_student/lib/api/users/entities/user_entity.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import 'package:app_student/api/class_groups/entities/class_group_entity.dart';

class UserEntity {
final String ine;
final String firstName;
final DateTime birthDate;
final ClassGroupEntity? classGroup;
final String? className;

UserEntity(
{required this.ine,
required this.firstName,
required this.birthDate,
this.classGroup});
this.className = ''});
}
1 change: 1 addition & 0 deletions frontend/app_student/lib/api/users/models/user_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ class UserModel {
String get file => entity.ine;
String get name => entity.firstName;
DateTime get birthDate => entity.birthDate;
String? get className => entity.className ?? '';
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:app_student/api/week_schedule/models/week_schedule_model.dart';
class WeekScheduleRepository {
final ApiService apiService;

WeekScheduleRepository({required this.apiService, required String className});
WeekScheduleRepository({required this.apiService});

Future<List<WeekScheduleModel>> getWeeksSchedule(className) {
return apiService.getData('/api/timetable?class_param=$className', (item) {
Expand Down
19 changes: 17 additions & 2 deletions frontend/app_student/lib/class_groups/cubit/class_group_cubit.dart
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
import 'package:app_student/api/class_groups/models/class_group_model.dart';
import 'package:app_student/api/class_groups/repositories/class_group_repository.dart';
import 'package:app_student/api/users/models/user_model.dart';
import 'package:bloc/bloc.dart';
import 'package:meta/meta.dart';

import '../../api/class_groups/repositories/class_group_repository.dart';
import '../../api/users/repositories/user_repository.dart';

part 'class_group_state.dart';

class ClassGroupCubit extends Cubit<ClassGroupState> {
final ClassGroupRepository classRepository;
final UserRepository userRepository;

ClassGroupCubit({required this.classRepository}) : super(ClassGroupInitial());
ClassGroupCubit({required this.classRepository, required this.userRepository})
: super(ClassGroupInitial());

Future<void> fetchClasses() async {
try {
emit(ClassGroupLoading());
final classes = await classRepository.getClasses();

emit(ClassGroupLoaded(classes));
} catch (e) {
emit(ClassGroupError(e.toString()));
}
}

Future<UserModel> getConnectedUser() async {
return userRepository.getUser();
}

Future<void> saveClass(ClassGroupModel classGroup) async {
await userRepository.saveUserClass(classGroup.name.toString());
emit(ClassGroupSelected());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ class ClassGroupLoaded extends ClassGroupState {
class ClassGroupError extends ClassGroupState {
final String message;

ClassGroupError(this.message);
ClassGroupError([this.message = 'An error occurred']);
}

class ClassGroupSelected extends ClassGroupState {}
45 changes: 0 additions & 45 deletions frontend/app_student/lib/class_groups/views/class_group_view.dart

This file was deleted.

26 changes: 11 additions & 15 deletions frontend/app_student/lib/login/cubit/login_cubit.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import 'package:app_student/api/users/repositories/user_repository.dart';
import 'package:bloc/bloc.dart';
import 'package:meta/meta.dart';
import 'package:shared_preferences/shared_preferences.dart';

part 'login_state.dart';

class LoginCubit extends Cubit<LoginState> {
LoginCubit() : super(LoginInitial()) {
final UserRepository userRepository;

LoginCubit(this.userRepository) : super(LoginInitial()) {
checkUserAuthentication();
}

Expand All @@ -23,24 +25,18 @@ class LoginCubit extends Cubit<LoginState> {
emit(LoginFieldError());
return;
}
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setString('ine', ine);
await prefs.setString('name', name);
await prefs.setString('birthDate', birthDate);
await userRepository.saveUserDetails(ine, name, birthDate, '');
emit(RedirectToClassSelection());
}

Future<void> checkUserAuthentication() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
String? ine = prefs.getString('ine');
String? name = prefs.getString('name');
String? birthDate = prefs.getString('birthDate');
String? className = prefs.getString('className');

if (ine != null && name != null && birthDate != null && className != null) {
Future<bool> checkUserAuthentication() async {
try {
await userRepository.getUser();
emit(LoginAuthenticated());
} else {
return true;
} catch (e) {
emit(LoginInitial());
return false;
}
}
}
Loading

0 comments on commit 05145f3

Please sign in to comment.