Current Team
+{activeMembers.length} team members who continuously work on developing and improving this application
+Past Members
+Thank you for your valuable contributions
+diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..f7c6be9 --- /dev/null +++ b/.env.development @@ -0,0 +1,22 @@ +BASE_PATH = "" +NEXT_PUBLIC_APP_URL="http://localhost:1209" + +# BASE_URL_API = https://hats-his.nutech-integrasi.com/presence-api/api/v1 +# BASE_URL_IMG = https://hats-his.nutech-integrasi.com/presence-api/ + +# BASE_URL_API = https://his.nutech-integrasi.com/presence-api/api/v1 +# BASE_URL_IMG = https://his.nutech-integrasi.com/presence-api/ +BASE_URL_API = https://36.66.3.44/presence-api/api/v1 +BASE_URL_IMG = https://36.66.3.44/presence-api/ + +NEXTAUTH_URL = http://localhost:1209 +# NEXTAUTH_URL = http://localhost:7090/super-apps/api/auth +NEXTAUTH_SECRET = hissuperappssecretcode2025 + +FIREBASE_API_KEY = AIzaSyAEkZCHhnyatsNiZ2dpjeaz6JqXYknKKHk +FIREBASE_APP_ID = "1:422528660020:web:db16e1cba4d357e32f1061" + +DEVICE_CODE = "40001" +NEXT_PUBLIC_HATS_SUPPORT_NAME = "Amalia" +NEXT_PUBLIC_HATS_SUPPORT_PHONE = "6285214074002" +NEXT_PUBLIC_APP_VERSION = "v1.1.0" \ No newline at end of file diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..23c0a11 --- /dev/null +++ b/.env.production @@ -0,0 +1,28 @@ +BASE_PATH = "" +NEXT_PUBLIC_APP_URL="https://his.nutech-integrasi.com" + +# BASE_URL_API = https://hats-his.nutech-integrasi.com/presence-api/api/v1 +# BASE_URL_IMG = https://hats-his.nutech-integrasi.com/presence-api/ +# NEXTAUTH_URL = https://hats-his.nutech-integrasi.com +# NEXTAUTH_URL_INTERNAL = http://36.66.3.44:7006 + +# BASE_URL_API = https://36.66.3.44/presence-api/api/v1 +# BASE_URL_IMG = https://36.66.3.44/presence-api/ +# NEXTAUTH_URL = https://36.66.3.44 + +BASE_URL_API = https://his.nutech-integrasi.com/presence-api/api/v1 +BASE_URL_IMG = https://his.nutech-integrasi.com/presence-api/ +NEXTAUTH_URL = https://his.nutech-integrasi.com +NEXTAUTH_URL_INTERNAL = http://36.66.3.44:7002 +# NEXTAUTH_URL = http://localhost:7002 +# NEXTAUTH_URL_INTERNAL = http://localhost:7002 + +NEXTAUTH_SECRET = 4339d50684523526005c1fcb34be0bb1 + +FIREBASE_API_KEY = AIzaSyAEkZCHhnyatsNiZ2dpjeaz6JqXYknKKHk +FIREBASE_APP_ID = "1:422528660020:web:db16e1cba4d357e32f1061" + +DEVICE_CODE = "40001" +NEXT_PUBLIC_HATS_SUPPORT_NAME = "Amalia" +NEXT_PUBLIC_HATS_SUPPORT_PHONE = "6285214074002" +NEXT_PUBLIC_APP_VERSION = "v1.1.0" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5ef6a52..03efc75 100644 --- a/.gitignore +++ b/.gitignore @@ -31,11 +31,11 @@ yarn-error.log* .pnpm-debug.log* # env files (can opt-in for committing if needed) -.env* +# .env* # vercel .vercel # typescript *.tsbuildinfo -next-env.d.ts +next-env.d.ts \ No newline at end of file diff --git a/app/(dashboard)/(main)/page-backup.tsx b/app/(dashboard)/(main)/page-backup.tsx new file mode 100644 index 0000000..6c85d83 --- /dev/null +++ b/app/(dashboard)/(main)/page-backup.tsx @@ -0,0 +1,178 @@ +import { Metadata } from "next" +import dynamic from "next/dynamic" +import Link from "next/link" +import dayjs from "dayjs" +import { getServerSession } from "next-auth" +// import { Download } from 'lucide-react' + +import { CalendarDateRangePicker } from "../components/DaterangePicker" +// import { MainNav } from "./components/MainNav" +// import { RecentSales } from "./components/RecentSales" +// import { UserNav } from "./components/UserNav" +// import TeamSwitcher from "./components/TeamSwitcher" +// import { Search } from "./components/Search" + +import { Button } from "@/components/ui/button" +// import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" +import { authOptions } from "@/pages/api/auth/[...nextauth]" +import { titleCase } from "@/lib/helper" +import { fetchDataWithPost } from "@/lib/fetchData" +// import { ToggleTheme } from "../admin/components/ToggleTheme" +// import Notification from "../admin/components/Notification" +import duration from 'dayjs/plugin/duration' +dayjs.extend(duration) + + +const Overview = dynamic(() => import("../components/Overview"), { + loading: () =>
loading...
, + ssr: false +}) + +export const metadata: Metadata = { + title: "Dashboard", + description: "Employee dashboard page.", +} + +export default async function DashboardPage() { + const session = await getServerSession(authOptions) + + const today = fetchDataWithPost('/presence/history/today', { nik: session?.user.detail.nik }) + const all = fetchDataWithPost('/presence/history', { nik: session?.user.detail.nik, start_date: dayjs().subtract(1, 'week'), end_date: dayjs().format('YYYY-MM-DD') }) + const dashboard = fetchDataWithPost('/dashboard', {}) + + // Wait for the promises to resolve + const [todayPresence, allPresence, dataDashboard] = await Promise.all([today, all, dashboard]) + + const alreadyCheckin = todayPresence.history.length > 0 + const alreadyCheckout = (alreadyCheckin && todayPresence.history[0].presence_checkout) || todayPresence.history.length === 0 + + const getWorkingHours = () => { + if (alreadyCheckin) { + const checkinTime = todayPresence.history[0].working_hours_start + if (alreadyCheckout) { + const checkoutTime = dayjs(todayPresence.history[0].presence_checkout.working_hours_end) + const duration = alreadyCheckin ? dayjs.duration(checkoutTime.diff(checkinTime)) : null + return duration + } + const duration = alreadyCheckin ? dayjs.duration(dayjs().diff(checkinTime)) : null + return duration + } + return null + } + + const getHoursMinutes = () => { + const duration = getWorkingHours() + if (duration) { + const hours = duration.hours() || 0; + const minutes = duration.minutes() || 0; + return `${hours} hours ${minutes} minutes` + } + else return '0 hour' + } + + return ( + <> +Welcome back, we miss your presence!
+Here is your store performance, we hope this helps you unlock insights and empower your decision for continues growth
++ today check-in +
++ number of hours you worked today +
++ number of employee in your department +
++ permission, leave and sick in this year +
+This is your dashboard of attendance, working hours and task report
+This is your dashboard of attendance, working hours and task report
++ {todayPresence.history.length === 0 || lastPresence.is_checkin ? "your today's check-in time" : "your today's check-out time"} +
++ your last presence {dataDashboard.presence.last_presence.check_in ? 'at ' + dayjs(dataDashboard.presence.last_presence.check_in).format('MMM DD, YYYY') : ''} +
++ number of working hours in this month +
+{dayjs(day).format('DD')}
+A working calendar is not just a schedule; it's a roadmap to productivity, a daily commitment to progress, and a visual representation of how we invest our most precious resource: time.
+{item.fullname}
++ {item.position_name || '--'} +
+{dayjs(item.working_hours_start).format('YYYY-MM-DD HH:mm')}
+{item.fullname}
++ {item.position_name || '--'} +
+{dayjs(item.working_hours_start).format('MMM DD, YYYY')}
+Presence information :
+{dayjs(dataPresence.working_hours_start).format('dddd, DD MMMM YYYY')}
+Check-in time :
+{dayjs(dataPresence.working_hours_start).format('HH:mm A')}
+Check-In location :
+{dataPresence.latitude}, {dataPresence.longitude}
+Check-In device :
+{dataPresence.device.name || '-'}
+Check-In note :
+{dataPresence.note || '-'}
+Check-out time :
+ {isMobile ? + setCheckoutTime(e.target.value)} /> + : +{item.fullname}
++ {item.position_name || '--'} +
+{dayjs(item.start_date).format('MMM DD, YYYY')}
+{item.fullname}
++ {item.position_name || '--'} +
+{dayjs(item.start_date).format('MMM DD, YYYY')}
+Category
+Address
+{dataPresence.contact_street}, {dataPresence.contact_city}
+Period
+{dayjs(dataPresence.start_date).format('dddd, DD MMM YYYY')} to {dayjs(dataPresence.end_date).format('dddd, DD MMM YYYY')}
+Return to work
+{dayjs(dataPresence.return_to_work_date).format('dddd, DD MMMM YYYY')}
+Notes
+{dataPresence.note || '-'}
+ {dataPresence.tag.length > 0 && dataPresence.tag.map((item: string) => +Send to
+{dataPresence.superior}
+Mentions to
+{dataPresence.cc.length > 0 ? dataPresence.cc.join(', ') : '-'}
+{item.fullname}
++ {item.position_name || '--'} +
+{item.fullname}
++ {item.position_name || '--'} +
+{item.fullname}
++ {item.position_name || '--'} +
+{item.fullname}
++ {item.position_name || '--'} +
++ your last presence at {latestPresenceCheckIn ? dayjs(latestPresenceCheckIn).format('MMM DD, YYYY') : ''} +
+
+ HIS Attendance Task System
+
+ {item.fullname}
++ {item.position_name || '--'} +
+{dayjs(item.working_hours_start).format('YYYY-MM-DD HH:mm')}
+{item.fullname}
++ {item.position_name || '--'} +
+{dayjs(item.working_hours_start).format('ddd, DD MMM YYYY HH:mm')}
+Presence information :
+{dayjs(dataPresence.working_hours_start).format('dddd, DD MMMM YYYY')}
+Check-in time :
+{dayjs(dataPresence.working_hours_start).format('HH:mm A')}
+Location :
+{dataPresence.latitude}, {dataPresence.longitude}
+Device :
+{dataPresence.device.name || '-'}
+Notes :
+{dataPresence.note || '-'}
+Check-out time :
+{dataPresence?.presence_checkout?.working_hours_start ? dayjs(dataPresence?.presence_checkout?.working_hours_end).format('HH:mm A') : 'Not check-out yet'}
++ Push Notifications +
++ Send notifications to device. +
++ {notification.title} +
++ {notification.description} +
+{item.fullname}
++ {item.position_name || '--'} +
+{dayjs(item.working_hours_end).format("HH:mm A")}
+ : +{dayjs(item.working_hours_start).format("HH:mm A")}
+ : null + } +{item.status_presence as any}
+{item.fullname}
++ {item.position_name || '--'} +
+{item.status_presence as any}
+ {(item.working_status === 'WFO' || item.working_status === 'WFH' || item.working_status === 'WFS') && item.working_status !== null ? + item.status_presence === 'Check Out' ? +{dayjs(item.working_hours_end).format("HH:mm A")}
+ : +{dayjs(item.working_hours_start).format("HH:mm A")}
+ : null + } + {item.status_presence === 'Belum Check In' &&--:--
} +{item.fullname}
+//+// {item.position_name || '--'} +//
+//{item.status_presence as any}
+//{dayjs(item.presence_checkout?.working_hours_end).format('dddd, DD MMM YYYY')}
+ {item.working_status === 'WFO' ? + item.presence_checkout.auto_checkout || item.presence_checkout.manual_presence ? +{item.working_status} -
+ {item.presence_checkout.auto_checkout &&{item.presence_checkout?.device?.name} - {item.presence_checkout?.area ? item.presence_checkout?.area?.name : item.presence_checkout?.location_name}
+ : + item.presence_checkout.auto_checkout || item.presence_checkout.manual_presence ? +{item.working_status} -
+ {item.presence_checkout.auto_checkout &&+ { + item.working_status + ' - ' + item.presence_checkout?.location_name + } +
+ } + {item.is_clear_auto_checkout === false && +{dayjs(item.working_hours_start).format('dddd, DD MMM YYYY')}
+{item.working_status} -
+{session?.user.detail.fullname}
++ {session?.user.detail.email} +
++ number of hours you worked today +
++// number of hours you worked today +//
+//
+ {isPast ? (
+ <>
+ Joined: {new Date(member.joinDate).toLocaleDateString("id-ID", { year: "numeric", month: "short" })}
+
+ Ended: {new Date(member.endDate!).toLocaleDateString("id-ID", { year: "numeric", month: "short" })}
+ >
+ ) : (
+ <>Joined since {new Date(member.joinDate).toLocaleDateString("id-ID", { year: "numeric", month: "long" })}>
+ )}
+
Get to know the Team behind this application.
+{activeMembers.length} team members who continuously work on developing and improving this application
+Thank you for your valuable contributions
+Here is list of your attendance history
+{OFFICE_PEJATEN_LATTITUDE}, {OFFICE_PEJATEN_LONGITUDE}
+{locationName}
+Update your presence information with the latest data.
+© {new Date().getFullYear()} - H.A.T.s | Design & Develop by H.I.S Dev Super Team 😎
+