From 3b6ab950b0a216f142eab2b073c07f6f7f025a17 Mon Sep 17 00:00:00 2001
From: Arth <65160206@go.buu.ac.th>
Date: Fri, 28 Mar 2025 02:36:20 +0700
Subject: [PATCH] fix time and fix employee image

---
 .env                                     |  5 ++++-
 .env.docker                              |  3 ---
 .env.production                          |  5 +++--
 Dockerfile                               |  2 +-
 docker-compose.yml                       |  4 +++-
 package-lock.json                        |  9 +++++----
 package.json                             |  2 +-
 src/components/GanttChart/GanttChart.vue | 13 ++++++-------
 src/components/Navbar/MainMenu.vue       |  4 ++--
 9 files changed, 25 insertions(+), 22 deletions(-)
 delete mode 100644 .env.docker

diff --git a/.env b/.env
index ddde050..13f07ff 100644
--- a/.env
+++ b/.env
@@ -1 +1,4 @@
-VITE_API_BASE_URL=http://localhost:4000
+# .env.local (สำหรับ localhost)
+VITE_EMP_IMAGE_BASE=http://localhost:4000/images/emp/
+VITE_SCHEDULER_API=http://localhost:9000/run-schedule
+VITE_API_BASE_URL=http://localhost:4000
\ No newline at end of file
diff --git a/.env.docker b/.env.docker
deleted file mode 100644
index 87cde37..0000000
--- a/.env.docker
+++ /dev/null
@@ -1,3 +0,0 @@
-# .env.docker (ใช้ตอนรันใน Docker หรือ production)
-VITE_EMP_IMAGE_BASE=http://dekdee3.informatics.buu.ac.th:8012/images/emp/
-VITE_SCHEDULER_API=http://dekdee3.informatics.buu.ac.th:8013/run-schedule
\ No newline at end of file
diff --git a/.env.production b/.env.production
index 787a791..741929e 100644
--- a/.env.production
+++ b/.env.production
@@ -1,3 +1,4 @@
-VITE_API_BASE_URL=http://dekdee3.informatics.buu.ac.th:8012
+# .env.docker (ใช้ตอนรันใน Docker หรือ production)
 VITE_EMP_IMAGE_BASE=http://dekdee3.informatics.buu.ac.th:8012/images/emp/
-VITE_SCHEDULER_API=http://dekdee3.informatics.buu.ac.th:8013/run-schedule
\ No newline at end of file
+VITE_SCHEDULER_API=http://dekdee3.informatics.buu.ac.th:8013/run-schedule
+VITE_API_BASE_URL=http://dekdee3.informatics.buu.ac.th:8012
diff --git a/Dockerfile b/Dockerfile
index 2c0fcb4..211bed4 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -9,7 +9,7 @@ RUN npm install
 
 # คัดลอก source code ทั้งหมด
 COPY . .
-
+COPY .env.production .env
 # สร้าง production build
 RUN npm run build
 
diff --git a/docker-compose.yml b/docker-compose.yml
index 639a1b7..bd4e4b5 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -3,5 +3,7 @@ services:
   lookoad-frontend:
     build: .
     ports:
-      - "8011:80" # นายจองไว้เรียบร้อย
+      - "8011:80"  # นายจองไว้เรียบร้อย
     restart: always
+    env_file:
+      - .env.production  # 👈 เพิ่มตรงนี้
diff --git a/package-lock.json b/package-lock.json
index e8b2aef..3a98320 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -16,7 +16,7 @@
         "class-validator": "^0.14.1",
         "d3": "^7.9.0",
         "date-fns": "^4.1.0",
-        "dayjs": "^1.11.10",
+        "dayjs": "^1.11.13",
         "install": "^0.13.0",
         "jsplumb": "^2.15.6",
         "pinia": "^2.1.7",
@@ -2848,9 +2848,10 @@
       }
     },
     "node_modules/dayjs": {
-      "version": "1.11.10",
-      "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz",
-      "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ=="
+      "version": "1.11.13",
+      "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.13.tgz",
+      "integrity": "sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==",
+      "license": "MIT"
     },
     "node_modules/de-indent": {
       "version": "1.0.2",
diff --git a/package.json b/package.json
index 9f8b03f..0f0491b 100644
--- a/package.json
+++ b/package.json
@@ -21,7 +21,7 @@
     "class-validator": "^0.14.1",
     "d3": "^7.9.0",
     "date-fns": "^4.1.0",
-    "dayjs": "^1.11.10",
+    "dayjs": "^1.11.13",
     "install": "^0.13.0",
     "jsplumb": "^2.15.6",
     "pinia": "^2.1.7",
diff --git a/src/components/GanttChart/GanttChart.vue b/src/components/GanttChart/GanttChart.vue
index 8fc0e8d..077ad56 100644
--- a/src/components/GanttChart/GanttChart.vue
+++ b/src/components/GanttChart/GanttChart.vue
@@ -108,9 +108,7 @@ import AddQueueDialog from './AddQueueDialog.vue'
 import MakequeueBtn from './MakequeueBtn.vue'
 import SettingBtn from './SettingBtn.vue'
 import './ganttChart.css'
-import dayjs from 'dayjs'
-import utc from 'dayjs/plugin/utc'
-import timezone from 'dayjs/plugin/timezone'
+
 
 // Stores
 const queueStore = useQueueStore()
@@ -220,13 +218,14 @@ function clearOriginalMaps() {
   Object.keys(originalColorMap).forEach((k) => delete originalColorMap[+k])
 }
 
-dayjs.extend(utc)
-dayjs.extend(timezone)
-
 function convertToLocalTime(utcString: string): string {
-  return dayjs.utc(utcString).tz("Asia/Bangkok").format("YYYY-MM-DD HH:mm")
+  const d = new Date(utcString)
+  const iso = d.toISOString()
+  // 🟢 คืนแบบไม่แปลง timezone (แค่ตัดเวลาให้ format สวย)
+  return iso.slice(0, 16).replace('T', ' ')
 }
 
+
 // Pagination & Dialog
 const pages = computed(() => pageStore.pages.map((p) => p.pagenum))
 const pageToShowDelete = ref<number | null>(null)
diff --git a/src/components/Navbar/MainMenu.vue b/src/components/Navbar/MainMenu.vue
index 424839a..483b012 100644
--- a/src/components/Navbar/MainMenu.vue
+++ b/src/components/Navbar/MainMenu.vue
@@ -6,14 +6,14 @@ import { useUserStore } from '@/stores/user'
 const drawer = inject<Ref<boolean>>('drawer')
 const rail = inject<Ref<boolean>>('rail')
 const authStore = useAuthStore()
+const API_BASE = import.meta.env.VITE_API_BASE_URL
 </script>
 
 <template>
   <v-navigation-drawer expand-on-hover rail style="background-color: #2B2E3F; color:white;">
     <!-- profile -->
     <v-list>
-      <v-list-item
-        :prepend-avatar="`http://localhost:4000/images/users/${authStore.getCurrentUser()?.image || 'default.jpg'}`">
+      <v-list-item :prepend-avatar="`${API_BASE}/images/users/${authStore.getCurrentUser()?.image || 'default.jpg'}`">
         <template #title>
           <span style="font-size: 20px; font-weight: bold">
             {{ authStore.getCurrentUser()?.name || 'Unknown User' }}
-- 
GitLab