From 05d5e60cf23039e12b249c5f4e205f5047556538 Mon Sep 17 00:00:00 2001
From: Marlene Simondant <msimondant@grandlyon.com>
Date: Tue, 18 Mar 2025 16:03:28 +0100
Subject: [PATCH] Set appointment date

---
 .../orientation-details.component.html                |  9 ++++++++-
 .../orientation-details.component.scss                |  6 ++++--
 .../orientation-details.component.ts                  | 11 ++++++++---
 3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/src/app/profile/dashboard/orientation-details/orientation-details.component.html b/src/app/profile/dashboard/orientation-details/orientation-details.component.html
index 43306c2db..ddc8dfbb9 100644
--- a/src/app/profile/dashboard/orientation-details/orientation-details.component.html
+++ b/src/app/profile/dashboard/orientation-details/orientation-details.component.html
@@ -98,7 +98,14 @@
             <div class="datePickerContainer">
               <span class="category-name" id="dateLabel">Date de RDV :</span>
               <span class="datePicker">
-                <input type="date" id="date" name="date" aria-labelledby="dateLabel" />
+                <input
+                  type="date"
+                  id="date"
+                  name="date"
+                  aria-labelledby="dateLabel"
+                  [value]="orientation.appointmentDate | date: 'yyyy-MM-dd'"
+                  (change)="setAppointmentDate($event)"
+                />
               </span>
             </div>
           </div>
diff --git a/src/app/profile/dashboard/orientation-details/orientation-details.component.scss b/src/app/profile/dashboard/orientation-details/orientation-details.component.scss
index 9c6b0133b..4574bc79d 100644
--- a/src/app/profile/dashboard/orientation-details/orientation-details.component.scss
+++ b/src/app/profile/dashboard/orientation-details/orientation-details.component.scss
@@ -115,9 +115,11 @@
             display: inline-grid;
             input {
               margin-top: 8px;
-              width: 250px;
-              height: 32px;
+              width: 200px;
+              height: 16px;
               padding: 8px;
+              border-radius: 4px;
+              border: 1px solid $grey-1;
             }
           }
           @media #{$phone} {
diff --git a/src/app/profile/dashboard/orientation-details/orientation-details.component.ts b/src/app/profile/dashboard/orientation-details/orientation-details.component.ts
index cb0f98cd9..01b2bc456 100644
--- a/src/app/profile/dashboard/orientation-details/orientation-details.component.ts
+++ b/src/app/profile/dashboard/orientation-details/orientation-details.component.ts
@@ -66,19 +66,16 @@ export class OrientationDetailsComponent implements OnInit {
       const comment = this.commentTextarea?.value || '';
       const sanitizedHtml = this.sanitizer.sanitize(SecurityContext.HTML, comment);
       const sanitizedComment = this.extractPlainText(sanitizedHtml || '');
-
       const patchData: any = {
         status: this.selectedStatus,
         action: null,
         processingComment: sanitizedComment,
         modifiedBy: this.userProfile._id,
       };
-
       // Only add closingDate if orientation is not already closed
       if (!isClosed) {
         patchData.closingDate = new Date();
       }
-
       this.patchOrientation(patchData);
     }
     this.isModalOpenned = false;
@@ -96,6 +93,14 @@ export class OrientationDetailsComponent implements OnInit {
     }
   }
 
+  public setAppointmentDate(event: Event): void {
+    const target = event.target as HTMLInputElement;
+    const date = new Date(target.value);
+    if (!isNaN(date.getTime())) {
+      this.patchOrientation({ appointmentDate: date, modifiedBy: this.userProfile._id });
+    }
+  }
+
   get isValidateDisabled(): boolean {
     return !this.selectedStatus || !this.commentTextarea?.value?.trim();
   }
-- 
GitLab