From a0458eeaddfede7c2acc8fd660950d7e37194fa5 Mon Sep 17 00:00:00 2001
From: Faneva <faneva.rakotoarivony@polymtl.ca>
Date: Sun, 13 Feb 2022 03:26:25 -0500
Subject: [PATCH] Bootstrap not working

---
 assets/calendar.js                  | 35 ++++++++++++++++++-----------
 config/packages/twig.yaml           |  2 +-
 src/Controller/SignUpController.php | 33 +++++++++++++++++++++++++++
 src/Form/UserType.php               | 33 +++++++++++++++++++++++++++
 templates/calendar/index.html.twig  |  2 ++
 templates/sign_up/index.html.twig   |  9 ++++++++
 6 files changed, 100 insertions(+), 14 deletions(-)
 create mode 100644 src/Controller/SignUpController.php
 create mode 100644 src/Form/UserType.php
 create mode 100644 templates/sign_up/index.html.twig

diff --git a/assets/calendar.js b/assets/calendar.js
index 73f58eb4..56af72e5 100644
--- a/assets/calendar.js
+++ b/assets/calendar.js
@@ -21,19 +21,27 @@ $(function () {
     useCreationPopup: true,
     useDetailPopup: true
   });
+  console.log(calendar);
 
+  function getStartAndEndDates() {
+    let dateStart = String(calendar.getDateRangeStart().toDate()).slice(4, 15);
+    document.getElementById("dateStart").innerHTML = dateStart;
+    let dateEnd = String(calendar.getDateRangeEnd().toDate()).slice(4, 15);
+    document.getElementById("dateEnd").innerHTML = dateEnd;
+  }
+
+  getStartAndEndDates();
   var scheduleIds = []
   var currentSchedule = 1
 
   function sendCalendarData() {
     console.log(scheduleIds)
     var schedules = []
-    scheduleIds.forEach(function(id){
+    scheduleIds.forEach(function (id) {
       var schedule = calendar.getSchedule(String(id), '1');
       schedules[schedules.length] = schedule
     })
 
-    console.log(schedules)
 
     $.ajax({
       type: "POST",
@@ -72,29 +80,31 @@ $(function () {
     calendar.createSchedules([schedule]);
 
     sendCalendarData();
-});
-  
-calendar.on('beforeDeleteSchedule', function(event) {
+  });
+
+  calendar.on('beforeDeleteSchedule', function (event) {
     console.log('schedule delete');
     calendar.deleteSchedule(event.schedule.id, event.schedule.calendarId, event.schedule);
     sendCalendarData();
-});
-  
+  });
+
   prevBtn.addEventListener("click", e => {
     calendar.prev();
+    getStartAndEndDates();
   });
   nextBtn.addEventListener("click", e => {
     calendar.next();
     sendCalendarData();
+    getStartAndEndDates();
   });
 
-  calendar.on('beforeUpdateSchedule', function(event) {
+  calendar.on('beforeUpdateSchedule', function (event) {
     var schedule = event.schedule;
     var changes = event.changes;
 
     calendar.updateSchedule(schedule.id, schedule.calendarId, changes);
     calendar.sendCalendarData();
-    });
+  });
 
 
   $.ajax({
@@ -103,9 +113,8 @@ calendar.on('beforeDeleteSchedule', function(event) {
     success: function (data) {
       var cleanedData = []
       console.log(data)
-      if (Array.isArray(data))
-      {
-        data.forEach(function(schedule){
+      if (Array.isArray(data)) {
+        data.forEach(function (schedule) {
           if (schedule) {
             schedule.start = schedule.start._date
             schedule.end = schedule.end._date
@@ -118,6 +127,6 @@ calendar.on('beforeDeleteSchedule', function(event) {
         calendar.createSchedules(cleanedData)
       }
 
-     },
+    },
   });
 });
diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml
index f9f4cc53..7178fc4a 100644
--- a/config/packages/twig.yaml
+++ b/config/packages/twig.yaml
@@ -3,4 +3,4 @@ twig:
 
 when@test:
     twig:
-        strict_variables: true
+        form_themes: ['bootstrap_5_layout.html.twig']
\ No newline at end of file
diff --git a/src/Controller/SignUpController.php b/src/Controller/SignUpController.php
new file mode 100644
index 00000000..573f8bf6
--- /dev/null
+++ b/src/Controller/SignUpController.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace App\Controller;
+
+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
+use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\Routing\Annotation\Route;
+use Symfony\Component\HttpFoundation\Request;
+use App\Entity\User;
+use App\Form\UserType;
+
+class SignUpController extends AbstractController
+{
+    #[Route('/sign_up', name: 'sign_up')]
+    public function new(Request $request): Response
+    {
+        $user = new User();
+        $form = $this->createForm(UserType::class, $user);
+        
+        $form->handleRequest($request);
+        if ($form->isSubmitted() && $form->isValid()) {
+            $user = $form->getData();
+
+            return $this->redirectToRoute('sign_up_success');
+        }
+
+        return $this->renderForm('sign_up/index.html.twig', [
+            'form' => $form,
+        ]);
+    }
+
+
+}
diff --git a/src/Form/UserType.php b/src/Form/UserType.php
new file mode 100644
index 00000000..f752ed27
--- /dev/null
+++ b/src/Form/UserType.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace App\Form;
+
+use App\Entity\User;
+use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolver;
+use Symfony\Component\Form\Extension\Core\Type\PasswordType;
+use Symfony\Component\Form\Extension\Core\Type\SubmitType;
+use Symfony\Component\Form\Extension\Core\Type\TextType;
+use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
+
+class UserType extends AbstractType
+{
+    public function buildForm(FormBuilderInterface $builder, array $options): void
+    {
+        $builder
+            ->add('email', TextType::class)
+            ->add('password', RepeatedType::class,  [
+                'type' => PasswordType::class
+            ])
+            ->add('displayName', TextType::class)
+            ->add('submit', SubmitType::class);
+    }
+
+    public function configureOptions(OptionsResolver $resolver): void
+    {
+        $resolver->setDefaults([
+            'data_class' => User::class,
+        ]);
+    }
+}
diff --git a/templates/calendar/index.html.twig b/templates/calendar/index.html.twig
index 2d608a23..ae51bae8 100644
--- a/templates/calendar/index.html.twig
+++ b/templates/calendar/index.html.twig
@@ -18,11 +18,13 @@
 				Est ce que vous avez respectez vos engagements ?
 				<button class="btn btn-success">Oui</button>
 				<button class="btn btn-danger">Non</button>
+				
 			</div>
 		</div>
 		{# <div id="calendar" style"height: 800px;"></div> #}
 		<button id="prevBtn" class="btn btn-secondary">Prev</button>
 		<button id="nextBtn" class="btn btn-primary">Next</button>
+		<h3><span id="dateStart"></span> jusqu'au <span id="dateEnd"></span></h3>
 		<div id="calendarList"></div>
 	</body>
 
diff --git a/templates/sign_up/index.html.twig b/templates/sign_up/index.html.twig
new file mode 100644
index 00000000..27ef1a39
--- /dev/null
+++ b/templates/sign_up/index.html.twig
@@ -0,0 +1,9 @@
+{% extends 'base.html.twig' %}
+
+{% block title %}Hello SignUpController!{% endblock %}
+
+{% block body %}
+
+
+{{ form(form) }}
+{% endblock %}
-- 
GitLab