6 Commits

Author SHA1 Message Date
Ichsan Kurniawan ef06bed081 Add privacy policy and terms pages
Replace placeholder pages with detailed legal documents covering data handling, Google Calendar use, user rights, and service terms. Add a shared legal page layout and metadata, plus Google site verification.
2026-11-19 10:39:26 +07:00
Ichsan Kurniawan d10603acc8 Optimize Next.js memory and handle 404s
Configure startup and package-import optimizations, exclude generated Next.js files from TypeScript checks, and route fetch responses with status 404 to the not-found page.
2026-11-18 18:20:27 +07:00
Ichsan Kurniawan d4168b45f2 Tighten task actions and image uploads
Gate assignment and team actions by permissions, limit client and end-user images to 2 MB, and make the technical status end date optional. Also update status remark handling and rename the Task navigation label.
2026-11-18 18:19:38 +07:00
Ichsan Kurniawan faa22e93e0 Align task pages with access permissions
Use the shared page-permission helper across task routes and gate client creation controls on CREATE_CLIENT. Remove an unused profile permission import.
2026-11-17 21:46:07 +07:00
Ichsan Kurniawan 69a325a376 Update .gitignore 2026-11-17 21:26:43 +07:00
Ichsan Kurniawan cf9e36f10a Add Google Calendar events and tasks
Add calendar authentication and event/task actions, plus rich-description styling and setup documentation.
2026-11-17 21:24:30 +07:00
36 changed files with 2303 additions and 117 deletions
+12 -1
View File
@@ -19,4 +19,15 @@ NEXT_PUBLIC_HATS_SUPPORT_PHONE = "6285214074002"
NEXT_PUBLIC_APP_VERSION = "v1.2.0"
NEXT_PUBLIC_MANAGER_USER_ID = '2'
NEXT_PUBLIC_S3_IMAGE_URL = https://cdn.hisnutech.my.id/public
NEXT_PUBLIC_S3_IMAGE_URL = https://cdn.hisnutech.my.id/public
# Google Calendar Service Account Config
GOOGLE_SERVICE_ACCOUNT_EMAIL = "hats-calendar@hats-project-515003.iam.gserviceaccount.com"
GOOGLE_PRIVATE_KEY = "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC2rZliu4vxv+mw\ng6D1O306tIwq30wzQ3QS8pA4pIsFQbtr/1Ur4EQyOHJGThzf1ndXS07zKN1eVt5O\nKsdbS70JKuwNPi2WgUtrsNURa20xNQMe88nILVFG54l1Wn2eXj5ZEeKfrdVO/zvW\nyhLIf4qGPRrNI8lMNcEo8NuNTvYNqTAfL/5fohOH9TLH0yB+zg3ee4C4tnhYj9OC\ntpN91cIXCtdWoAkr4QKyYejAsAgYz9DWZ/szGEyWClp+6NGOx2Lhkmx/Thcbww9H\nB8du7+02VryPhsl7eEHMcoRNgHsIj/ok2xLf9sBhL0pCxgpRa0lMjMrjw/m+nOzr\n22Zh1MXvAgMBAAECggEACe1mNATgJouY3gRRN3J7rDiKk3veDr0gLjVrXACpI2h+\nkHBoRwGhgx8pKqPtEsb7Zk2L5U/3s7xByXquqcn0ZG6mNFQIMzEkkZ4i/hbZ8L4i\nRMjX0t6Pl6xWfn+j6vrRJZMAv0+5k1jwfgwuOCIiO4hPkA1dT5xuOlTYgZXkbjqH\ne2Yr+WKSXG5fZ3y8X0lqBKirIIG0cT9EvTwBLYoelaYzxphcN23Z7upLqDMq5qPp\nklD50IQmsP9vh+ZWrWxApcCb71hFKk3lfIt+04wciPYJyN2WGSMvYCcKJHmP+QY9\nX+zmu3lFk+ToVmcd85z9PM8zO8GhfiU2o/FCvDjLfQKBgQDmU3UjYUosAU1R5reT\ntJdCOkdQg3zbsnxFrbqxwCGfM9aGDVROQWJ9uiY4iawMF57RNZ1i9NfpV3BhmcdS\nzg6OabTIefYbHkxQwQGP2benVteJLfoO3lKM7v/mfIbxQdFfFzUjjIPJP1S/IpX2\nuEHcB6lpxxeobxt5uQUchsbn0wKBgQDLCnhNyBIgmS8YodfinN+MIV6BRpia0bps\njSiPuRT8RMvq30Nn1orttyEo1F+EH3daiiVVZT+wnMp0AEZdKoi8v14l+6ALCycL\nZzme1c7tWQpXpr5K7rXlgN9iqH3fajhOM7BPZwAGnEQeRwGUrYtEGK/EPMb3la52\nUGw3kELT9QKBgCHTlfuJOVR3KHzjzohB2IkgeALKHNdDQl8VYbrjRczU1ye+42fO\n0IE4io55Iaxw96EwJ5o17VPWxKmA5TYzDw45VhSvXMakz354qhsPVZqc9XCvMO9o\nFWWfYDPgjAz4pqA5j1NWOrCevXqIwM+IRhvjgC0J0V6qWrWox6hl3uaDAoGBALfV\nJfF+qPL83shVmIpj8H8Go3M2wOrD4x9vev8N2zNA8sQYGwaEGEt8mDhIeKa+eqju\nFTlJL64vd5opuYuW/DCwr4SCW3hEQ7iuYFwwR2dcS+HqZbaghO5jjV3dIgJLQOmF\nISfzIPHbQE2Nip/btREVrOZnBNqbmlcjH6f7JJaVAoGATLoFdwPbGE38KOtqrxVS\nO2rpGSi1FstgtjIRKe60QKz3AkF7iG5mFV1LPgvMisBRADAvZs5FDlnWe4D8DFEp\nR2I6jg2NqQnZRSD6TTLjLSkGttd/x0NO0KkhDwcfWkTDejkpgAGCirDB8ayH84F/\nzdO/JzKM/noIOXjIzN1Z2zA=\n-----END PRIVATE KEY-----\n"
GOOGLE_CALENDAR_ID = "a79f0cf9f55e1109d8c88ba61d2524a57e11e7da0167d5f7b0f7da3f628fe4a2@group.calendar.google.com"
GOOGLE_CALENDAR_SA_FILE = "hats-project-sa-rifail.json"
# Google Calendar oAuth 2.0 Config
GOOGLE_CLIENT_ID = "141775000325-3rammrevss2mq37u3vthdfra2l1dkm83.apps.googleusercontent.com"
GOOGLE_CLIENT_SECRET = "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"
GOOGLE_REFRESH_TOKEN = "1//04yMJqoGPYlTeCgYIARAAGAQSSQF-L9IrX-Zy510TWP7UlWM_JpZJQ-VaPPFLnCVbrpoO7zMWhndAbgKrpysh9Fd6ItuMpaPVM-wBzsHoQtOnAnMgIUb0dmPGYms"
+4 -1
View File
@@ -43,4 +43,7 @@ next-env.d.ts
*.log
anti-slop
anti-slop
google_client_secret.json
google_service_account.json
+1 -1
View File
@@ -43,7 +43,7 @@ export function MainNav({ className, ...props }: HTMLAttributes<HTMLElement>) {
className={`text-sm font-medium transition-colors hover:text-his hover:border-b-[3px] border-his pt-6 pb-5 ${getMenuActiveStyle('/task')}`}
>
<i className="ti ti-checklist text-base mr-0.5"></i>
My Task
Task
</Link>
{session?.user.detail.role.allow_admin_panel &&
<Link
+1 -1
View File
@@ -9,7 +9,7 @@ import LazyLoading from '@/components/loader/LazyLoading';
import { type IProfile } from './components/type';
import { type IUser } from '@/app/admin/administration/user/component/type';
import { getAccessPagePermission, getCacheServerSession, getNonAdminAccessPagePermission } from '@/lib/get-access-data';
import { getAccessPagePermission, getCacheServerSession } from '@/lib/get-access-data';
const ForgotPassword = lazy(() => import('./components/ForgotPassword'));
const ChangeTheme = lazy(() => import("./components/ChangeTheme"))
@@ -10,6 +10,7 @@ import { useRouter, useSearchParams } from 'next/navigation';
import dynamic from 'next/dynamic';
import FilterComponent from '../../../component/FilterComponent';
import ProjectAssignmentDashboardStats from '../../../component/project-assignment/ProjectAssignmentDashboardStats';
import { IClient } from '../../../types';
const AssignmentList = dynamic(
() => import('../../../component/project-assignment/AssignmentList'),
@@ -69,12 +70,13 @@ const ConfirmDeleteWithInput = dynamic(
);
interface Props {
client: IClient;
clientId: string;
assignmentLists: IProjectAssignment[];
actions?: string[]
}
export default function ClientDetailComponent({ clientId, assignmentLists, actions }: Props) {
export default function ClientDetailComponent({ client, clientId, assignmentLists, actions }: Props) {
const router = useRouter();
const searchParams = useSearchParams();
const urlLayout = searchParams?.get('layout') as 'grid' | 'list' | null;
@@ -133,7 +135,7 @@ export default function ClientDetailComponent({ clientId, assignmentLists, actio
This client doesn't have any projects or internal memos yet. Try to change the filter or create one to get started.
</p>
</div>
{actions?.includes("CREATE_ASSIGNMENT") &&
{client?.name && actions?.includes("CREATE_ASSIGNMENT") &&
<Link href={`/task/client-detail/${clientId}/project-assignments`}>
<Button variant="outline" className="mt-4">Create Assignment</Button>
</Link>
@@ -61,7 +61,7 @@ export default function ClientProfileCard({ client, clientId, actions }: Props)
{/* Right: + New assignment Button */}
<div className="shrink-0 self-start lg:self-center">
{actions?.includes("CREATE_ASSIGNMENT") &&
{client.name && actions?.includes("CREATE_ASSIGNMENT") &&
<Link href={`/task/client-detail/${clientId}/project-assignments`}>
<Button className="gap-2 bg-his hover:bg-his/90 text-white font-medium rounded-xl px-5 py-2.5 shadow-sm transition-transform active:scale-[0.98]">
<Plus className="h-4 w-4" />
@@ -9,7 +9,7 @@ import { getQueryStringFilteredAssignments } from '@/lib/fetchData';
import { getFilteredAssignments } from '../../../data';
import { getClientById, getAssignmentsByClient } from '../../../utils/queries';
import Reveal from '@/components/ui/reveal';
import { getNonAdminAccessPagePermission } from '@/lib/get-access-data';
import { getAccessPagePermission } from '@/lib/get-access-data';
type Props = {
params: Promise<{ client_id: string }>
@@ -55,7 +55,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
}
export default async function ClientDetailPage({ params, searchParams }: Props) {
const actions = await getNonAdminAccessPagePermission('/task', 'VIEW_CLIENT')
const actions = await getAccessPagePermission('/task', 'VIEW_CLIENT', false)
const { client_id } = await params;
@@ -103,6 +103,7 @@ export default async function ClientDetailPage({ params, searchParams }: Props)
</Reveal>
<ClientDetailComponent
client={client}
clientId={client_id}
assignmentLists={filterAssignments}
actions={actions}
@@ -527,15 +527,17 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
</button>
</div>
) : null}
<Button
onClick={() => setAction('MANAGE_EMPLOYEE')}
variant="outline"
size="sm"
className="gap-1.5 transition-transform active:scale-[0.98]"
>
<UserPlus className="h-4 w-4" />
Manage team
</Button>
{actions?.includes("MANAGE_TEAM") &&
<Button
onClick={() => setAction('MANAGE_EMPLOYEE')}
variant="outline"
size="sm"
className="gap-1.5 transition-transform active:scale-[0.98]"
>
<UserPlus className="h-4 w-4" />
Manage team
</Button>
}
</div>
}
>
@@ -3,7 +3,7 @@ import { Button } from '@/components/ui/button';
import Link from 'next/link';
import AssignmentDetailComponent from './AssignmentDetailComponent';
import { getClientById, getAssignmentById } from '../../../utils/queries';
import { getNonAdminAccessPagePermission } from '@/lib/get-access-data';
import { getAccessPagePermission } from '@/lib/get-access-data';
type Props = {
params: Promise<{ client_id: string; assignment_id: string }>
@@ -46,7 +46,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
}
export default async function AssignmentDetailPage({ params }: Props) {
const actions = await getNonAdminAccessPagePermission('/task', 'VIEW_ASSIGNMENT')
const actions = await getAccessPagePermission('/task', 'VIEW_ASSIGNMENT', false)
const { client_id, assignment_id } = await params;
@@ -1,7 +1,7 @@
import type { Metadata } from 'next';
import ProjectAssignmentForm from "./ProjectAssignmentForm";
import { getClientById, getAssignmentById } from "../../../utils/queries";
import { getNonAdminAccessPagePermission } from '@/lib/get-access-data';
import { getAccessPagePermission } from '@/lib/get-access-data';
type Props = {
params: Promise<{ client_id?: string }>
@@ -15,7 +15,7 @@ export async function generateMetadata({ params, searchParams }: Props): Promise
const assignmentId = typeof resolvedSearchParams?.assignment_id === 'string' ? resolvedSearchParams.assignment_id : undefined;
const isPromote = resolvedSearchParams?.promote === 'true' || resolvedSearchParams?.is_promote === 'true';
await getNonAdminAccessPagePermission('/task', isPromote ? 'PROMOTE_ASSIGNMENT' : isEdit ? 'UPDATE_ASSIGNMENT' : 'CREATE_ASSIGNMENT');
await getAccessPagePermission('/task', isPromote ? 'PROMOTE_ASSIGNMENT' : isEdit ? 'UPDATE_ASSIGNMENT' : 'CREATE_ASSIGNMENT', false);
try {
const clientPromise = client_id ? getClientById(client_id) : Promise.resolve(undefined);
@@ -10,7 +10,7 @@ import FilterComponent from '@/app/(dashboard)/task/component/FilterComponent';
import { COMPLETE_STATUS_LIST, getFilteredAssignments, ONPROGRESS_STATUS_LIST } from '@/app/(dashboard)/task/data';
import { getClientById, getProjectAssignment } from '../../../../utils/queries';
import Reveal from '@/components/ui/reveal';
import { getNonAdminAccessPagePermission } from '@/lib/get-access-data';
import { getAccessPagePermission } from '@/lib/get-access-data';
type Props = {
params: Promise<{ client_id: string; project_id: string }>
@@ -18,7 +18,7 @@ type Props = {
};
export async function generateMetadata({ params, searchParams }: Props): Promise<Metadata> {
const actions = await getNonAdminAccessPagePermission('/task', 'VIEW_PROJECT')
await getAccessPagePermission('/task', 'VIEW_PROJECT', false)
const { client_id, project_id } = await params;
const searchParams_ = await searchParams;
+11 -3
View File
@@ -36,7 +36,8 @@ const FormEndUser: FC<Props> = ({ data, onSuccess, onCancel }) => {
const existFile = data?.photo || null
const dropzoneRef = useRef<any>(null);
const maxSizeMB = 5
const maxSizeMB = 2
const maxSizeBytes = maxSizeMB * 1024 * 1024;
const openDialog = () => {
// Note that the ref is set async,
@@ -48,6 +49,13 @@ const FormEndUser: FC<Props> = ({ data, onSuccess, onCancel }) => {
const onDrop = useCallback((acceptedFiles: any[]) => {
acceptedFiles.forEach(async (file: any) => {
if (file.size > maxSizeBytes) {
toast.error('File size exceeds the limit', {
description: `Maximum allowed file size is ${maxSizeMB}MB.`,
});
return;
}
const reader = new FileReader();
reader.onabort = () => console.log('file reading was aborted');
@@ -184,7 +192,7 @@ const FormEndUser: FC<Props> = ({ data, onSuccess, onCancel }) => {
<Label>Add End User Image</Label>
{/* Drop area */}
<Dropzone ref={dropzoneRef} onDrop={onDrop} multiple={false} noClick noKeyboard
accept={{ 'image/*': ['.png', '.bmp', '.jpeg', '.jpg', '.webp'] }}
accept={{ 'image/*': ['.svg', '.png', '.bmp', '.jpeg', '.jpg', '.webp'] }}
>
{/* @ts-ignore */}
{({ getRootProps, getInputProps, acceptedFiles }) => {
@@ -217,7 +225,7 @@ const FormEndUser: FC<Props> = ({ data, onSuccess, onCancel }) => {
</div>
<p className="mb-1.5 text-sm font-medium">Drop your files here</p>
<p className="text-muted-foreground text-xs">
SVG, PNG, JPG or GIF (max. {maxSizeMB}MB)
SVG, PNG, JPG, WEBP, BMP or GIF (max. {maxSizeMB}MB)
</p>
<Button type='button' variant="outline" className="mt-4" onClick={openDialog}>
<UploadIcon className="-ms-1 opacity-60" aria-hidden="true" />
+12 -9
View File
@@ -15,9 +15,10 @@ import { calculateOverviewStats } from '../utils/client-overview-helpers';
interface HomeTaskProps {
clients?: IClient[];
actions?: string[]
}
export default function HomeTask({ clients = [] }: HomeTaskProps) {
export default function HomeTask({ clients = [], actions }: HomeTaskProps) {
const router = useRouter();
const [showForm, setShowForm] = useState(false);
@@ -60,14 +61,16 @@ export default function HomeTask({ clients = [] }: HomeTaskProps) {
Complete overview of all clients, projects, personnel and work orders in one place.
</p>
</div>
<div className="flex items-center gap-3 shrink-0">
<Button
className="gap-2 w-full sm:w-auto shrink-0 font-medium"
onClick={() => setShowForm(true)}
>
<Plus className="w-4 h-4" /> Add Client
</Button>
</div>
{actions?.includes("CREATE_CLIENT") &&
<div className="flex items-center gap-3 shrink-0">
<Button
className="gap-2 w-full sm:w-auto shrink-0 font-medium"
onClick={() => setShowForm(true)}
>
<Plus className="w-4 h-4" /> Add Client
</Button>
</div>
}
</div>
{/* Top Stat Cards (4 Cards Grid) */}
@@ -76,7 +76,7 @@ export default function UpdateAdministrationStatus({
}, [assignment, statusList]);
const [selectedStatusId, setSelectedStatusId] = useState<string>(initialStatusId);
const [description, setDescription] = useState<string>(assignment?.project_assignment_status?.remark || assignment?.project_assignment_status?.description || assignment?.note || '');
const [description, setDescription] = useState<string>(assignment?.project_assignment_status?.remark || assignment?.note || '');
useEffect(() => {
if (initialStatusId) {
@@ -85,7 +85,7 @@ export default function UpdateAdministrationStatus({
}, [initialStatusId]);
useEffect(() => {
const initialRemark = assignment?.project_assignment_status_notes || assignment?.project_assignment_status?.remark || assignment?.project_assignment_status?.description || assignment?.note || '';
const initialRemark = assignment?.project_assignment_status_notes || assignment?.project_assignment_status?.remark || assignment?.note || '';
setDescription(initialRemark);
}, [assignment]);
@@ -137,11 +137,11 @@ function EditTechnicalStatusModal({ assignmentId, data, onClose, onSuccess }: Ed
return dayjs(endDate).isBefore(dayjs(startDate), 'day');
}, [startDate, endDate]);
const isDateMissing = !startDate || !endDate;
const isDateMissing = !startDate;
const handleSave = async () => {
if (isDateMissing) {
toast.error('Date range required', {
toast.error('Start Date is required', {
description: 'Please select both a start date and an end date.'
});
return;
@@ -258,7 +258,7 @@ function EditTechnicalStatusModal({ assignmentId, data, onClose, onSuccess }: Ed
</div>
<div className="space-y-1.5">
<label className="text-xs font-medium text-foreground">
End Date <span className="text-destructive">*</span>
End Date
</label>
<DatePicker
date={endDate}
@@ -298,18 +298,10 @@ function EditTechnicalStatusModal({ assignmentId, data, onClose, onSuccess }: Ed
</div>
<DialogFooter className="gap-2">
<Button
type="button"
variant="outline"
onClick={onClose}
disabled={isSaving}
>
<Button type="button" variant="outline" onClick={onClose} disabled={isSaving}>
Cancel
</Button>
<Button
type="button"
onClick={handleSave}
disabled={isSaving || isDateRangeInvalid || isDateMissing}
<Button type="button" onClick={handleSave} disabled={isSaving || isDateRangeInvalid || isDateMissing}
className="bg-his text-white hover:bg-his/90 gap-1.5 shadow-2xs font-medium"
>
{isSaving ? (
@@ -75,7 +75,7 @@ export default function Client({ clients, actions, initialLayout = 'grid' }: Cli
<p className="text-muted-foreground max-w-sm mx-auto mt-2">
Try to change the filter or create one to get started.
</p>
{actions?.includes('CREATE') &&
{actions?.includes('CREATE_CLIENT') &&
<Button
variant="outline"
className="mt-4"
@@ -40,7 +40,8 @@ const FormClient: FC<Props> = ({ data, onSuccess, onCancel, isRedirectToDetail }
const existFile = data?.photo || null
const dropzoneRef = useRef<any>(null);
const maxSizeMB = 5
const maxSizeMB = 2
const maxSizeBytes = maxSizeMB * 1024 * 1024;
const openDialog = () => {
if (dropzoneRef.current) {
@@ -50,6 +51,13 @@ const FormClient: FC<Props> = ({ data, onSuccess, onCancel, isRedirectToDetail }
const onDrop = useCallback((acceptedFiles: any[]) => {
acceptedFiles.forEach(async (file: any) => {
if (file.size > maxSizeBytes) {
toast.error('File size exceeds the limit', {
description: `Maximum allowed file size is ${maxSizeMB}MB.`,
});
return;
}
const reader = new FileReader();
reader.onabort = () => console.log('file reading was aborted');
@@ -208,7 +216,7 @@ const FormClient: FC<Props> = ({ data, onSuccess, onCancel, isRedirectToDetail }
<Label>Add Client Image</Label>
{/* Drop area */}
<Dropzone ref={dropzoneRef} onDrop={onDrop} multiple={false} noClick noKeyboard
accept={{ 'image/*': ['.png', '.bmp', '.jpeg', '.jpg', '.webp'] }}
accept={{ 'image/*': ['.svg', '.png', '.bmp', '.jpeg', '.jpg', '.webp'] }}
>
{/* @ts-ignore */}
{({ getRootProps, getInputProps, acceptedFiles }) => {
@@ -241,7 +249,7 @@ const FormClient: FC<Props> = ({ data, onSuccess, onCancel, isRedirectToDetail }
</div>
<p className="mb-1.5 text-sm font-medium">Drop your files here</p>
<p className="text-muted-foreground text-xs">
SVG, PNG, JPG or GIF (max. {maxSizeMB}MB)
SVG, PNG, JPG, WEBP, BMP or GIF (max. {maxSizeMB}MB)
</p>
<Button type='button' variant="outline" className="mt-4" onClick={openDialog}>
<UploadIcon className="-ms-1 opacity-60" aria-hidden="true" />
+3 -3
View File
@@ -3,7 +3,7 @@ import type { Metadata } from 'next';
import { getFilteredClients } from './data';
import { getClients } from './utils/queries';
import { Loader2 } from 'lucide-react';
import { getNonAdminAccessPagePermission } from '@/lib/get-access-data';
import { getAccessPagePermission } from '@/lib/get-access-data';
const HomeTask = lazy(() => import('./component/HomeTask'));
const Client = lazy(() => import('./component/client/Client'));
@@ -41,7 +41,7 @@ export async function generateMetadata(): Promise<Metadata> {
}
export default async function ClientsPage({ searchParams }: Props) {
const actions = await getNonAdminAccessPagePermission('/task', 'VIEW')
const actions = await getAccessPagePermission('/task', 'VIEW', false)
const searchParams_ = await searchParams;
// const view = searchParams_.view === 'assignments' ? 'assignments' : 'clients';
@@ -64,7 +64,7 @@ export default async function ClientsPage({ searchParams }: Props) {
<div className="flex-1 space-y-8 p-4 sm:p-8 pt-4 sm:pt-6">
<Suspense fallback={<div className='flex justify-center items-center h-48 gap-2'><Loader2 className="animate-spin" />Loading...</div>}>
<HomeTask clients={allClients} />
<HomeTask clients={allClients} actions={actions} />
</Suspense>
<Suspense fallback={<div className="animate-pulse h-96 bg-accent rounded-xl" />}>
+33
View File
@@ -1,6 +1,7 @@
@import "tailwindcss";
@import "tw-animate-css";
@import 'tailwind-scrollbar-hide/v4';
@plugin "@tailwindcss/typography";
@custom-variant dark (&:is(.dark *));
@@ -343,4 +344,36 @@
.tada {
animation-name: tada;
}
/* Google Calendar Rich Description Styles */
.gcal-rich-content ul {
list-style-type: disc !important;
padding-left: 1.75rem !important;
margin: 0.35rem 0 !important;
}
.gcal-rich-content ol {
list-style-type: decimal !important;
padding-left: 1.75rem !important;
margin: 0.35rem 0 !important;
}
.gcal-rich-content li {
display: list-item !important;
margin: 0.15rem 0 !important;
}
.gcal-rich-content a,
.gcal-rich-content a * {
color: #1a73e8 !important;
text-decoration: underline !important;
text-underline-offset: 2px !important;
cursor: pointer !important;
}
.dark .gcal-rich-content a,
.dark .gcal-rich-content a * {
color: #8ab4f8 !important;
}
+1
View File
@@ -103,6 +103,7 @@ export default async function RootLayout({
return (
<html lang="en" suppressHydrationWarning>
<head>
<meta name="google-site-verification" content="q4skPMDX5KDkaJOhjnvBrAowMlMJc__AekSaH_Je4Hg" />
<link rel="apple-touch-icon" href="/assets/apple-touch-icon.png" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@3.35.0/dist/tabler-icons.min.css" crossOrigin="anonymous" referrerPolicy="no-referrer"></link>
</head>
+284 -21
View File
@@ -1,26 +1,289 @@
'use client'
import type { Metadata } from 'next';
import { FC } from 'react';
import { Button } from '@/components/ui/button';
import { useRouter } from 'next/navigation';
import { A, DataTable, LegalLayout, LegalSection, UL } from '@/components/legal/LegalLayout';
import { LEGAL } from '@/lib/legal';
type Props = {};
export const metadata: Metadata = {
title: `Privacy Policy | ${LEGAL.shortName}`,
description: `How ${LEGAL.appName} collects, uses, stores and protects personal data, including data from Google Calendar.`,
};
const PrivacyPolicyPage: FC<Props> = ({ }) => {
const router = useRouter()
const sections: LegalSection[] = [
{
id: 'about',
title: 'Who we are and what this covers',
body: (
<>
<p>
{LEGAL.appName} ({LEGAL.shortName}) is a workplace web application at{' '}
<A href={LEGAL.siteUrl}>{LEGAL.siteUrl}</A>. It is operated by {LEGAL.operator} and used by employees and
administrators for attendance, task and project assignment, leave and permit requests, and approvals.
</p>
<p>
This policy explains what personal data {LEGAL.shortName} handles, why, who can see it, how long it is kept,
and the choices you have. It applies to the {LEGAL.shortName} website, the installable web app (PWA) and
its integration with Google Calendar.
</p>
</>
),
},
{
id: 'data-we-collect',
title: 'Data we collect',
body: (
<>
<p>We only collect data needed to run the features you use.</p>
<DataTable
head={['Category', 'What it includes', 'Why we need it']}
rows={[
[
'Account',
'Name, work email, password (stored by our backend in protected form), role, division, area, employee position and type.',
'To sign you in and decide what you are allowed to see and do.',
],
[
'Attendance',
'Check-in and check-out time, GPS coordinates at that moment, a photo taken with your device camera, work status (for example office or remote), and device details.',
'To record working hours and let managers verify attendance.',
],
[
'Leave, permit and sick requests',
'Request type, dates, reason, supporting attachments, signature, and approval decisions.',
'To process requests and produce the request documents (PDF).',
],
[
'Tasks and projects',
'Task titles, descriptions, due dates, status, assignees, client and project names.',
'To plan and track work assigned to you or your team.',
],
[
'Notifications',
'A push notification token from Firebase Cloud Messaging for your browser or device.',
'To deliver reminders and approval alerts you have allowed.',
],
[
'Usage and security logs',
'Sign-in events, audit trail entries (who changed what and when), IP address, browser type and error logs.',
'To keep the service secure, investigate problems and keep an audit record.',
],
]}
/>
<p>
Camera and location are requested through your browser. They are only used when you open an attendance
screen, and you can refuse the permission. Without them, attendance that requires a photo or location
cannot be submitted.
</p>
</>
),
},
{
id: 'google-data',
title: 'Google user data and Google Calendar',
body: (
<>
<p>
{LEGAL.shortName} connects to the <strong>Google Calendar API</strong> to show and manage work schedules and
task due dates on a Google Calendar owned by the organisation. This section describes exactly what is
accessed and how it is used.
</p>
<p>
<strong>How access works.</strong> Employees sign in to {LEGAL.shortName} with their work email and
password, not with Google. The Calendar connection is made once by an administrator, using an
organisation-managed Google account that authorises {LEGAL.shortName} through Google OAuth 2.0. The resulting
refresh token is kept on our server as a protected configuration value. It is never sent to your browser.
{LEGAL.shortName} does not read the personal calendar, email, contacts or Drive files of employees.
</p>
<p>The scopes requested, and why:</p>
<DataTable
head={['Scope', 'What it allows', 'How H.A.T.s uses it']}
rows={[
[
<code key="a" className="break-all text-[13px]">https://www.googleapis.com/auth/calendar</code>,
'See, create, edit and delete calendars and their events.',
'Reads the shared work calendar so schedules appear in the app, and manages that calendar when authorised users publish or change work items.',
],
[
<code key="b" className="break-all text-[13px]">https://www.googleapis.com/auth/calendar.events</code>,
'See, create, edit and delete events on calendars.',
'Creates, updates and removes events and due dates when a user adds, edits or deletes a schedule or task, and optionally adds a Google Meet link and guest emails.',
],
]}
/>
<p>The Google data involved is limited to:</p>
<UL>
<li>Event title, description, location, start and end time, all-day flag and colour.</li>
<li>Guest email addresses on an event, and Google Meet or event links.</li>
<li>The creator email and created or updated timestamps of an event.</li>
</UL>
<p>
<strong>Use and storage.</strong> Calendar data is requested from Google when a page needs it and is
displayed to authorised users. {LEGAL.shortName} does not build a separate copy of calendar content for any
other purpose. Items that users create inside {LEGAL.shortName} are saved in our own database as well as in
the calendar.
</p>
<p>
<strong>Limited Use.</strong> {LEGAL.shortName}&apos;s use and transfer of information received from Google
APIs to any other app adheres to the{' '}
<A href="https://developers.google.com/terms/api-services-user-data-policy">
Google API Services User Data Policy
</A>
, including the Limited Use requirements. In particular:
</p>
<UL>
<li>We use Google data only to provide and improve the user-facing calendar and task features described here.</li>
<li>We do not sell Google data and do not transfer it to third parties, except where needed to provide these features, to follow the law, or to protect the security of the service.</li>
<li>We do not use Google data for advertising, including retargeting or interest-based ads.</li>
<li>We do not use Google data to develop, improve or train generalised AI or machine learning models.</li>
<li>Our staff do not read Google data unless an administrator gives permission for a specific support case, it is needed for security or abuse investigation, or the law requires it.</li>
</UL>
<p>
<strong>Revoking access.</strong> The administrator of the connected Google account can remove{' '}
{LEGAL.shortName} at any time at{' '}
<A href="https://myaccount.google.com/permissions">myaccount.google.com/permissions</A>. After that, the
calendar features stop working and Google data is no longer fetched. To ask us to delete items created by
the integration, contact us using the details in section 11.
</p>
</>
),
},
{
id: 'how-we-use',
title: 'How we use data',
body: (
<UL>
<li>Authenticate you and enforce role-based access.</li>
<li>Record, display and report attendance, leave, permits and approvals.</li>
<li>Assign, schedule and track tasks and projects, including syncing them with Google Calendar.</li>
<li>Send notifications you have enabled.</li>
<li>Protect the service, detect misuse such as falsified location or photos, and keep an audit trail.</li>
<li>Fix bugs and keep the application working.</li>
</UL>
),
},
{
id: 'sharing',
title: 'Who can see your data and who we share it with',
body: (
<>
<p>
<strong>Inside your organisation.</strong> Your managers, HR and administrators can see attendance, leave and
task data that their role permits. Colleagues see only what the features they use expose, such as shared
calendar entries.
</p>
<p>
<strong>Service providers.</strong> We rely on a small set of providers to run the service:
</p>
<UL>
<li><strong>Google</strong> for the Calendar API (section 3) and Firebase Cloud Messaging for push notifications.</li>
<li><strong>Our hosting provider</strong> for the server and database that run {LEGAL.shortName}.</li>
</UL>
<p>
We do not sell personal data and we do not share it for advertising. We may disclose data when the law or a
valid legal request requires it.
</p>
</>
),
},
{
id: 'cookies',
title: 'Cookies and local storage',
body: (
<>
<p>{LEGAL.shortName} uses only what it needs to work:</p>
<UL>
<li>A secure session cookie that keeps you signed in.</li>
<li>Local storage for your theme choice (light, dark or system).</li>
<li>A service worker and cache so the installed web app can load and show an offline page.</li>
</UL>
<p>We do not use advertising or cross-site tracking cookies.</p>
</>
),
},
{
id: 'retention',
title: 'How long we keep data',
body: (
<>
<p>
Attendance, leave and audit records are kept while your account is active and for as long as your organisation
needs them for payroll, labour and audit obligations. After that they are deleted or anonymised.
</p>
<p>
When an account is deactivated, access ends right away. Data tied to it is removed or anonymised on request,
unless a record must be kept by law or for an open dispute. Push tokens are removed when you sign out or
revoke notification permission. Server logs are kept only as long as needed for security and debugging.
</p>
</>
),
},
{
id: 'security',
title: 'How we protect data',
body: (
<UL>
<li>Traffic between your device and {LEGAL.shortName} is encrypted with HTTPS.</li>
<li>Role-based access control limits each user to the data their job needs.</li>
<li>Google OAuth tokens and API credentials are held on the server as protected configuration, not in the browser or the source code shared with users.</li>
<li>Changes to important records are written to an audit trail.</li>
</UL>
),
},
{
id: 'your-rights',
title: 'Your rights and choices',
body: (
<>
<p>You can ask us to:</p>
<UL>
<li>Give you a copy of the personal data we hold about you.</li>
<li>Correct data that is wrong or out of date.</li>
<li>Delete your data, where we are not required to keep it.</li>
<li>Stop optional processing, for example by turning off notifications in your browser settings.</li>
</UL>
<p>
Some changes, such as editing a submitted attendance record, may need approval from your administrator
because the organisation relies on it as a record. Where Indonesian data protection law (Law No. 27 of 2022
on Personal Data Protection) applies, you hold the rights it provides.
</p>
</>
),
},
{
id: 'children',
title: 'Children',
body: (
<p>
{LEGAL.shortName} is a workplace tool for employees and is not directed to children under 17. We do not knowingly
collect data from children. If you believe a child&apos;s data was submitted, contact us and we will delete it.
</p>
),
},
{
id: 'contact',
title: 'Contact and changes to this policy',
body: (
<>
<p>
For privacy questions, access or deletion requests, or Google data concerns, email{' '}
<A href={`mailto:${LEGAL.contactEmail}`}>{LEGAL.contactEmail}</A>. We aim to reply within 14 days.
</p>
<p>
If we change this policy, we will update the date at the top of this page. For material changes, including
any new Google scope, we will tell users inside the app before the change takes effect. See also our{' '}
<A href="/terms">Terms of Service</A>.
</p>
</>
),
},
];
return (
<>
<div className="h-screen flex flex-col justify-center items-center">
<h2 className="text-xl sm:text-2xl font-semibold tracking-tight text-center">Privacy Policy</h2>
<span className="text-center mt-2 text-zinc-600 dark:text-zinc-400 w-11/12 sm:w-9/12">Idihh rajin amat sampe buka buka privacy policy segala, kepoo yaa</span>
<span className="text-center mb-6 text-zinc-600 dark:text-zinc-400 w-11/12 sm:w-9/12">emang boleh sekepo itu? &#128527;</span>
<div className="flex items-center space-x-2">
<Button onClick={() => { router.back(); router.refresh() }}>Ayok balik lagi yukk :)</Button>
</div>
</div>
</>
);
export default function PrivacyPolicyPage() {
return (
<LegalLayout
current="privacy-policy"
title="Privacy Policy"
summary={`This page explains what ${LEGAL.shortName} collects, why, who can see it and how to control it. Section 3 covers our use of Google Calendar data in full.`}
sections={sections}
/>
);
}
export default PrivacyPolicyPage;
+185 -21
View File
@@ -1,26 +1,190 @@
'use client'
import type { Metadata } from 'next';
import { FC } from 'react';
import { Button } from '@/components/ui/button';
import { useRouter } from 'next/navigation';
import { A, LegalLayout, LegalSection, UL } from '@/components/legal/LegalLayout';
import { LEGAL } from '@/lib/legal';
type Props = {};
export const metadata: Metadata = {
title: `Terms of Service | ${LEGAL.shortName}`,
description: `The rules for using ${LEGAL.appName}.`,
};
const TermsPage: FC<Props> = ({ }) => {
const router = useRouter()
const sections: LegalSection[] = [
{
id: 'acceptance',
title: 'Acceptance of these terms',
body: (
<p>
These terms govern your use of {LEGAL.appName} ({LEGAL.shortName}) at <A href={LEGAL.siteUrl}>{LEGAL.siteUrl}</A>,
operated by {LEGAL.operator}. By signing in or using the service you agree to them and to our{' '}
<A href="/privacy-policy">Privacy Policy</A>. If you do not agree, do not use the service.
</p>
),
},
{
id: 'service',
title: 'What the service does',
body: (
<>
<p>{LEGAL.shortName} is a workplace application that provides:</p>
<UL>
<li>Attendance check-in and check-out with location and photo.</li>
<li>Leave, permit and sick requests with approval workflow and generated documents.</li>
<li>Task, client and project assignment.</li>
<li>Calendar scheduling through an integration with Google Calendar.</li>
<li>Reports, notifications and administration tools for authorised staff.</li>
</UL>
<p>Features available to you depend on the role your administrator gives you.</p>
</>
),
},
{
id: 'accounts',
title: 'Accounts',
body: (
<UL>
<li>Accounts are created or approved by your organisation. You must give accurate information.</li>
<li>Keep your password private. You are responsible for activity under your account, so tell us promptly if you suspect misuse.</li>
<li>Do not share your account or sign in as someone else.</li>
</UL>
),
},
{
id: 'acceptable-use',
title: 'Acceptable use',
body: (
<>
<p>You agree not to:</p>
<UL>
<li>Submit false attendance, for example fake GPS location, photos of someone else, or photos of photos.</li>
<li>Submit leave, permit or sick requests with false reasons or forged attachments or signatures.</li>
<li>Access data or areas of the service your role does not allow, or try to bypass access controls.</li>
<li>Probe, scan, overload or interfere with the service, or introduce malware.</li>
<li>Copy, resell or reverse engineer the service, except where the law allows it.</li>
<li>Use the service to harass others or to store unlawful content.</li>
</UL>
<p>Your organisation may take disciplinary action under its own policies for misuse of attendance records.</p>
</>
),
},
{
id: 'your-content',
title: 'Your data and content',
body: (
<>
<p>
You keep ownership of what you submit, such as requests, attachments and task details. You give {LEGAL.operator}{' '}
permission to process it to run the service for you and your organisation, as described in the Privacy Policy.
</p>
<p>
Attendance, leave and task records are also records of your organisation, which decides how they are used for
HR and payroll purposes.
</p>
</>
),
},
{
id: 'google',
title: 'Google Calendar integration',
body: (
<>
<p>
The calendar features use Google APIs through an account connected by an administrator. Use of Google data is
covered by section 3 of the <A href="/privacy-policy#google-data">Privacy Policy</A>, which includes our
compliance with the Google API Services User Data Policy and its Limited Use requirements.
</p>
<p>
Your use of Google Calendar and Google Meet is also subject to{' '}
<A href="https://policies.google.com/terms">Google&apos;s Terms of Service</A>. Calendar features may stop if
Google changes or withdraws its APIs, or if the connected account revokes access.
</p>
</>
),
},
{
id: 'permissions',
title: 'Device permissions',
body: (
<p>
Attendance features ask your browser for camera and location access, and notifications ask for permission to
send alerts. You can refuse or withdraw these at any time in your browser or device settings. Features that need a
permission will not work without it.
</p>
),
},
{
id: 'ip',
title: 'Intellectual property',
body: (
<p>
The {LEGAL.shortName} software, name, logo and design belong to {LEGAL.operator} or its licensors. You receive a
limited, non-exclusive, non-transferable right to use the service for your work while your account is active.
</p>
),
},
{
id: 'availability',
title: 'Availability and changes',
body: (
<p>
We work to keep {LEGAL.shortName} available, but it may be interrupted for maintenance, updates or events outside our
control. We may change or remove features. We will give notice of significant changes where we reasonably can.
</p>
),
},
{
id: 'disclaimer',
title: 'Disclaimers and limits of liability',
body: (
<>
<p>
The service is provided &quot;as is&quot; and &quot;as available&quot;. To the extent the law allows, we do not
promise it will be uninterrupted or error free, and we are not responsible for decisions made from attendance or
report data without checking it.
</p>
<p>
To the extent the law allows, {LEGAL.operator} is not liable for indirect or consequential loss arising from use of
the service. Nothing in these terms limits liability that cannot be limited by law.
</p>
</>
),
},
{
id: 'termination',
title: 'Suspension and termination',
body: (
<p>
Your access ends when your organisation deactivates your account or you stop being part of it. We may suspend an
account that breaks these terms or puts the service or others at risk. You may stop using the service at any time and
can request deletion of your data as described in the Privacy Policy.
</p>
),
},
{
id: 'law',
title: 'Governing law, changes and contact',
body: (
<>
<p>
These terms are governed by the laws of the Republic of Indonesia. We will first try to settle disputes through
discussion before any formal proceedings.
</p>
<p>
We may update these terms. The date at the top of this page shows the latest version, and continued use after a
change means you accept it. For questions, email{' '}
<A href={`mailto:${LEGAL.contactEmail}`}>{LEGAL.contactEmail}</A>.
</p>
</>
),
},
];
return (
<>
<div className="h-screen flex flex-col justify-center items-center">
<h2 className="text-xl sm:text-2xl font-semibold tracking-tight text-center">Terms of Service</h2>
<span className="text-center mt-2 text-zinc-600 dark:text-zinc-400 w-11/12 sm:w-9/12">Gausah sok rajin, sok sok an baca terms condition segala</span>
<span className="text-center mb-6 text-zinc-600 dark:text-zinc-400 w-11/12 sm:w-9/12">emang boleh serajin itu? &#128524;</span>
<div className="flex items-center space-x-2">
<Button onClick={() => { router.back(); router.refresh() }}>Yuk balik lagi yukk :)</Button>
</div>
</div>
</>
);
export default function TermsPage() {
return (
<LegalLayout
current="terms"
title="Terms of Service"
summary={`The rules for using ${LEGAL.shortName}: who can use it, what is expected of you, and what you can expect from us.`}
sections={sections}
/>
);
}
export default TermsPage;
+184
View File
@@ -0,0 +1,184 @@
import Link from 'next/link';
import { ReactNode } from 'react';
import Logo from '@/app/(dashboard)/components/Logo';
import { ToggleTheme } from '@/components/ToggleTheme';
import { LEGAL } from '@/lib/legal';
export type LegalSection = {
id: string;
title: string;
body: ReactNode;
};
type Props = {
title: string;
summary: string;
current: 'privacy-policy' | 'terms';
sections: LegalSection[];
};
const linkClass =
'text-[#B8391A] dark:text-[#FF8F70] underline underline-offset-4 decoration-1 hover:decoration-2 rounded-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#B8391A] dark:focus-visible:outline-[#FF8F70]';
export function LegalLayout({ title, summary, current, sections }: Props) {
const other =
current === 'privacy-policy'
? { href: '/terms', label: 'Terms of Service' }
: { href: '/privacy-policy', label: 'Privacy Policy' };
return (
<div className="h-dvh overflow-y-auto scroll-smooth text-zinc-800 dark:text-zinc-200">
<header className="border-b border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-950">
<div className="mx-auto flex max-w-6xl items-center justify-between gap-4 px-4 py-2 sm:px-6">
<Logo />
<nav aria-label="Legal pages" className="flex items-center gap-1 sm:gap-3 text-sm">
<Link
href="/privacy-policy"
aria-current={current === 'privacy-policy' ? 'page' : undefined}
className="inline-flex min-h-11 items-center px-2 rounded-sm aria-[current=page]:font-semibold aria-[current=page]:underline underline-offset-8 decoration-2 decoration-his hover:text-zinc-950 dark:hover:text-white"
>
Privacy
</Link>
<Link
href="/terms"
aria-current={current === 'terms' ? 'page' : undefined}
className="inline-flex min-h-11 items-center px-2 rounded-sm aria-[current=page]:font-semibold aria-[current=page]:underline underline-offset-8 decoration-2 decoration-his hover:text-zinc-950 dark:hover:text-white"
>
Terms
</Link>
<ToggleTheme />
</nav>
</div>
</header>
<main className="mx-auto max-w-6xl px-4 py-8 sm:px-6 sm:py-12 lg:grid lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-12">
<aside className="mb-6 lg:mb-0">
<div className="lg:sticky lg:top-8">
<details className="group rounded-md border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-900 lg:hidden">
<summary className="flex min-h-11 cursor-pointer items-center justify-between px-4 text-sm font-medium focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#B8391A] dark:focus-visible:outline-[#FF8F70]">
On this page
<span aria-hidden className="text-zinc-500 transition-transform group-open:rotate-180">
&#9662;
</span>
</summary>
<TocList sections={sections} />
</details>
<div className="hidden lg:block">
<p className="mb-3 text-sm font-semibold text-zinc-900 dark:text-zinc-100">On this page</p>
<TocList sections={sections} />
</div>
</div>
</aside>
<article className="min-w-0 rounded-lg border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-900 px-5 py-8 sm:px-10 sm:py-12">
<p className="text-sm text-zinc-600 dark:text-zinc-400">
{LEGAL.appName} &middot; Last updated {LEGAL.updated}
</p>
<h1 className="mt-2 text-3xl font-bold tracking-tight text-zinc-950 dark:text-white sm:text-4xl">
{title}
</h1>
<p className="mt-4 max-w-prose text-base leading-7 text-zinc-700 dark:text-zinc-300">{summary}</p>
<div className="mt-10 space-y-12">
{sections.map((s, i) => (
<section key={s.id} id={s.id} aria-labelledby={`${s.id}-title`} className="scroll-mt-6">
<h2
id={`${s.id}-title`}
className="text-xl font-semibold tracking-tight text-zinc-950 dark:text-white"
>
<span className="mr-2 tabular-nums text-zinc-500 dark:text-zinc-400">{i + 1}.</span>
{s.title}
</h2>
<div className="mt-4 space-y-4 text-[15px] leading-7 text-zinc-700 dark:text-zinc-300 [&_strong]:font-semibold [&_strong]:text-zinc-950 dark:[&_strong]:text-white">
{s.body}
</div>
</section>
))}
</div>
<footer className="mt-14 flex flex-col gap-3 border-t border-zinc-200 dark:border-zinc-800 pt-6 text-sm sm:flex-row sm:items-center sm:justify-between">
<p className="text-zinc-600 dark:text-zinc-400">
Questions? Write to{' '}
<a className={linkClass} href={`mailto:${LEGAL.contactEmail}`}>
{LEGAL.contactEmail}
</a>
</p>
<div className="flex gap-4">
<Link className={linkClass} href={other.href}>
{other.label}
</Link>
<Link className={linkClass} href="/">
Back to app
</Link>
</div>
</footer>
</article>
</main>
</div>
);
}
function TocList({ sections }: { sections: LegalSection[] }) {
return (
<ol className="space-y-0.5 px-2 pb-2 text-sm lg:px-0 lg:pb-0">
{sections.map((s, i) => (
<li key={s.id}>
<a
href={`#${s.id}`}
className="flex min-h-11 items-baseline gap-2 rounded-sm px-2 py-2.5 text-zinc-700 hover:bg-zinc-100 hover:text-zinc-950 dark:text-zinc-300 dark:hover:bg-zinc-800 dark:hover:text-white focus-visible:outline-2 focus-visible:outline-[#B8391A] dark:focus-visible:outline-[#FF8F70] lg:min-h-0 lg:py-1.5"
>
<span className="w-5 shrink-0 tabular-nums text-zinc-500 dark:text-zinc-400">{i + 1}.</span>
<span>{s.title}</span>
</a>
</li>
))}
</ol>
);
}
export function UL({ children }: { children: ReactNode }) {
return <ul className="list-disc space-y-2 pl-5 marker:text-zinc-400">{children}</ul>;
}
export function A({ href, children }: { href: string; children: ReactNode }) {
const external = href.startsWith('http');
return (
<a
href={href}
className={linkClass}
{...(external ? { target: '_blank', rel: 'noopener noreferrer' } : {})}
>
{children}
</a>
);
}
export function DataTable({ head, rows }: { head: string[]; rows: ReactNode[][] }) {
return (
<div className="overflow-x-auto rounded-md border border-zinc-200 dark:border-zinc-800">
<table className="w-full min-w-136 border-collapse text-left text-sm">
<thead className="bg-zinc-100 dark:bg-zinc-800 text-zinc-900 dark:text-zinc-100">
<tr>
{head.map((h) => (
<th key={h} scope="col" className="px-4 py-3 font-semibold">
{h}
</th>
))}
</tr>
</thead>
<tbody className="divide-y divide-zinc-200 dark:divide-zinc-800 align-top">
{rows.map((r, i) => (
<tr key={i}>
{r.map((c, j) => (
<td key={j} className={j === 0 ? 'px-4 py-3 font-medium text-zinc-950 dark:text-white' : 'px-4 py-3'}>
{c}
</td>
))}
</tr>
))}
</tbody>
</table>
</div>
);
}
+25
View File
@@ -0,0 +1,25 @@
Langkah 1: Google Cloud Console
- Buka Google Cloud Console
- Buat project baru (misal: hats-project) atau pilih project yang sudah ada.
- Masuk ke APIs & Services > Library, cari Google Calendar API, lalu klik Enable.
- Buat OAuth 2.0 Client ID (Web Application) di Google Cloud Console.
- Tambah pada bagian Authorized redirect URIs: `https://developers.google.com/oauthplayground`
Langkah 2: Google Playground
Buka Google OAuth 2.0 Playground
- Klik ikon Gear (⚙️ OAuth 2.0 configuration) di pojok kanan atas:
- Centang kotak "Use your own OAuth credentials".
- Masukkan nilai GOOGLE_CLIENT_ID dan GOOGLE_CLIENT_SECRET Anda.
- Klik Close.
- Pada panel kiri (Step 1), masukkan scope: `https://www.googleapis.com/auth/calendar`
- Lalu klik Authorize APIs dan login menggunakan akun Google sistem Anda (his.nutech@gmail.com).
- Pada Step 2, klik tombol Exchange authorization code for tokens.
- Salin Refresh token yang baru dihasilkan, lalu ganti nilai GOOGLE_REFRESH_TOKEN di .env.development dan restart server Next.js (npm run dev).
Langkah 3: Buka Google Calendar dengan akun Google pengelola.
- Buat kalender khusus (misal: "HATS Tasks & Schedule") atau gunakan kalender yang sudah ada.
- Klik ikon titik tiga di samping kalender > Settings and sharing.
- Gulir ke bagian Share with specific people or groups, klik Add people and groups.
- Tempelkan email Service Account Anda (format: hats-calendar-bot@<project-id>.iam.gserviceaccount.com).
- Atur izin menjadi: "Make changes to events" (agar bot bisa membuat, mengedit, dan menghapus event).
- Gulir ke bagian Integrate calendar, lalu salin Calendar ID (format: xxx@group.calendar.google.com atau alamat email pemilik).
+3 -1
View File
@@ -1,4 +1,4 @@
import { redirect } from "next/navigation"
import { notFound, redirect } from "next/navigation"
import { ResponseData } from "@/types/types"
import { logger } from "./logger"
import { getCacheServerSession } from "./get-access-data"
@@ -24,6 +24,7 @@ export default async function fetchData(url: string = '/', cache: "default" | "f
console.log("FETCH ERROR DATA :", res.status, data)
if (res.status === 401 || res.status === 403) return redirect(`/auth?error=Session error or has expired !`)
if (res.status === 404) notFound()
// This will activate the closest `error.js` Error Boundary
throw new Error(`(${data.code || res.status}) ${data.message || res.statusText}`)
}
@@ -62,6 +63,7 @@ export async function fetchDataWithPost(url: string = '/', payload: any = {}, ca
console.log("FETCH ERROR DATA :", res.status, data)
if (res.status === 401 || res.status === 403) redirect(`/auth?error=Session error or has expired !`);
if (res.status === 404) notFound()
throw new Error(`(${data?.code || res.status} ${res.statusText}) ${data?.message}`);
}
+131
View File
@@ -0,0 +1,131 @@
import { google, calendar_v3 } from 'googleapis';
import path from 'path';
import fs from 'fs';
const SCOPES = [
'https://www.googleapis.com/auth/calendar',
'https://www.googleapis.com/auth/calendar.events',
];
export interface GoogleClientContext {
calendar: calendar_v3.Calendar;
calendarId: string;
serviceAccountEmail: string;
authMode: 'oauth2' | 'service_account';
}
export function getGoogleCalendarClient(): GoogleClientContext {
const calendarId = process.env.GOOGLE_CALENDAR_ID || 'primary';
const clientId = process.env.GOOGLE_CLIENT_ID?.trim();
const clientSecret = process.env.GOOGLE_CLIENT_SECRET?.trim();
const refreshToken = process.env.GOOGLE_REFRESH_TOKEN?.trim();
const serviceAccountFile = process.env.GOOGLE_CALENDAR_SA_FILE?.trim();
// 1. Primary Mode: Single System OAuth2 Refresh Token
if (clientId && clientSecret && refreshToken) {
const oauth2Client = new google.auth.OAuth2(
clientId,
clientSecret,
'https://developers.google.com/oauthplayground'
);
oauth2Client.setCredentials({
refresh_token: refreshToken,
});
const calendar = google.calendar({
version: 'v3',
auth: oauth2Client,
});
return {
calendar,
calendarId,
serviceAccountEmail: 'OAuth2 System Account',
authMode: 'oauth2',
};
}
// 2. Fallback Mode: Google Service Account
let clientEmail = process.env.GOOGLE_SERVICE_ACCOUNT_EMAIL;
let privateKey = process.env.GOOGLE_PRIVATE_KEY;
const keyFilePath = path.join(process.cwd(), serviceAccountFile!);
if (fs.existsSync(keyFilePath)) {
try {
const fileData = JSON.parse(fs.readFileSync(keyFilePath, 'utf8'));
if (fileData.client_email) clientEmail = fileData.client_email;
if (fileData.private_key) privateKey = fileData.private_key;
} catch (e) {
console.warn('[GOOGLE_CALENDAR] Could not parse hats-project-sa-rifail.json:', e);
}
}
if (!clientEmail || !privateKey) {
throw new Error(
'Kredensial Google Calendar tidak ditemukan! Pastikan GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, dan GOOGLE_REFRESH_TOKEN telah dikonfigurasi di file .env.'
);
}
const formattedPrivateKey = privateKey.replace(/\\n/g, '\n');
const auth = new google.auth.JWT({
email: clientEmail,
key: formattedPrivateKey,
scopes: SCOPES,
});
const calendar = google.calendar({
version: 'v3',
auth,
});
return {
calendar,
calendarId,
serviceAccountEmail: clientEmail,
authMode: 'service_account',
};
}
export function formatGoogleApiError(error: unknown): string {
if (!error) return 'Terjadi kesalahan internal yang tidak diketahui.';
const err = error as { message?: string; code?: number | string };
const message = err.message || String(error);
if (message.includes('unauthorized_client')) {
return 'OAuth2 Error (unauthorized_client): GOOGLE_REFRESH_TOKEN tidak cocok dengan GOOGLE_CLIENT_ID & GOOGLE_CLIENT_SECRET Anda. Jika membuat token di Google OAuth Playground, pastikan Anda klik ikon Gear (⚙️) di kanan atas dan centang "Use your own OAuth credentials" lalu masukkan Client ID & Client Secret sebelum mengklik Authorize APIs.';
}
if (message.includes('invalid_grant')) {
return 'OAuth2 Error (invalid_grant): Refresh Token sudah kedaluwarsa, dicabut (revoked), atau aplikasi OAuth masih berstatus "Testing" di Google Cloud Console (token kedaluwarsa setelah 7 hari). Silakan generate ulang GOOGLE_REFRESH_TOKEN.';
}
if (message.includes('Google Calendar API has not been used') || message.includes('disabled')) {
return 'Google Calendar API belum diaktifkan di Google Cloud Console. Silakan aktifkan Calendar API di Console.';
}
if (message.includes('Domain-Wide Delegation')) {
return 'Service Account tanpa Domain-Wide Delegation tidak dapat mengirim undangan email (attendees) secara langsung.';
}
if (message.includes('Invalid conference type value')) {
return 'Pembuatan link Google Meet otomatis gagal ("Invalid conference type value"). Pastikan menggunakan autentikasi OAuth2 System Account atau masukkan link Google Meet secara manual.';
}
if (message.includes('Invalid start time') || message.includes('time range is empty')) {
return 'Format waktu mulai/selesai tidak valid. Pastikan waktu selesai lebih akhir dari waktu mulai.';
}
if (message.includes('Not Found') || err.code === 404) {
return 'Kalender tidak ditemukan (404). Pastikan akun Google OAuth2 yang digunakan memiliki akses ke GOOGLE_CALENDAR_ID tersebut (atau ubah GOOGLE_CALENDAR_ID="primary" untuk menggunakan kalender utama akun tersebut).';
}
if (message.includes('forbidden') || err.code === 403) {
return 'Akses ditolak (403). Pastikan akun yang digunakan memiliki izin "Make changes to events" pada kalender ini.';
}
return message;
}
+27
View File
@@ -0,0 +1,27 @@
export interface GoogleEventColor {
id: string;
name: string;
hex: string;
}
/**
* Official Google Calendar API v3 Event colorId palette ("1" - "11")
*/
export const GOOGLE_EVENT_COLORS: GoogleEventColor[] = [
{ id: '1', name: 'Lavender', hex: '#7986cb' },
{ id: '2', name: 'Sage', hex: '#33b679' },
{ id: '3', name: 'Grape', hex: '#8e24aa' },
{ id: '4', name: 'Flamingo', hex: '#e67c73' },
{ id: '5', name: 'Banana', hex: '#f6bf26' },
{ id: '6', name: 'Tangerine', hex: '#f4511e' },
{ id: '7', name: 'Peacock', hex: '#039be5' },
{ id: '8', name: 'Graphite', hex: '#616161' },
{ id: '9', name: 'Blueberry', hex: '#3f51b5' },
{ id: '10', name: 'Basil', hex: '#0b8043' },
{ id: '11', name: 'Tomato', hex: '#d50000' },
];
export function getEventColorInfo(colorId?: string): GoogleEventColor | null {
if (!colorId) return null;
return GOOGLE_EVENT_COLORS.find((c) => c.id === colorId) || null;
}
+543
View File
@@ -0,0 +1,543 @@
'use server';
import { revalidatePath } from 'next/cache';
import { calendar_v3 } from 'googleapis';
import dayjs from 'dayjs';
import { getGoogleCalendarClient, formatGoogleApiError } from './auth';
import {
CalendarActionResponse,
CalendarEventItem,
CreateEventInput,
UpdateEventInput,
} from './types';
const TIME_ZONE = 'Asia/Jakarta';
const FOOTER_DELIMITER = '\n\n--- [Additional Info H.A.T.s] ---';
function stripDescriptionFooter(desc?: string | null): string {
if (!desc) return '';
const idx = desc.indexOf(FOOTER_DELIMITER);
return idx !== -1 ? desc.slice(0, idx).trim() : desc.trim();
}
function buildDescriptionWithFooter(rawDesc: string, guests: string[], meetLink?: string): string {
const clean = stripDescriptionFooter(rawDesc);
const extraLines: string[] = [];
if (meetLink) {
extraLines.push(`Google Meet: ${meetLink}`);
}
if (guests.length > 0) {
extraLines.push(`Tamu (Guests): ${guests.join(', ')}`);
}
if (extraLines.length === 0) {
return clean;
}
return `${clean}${FOOTER_DELIMITER}\n${extraLines.join('\n')}`.trim();
}
function mapGoogleEventToItem(item: calendar_v3.Schema$Event): CalendarEventItem {
const isAllDay = !item.start?.dateTime && !!item.start?.date;
const startStr = item.start?.dateTime || item.start?.date || '';
let endStr = item.end?.dateTime || item.end?.date || '';
// Convert Google Calendar exclusive end.date back to inclusive date for UI
if (isAllDay && item.start?.date && item.end?.date) {
const startDay = dayjs(item.start.date);
const endDay = dayjs(item.end.date);
if (endDay.isAfter(startDay, 'day')) {
endStr = endDay.subtract(1, 'day').format('YYYY-MM-DD');
} else {
endStr = item.start.date;
}
}
const privateProps = item.extendedProperties?.private || {};
// Parse attendees from native field + fallback privateProps.guests
const nativeAttendees = item.attendees?.map((a) => a.email).filter((email): email is string => Boolean(email)) || [];
let storedGuests: string[] = [];
if (privateProps.guests) {
try {
const parsed = JSON.parse(privateProps.guests);
if (Array.isArray(parsed)) {
storedGuests = parsed.filter((e): e is string => typeof e === 'string');
}
} catch {
// ignore invalid json
}
}
const attendees = Array.from(new Set([...nativeAttendees, ...storedGuests]));
// Resolve Google Meet / Conference link
const videoEntry = item.conferenceData?.entryPoints?.find((ep) => ep.entryPointType === 'video')?.uri;
const hangoutLink = item.hangoutLink || videoEntry || privateProps.meetLink || undefined;
const rawDescription =
privateProps.rawDescription !== undefined
? privateProps.rawDescription
: stripDescriptionFooter(item.description);
return {
id: item.id || '',
summary: item.summary || '(Tanpa Judul)',
description: rawDescription,
location: item.location || '',
start: startStr,
end: endStr,
isAllDay,
colorId: item.colorId || undefined,
attendees,
hangoutLink,
htmlLink: item.htmlLink || '',
creatorEmail: item.creator?.email || '',
createdAt: item.created || '',
updatedAt: item.updated || '',
};
}
function buildEventStartAndEnd(
startDateTime: string,
endDateTime: string,
isAllDay?: boolean,
isPatch?: boolean
): {
start: calendar_v3.Schema$EventDateTime;
end: calendar_v3.Schema$EventDateTime;
} {
if (isAllDay) {
const startPart = startDateTime.split('T')[0];
const endPart = endDateTime.split('T')[0];
const startDay = dayjs(startPart);
const endDay = dayjs(endPart);
if (!startDay.isValid() || !endDay.isValid()) {
throw new Error('Format tanggal mulai atau selesai tidak valid.');
}
if (endDay.isBefore(startDay, 'day')) {
throw new Error('Tanggal selesai tidak boleh sebelum tanggal mulai.');
}
const startDateFormatted = startDay.format('YYYY-MM-DD');
// Google Calendar API requires exclusive end.date (+1 day from inclusive end date)
const exclusiveEndDate = endDay.add(1, 'day').format('YYYY-MM-DD');
if (isPatch) {
return {
start: { date: startDateFormatted, dateTime: null as unknown as string },
end: { date: exclusiveEndDate, dateTime: null as unknown as string },
};
}
return {
start: { date: startDateFormatted },
end: { date: exclusiveEndDate },
};
}
const startObj = new Date(startDateTime);
const endObj = new Date(endDateTime);
if (isNaN(startObj.getTime()) || isNaN(endObj.getTime())) {
throw new Error('Format waktu mulai atau selesai tidak valid.');
}
if (endObj.getTime() <= startObj.getTime()) {
throw new Error('Waktu selesai harus lebih akhir dari waktu mulai.');
}
if (isPatch) {
return {
start: {
date: null as unknown as string,
dateTime: startObj.toISOString(),
timeZone: TIME_ZONE,
},
end: {
date: null as unknown as string,
dateTime: endObj.toISOString(),
timeZone: TIME_ZONE,
},
};
}
return {
start: {
dateTime: startObj.toISOString(),
timeZone: TIME_ZONE,
},
end: {
dateTime: endObj.toISOString(),
timeZone: TIME_ZONE,
},
};
}
/**
* Fetch list of Google Calendar events (excluding Task events).
*/
export async function getCalendarEvents(params?: {
timeMin?: string;
timeMax?: string;
maxResults?: number;
}): Promise<CalendarActionResponse<CalendarEventItem[]>> {
try {
const { calendar, calendarId } = getGoogleCalendarClient();
const response = await calendar.events.list({
calendarId,
timeMin: params?.timeMin || new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString(),
timeMax: params?.timeMax,
maxResults: params?.maxResults || 100,
singleEvents: true,
orderBy: 'startTime',
});
const items = response.data.items || [];
const regularEvents: CalendarEventItem[] = items
.filter((item) => {
const isTaskType = item.extendedProperties?.private?.type === 'task';
const hasTaskPrefix = (item.summary || '').startsWith('[TASK');
return !isTaskType && !hasTaskPrefix;
})
.map(mapGoogleEventToItem);
return {
success: true,
data: regularEvents,
};
} catch (error: unknown) {
console.error('[GOOGLE_CALENDAR] getCalendarEvents error:', error);
return {
success: false,
error: formatGoogleApiError(error),
};
}
}
/**
* Execute insert or patch with intelligent handling for Service Account limitations
* regarding conferenceData (Google Meet) and attendees (Domain-Wide Delegation).
*/
async function executeEventMutation(
mode: 'insert' | 'patch',
calendar: calendar_v3.Calendar,
calendarId: string,
eventId: string | undefined,
requestBody: calendar_v3.Schema$Event,
options: {
wantsAutoMeet: boolean;
manualMeetLink: string;
hasAttendees: boolean;
}
): Promise<{ data: calendar_v3.Schema$Event; warnings: string[] }> {
const warnings: string[] = [];
let useConferenceVersion = options.wantsAutoMeet ? 1 : undefined;
const performCall = async () => {
const sendUpdates =
requestBody.attendees && requestBody.attendees.length > 0 ? 'all' : 'none';
if (mode === 'insert') {
return await calendar.events.insert({
calendarId,
conferenceDataVersion: useConferenceVersion,
sendUpdates,
requestBody,
});
} else {
return await calendar.events.patch({
calendarId,
eventId: eventId!,
conferenceDataVersion: useConferenceVersion,
sendUpdates,
requestBody,
});
}
};
// Up to 3 attempts in case both conferenceData and attendees hit Service Account limits
for (let attempt = 0; attempt < 3; attempt++) {
try {
const res = await performCall();
return { data: res.data, warnings };
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
// 1. Handle conferenceData / Google Meet auto-generation failure
if (msg.includes('Invalid conference type value') && requestBody.conferenceData) {
delete requestBody.conferenceData;
useConferenceVersion = undefined;
if (options.manualMeetLink) {
warnings.push(
'Kalender/Service Account ini tidak mendukung auto-generate Google Meet ("Invalid conference type value"). Link Google Meet manual telah digunakan.'
);
continue;
} else {
throw new Error(
'Pembuatan link Google Meet otomatis gagal ("Invalid conference type value"). Kalender akun Gmail personal dengan Service Account (tanpa Google Workspace Domain-Wide Delegation) tidak mendukung pembuatan ruang Google Meet otomatis. Silakan matikan toggle otomatis atau isi kolom Link Google Meet Manual.'
);
}
}
// 2. Handle attendees Domain-Wide Delegation limitation on Service Accounts
if (msg.includes('Domain-Wide Delegation') && requestBody.attendees) {
delete requestBody.attendees;
warnings.push(
'Service Account tanpa Domain-Wide Delegation tidak dapat mengirim email undangan (RSVP) langsung. Daftar tamu tetap disimpan pada event.'
);
continue;
}
throw err;
}
}
const finalRes = await performCall();
return { data: finalRes.data, warnings };
}
/**
* Create a new Google Calendar event.
*/
export async function createCalendarEvent(
payload: CreateEventInput
): Promise<CalendarActionResponse<CalendarEventItem>> {
try {
if (!payload.summary || !payload.summary.trim()) {
return { success: false, error: 'Judul event (summary) wajib diisi.' };
}
if (!payload.startDateTime || !payload.endDateTime) {
return { success: false, error: 'Waktu mulai dan selesai wajib diisi.' };
}
const { start, end } = buildEventStartAndEnd(
payload.startDateTime,
payload.endDateTime,
payload.isAllDay,
false
);
const { calendar, calendarId } = getGoogleCalendarClient();
const cleanGuests = Array.from(
new Set((payload.attendees || []).map((e) => e.trim().toLowerCase()).filter(Boolean))
);
const rawDescription = payload.description?.trim() || '';
const manualMeetLink = payload.manualMeetLink?.trim() || '';
const requestBody: calendar_v3.Schema$Event = {
summary: payload.summary.trim(),
description: buildDescriptionWithFooter(
rawDescription,
cleanGuests,
manualMeetLink
),
location: payload.location?.trim() || '',
start,
end,
colorId: payload.colorId || undefined,
extendedProperties: {
private: {
type: 'event',
source: 'hats-app',
rawDescription,
guests: JSON.stringify(cleanGuests),
meetLink: manualMeetLink,
},
},
};
if (cleanGuests.length > 0) {
requestBody.attendees = cleanGuests.map((email) => ({ email }));
}
if (payload.generateMeet) {
requestBody.conferenceData = {
createRequest: {
requestId: `hats-meet-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`,
conferenceSolutionKey: {
type: 'hangoutsMeet',
},
},
};
}
const { data: item, warnings } = await executeEventMutation(
'insert',
calendar,
calendarId,
undefined,
requestBody,
{
wantsAutoMeet: Boolean(payload.generateMeet),
manualMeetLink,
hasAttendees: cleanGuests.length > 0,
}
);
revalidatePath('/integrated-calendar');
return {
success: true,
data: mapGoogleEventToItem(item),
warning: warnings.length > 0 ? warnings.join(' ') : undefined,
};
} catch (error: unknown) {
console.error('[GOOGLE_CALENDAR] createCalendarEvent error:', error);
return {
success: false,
error: formatGoogleApiError(error),
};
}
}
/**
* Update an existing Google Calendar event.
*/
export async function updateCalendarEvent(
id: string,
payload: UpdateEventInput
): Promise<CalendarActionResponse<CalendarEventItem>> {
try {
if (!id) {
return { success: false, error: 'ID event diperlukan.' };
}
const { calendar, calendarId } = getGoogleCalendarClient();
const cleanGuests = Array.from(
new Set(
(payload.attendees || [])
.map((e) => e.trim().toLowerCase())
.filter(Boolean)
)
);
const rawDescription = payload.description?.trim() ?? '';
const manualMeetLink = payload.manualMeetLink?.trim() ?? '';
const requestBody: calendar_v3.Schema$Event = {
extendedProperties: {
private: {
type: 'event',
source: 'hats-app',
rawDescription,
guests: JSON.stringify(cleanGuests),
meetLink: manualMeetLink,
},
},
};
if (payload.summary !== undefined) {
requestBody.summary = payload.summary.trim();
}
if (payload.description !== undefined || payload.attendees !== undefined || payload.manualMeetLink !== undefined) {
requestBody.description = buildDescriptionWithFooter(
rawDescription,
cleanGuests,
manualMeetLink
);
}
if (payload.location !== undefined) {
requestBody.location = payload.location.trim();
}
if (payload.colorId !== undefined) {
requestBody.colorId = payload.colorId || (null as unknown as string);
}
if (payload.startDateTime && payload.endDateTime) {
const { start, end } = buildEventStartAndEnd(
payload.startDateTime,
payload.endDateTime,
payload.isAllDay,
true
);
requestBody.start = start;
requestBody.end = end;
}
if (payload.attendees !== undefined) {
requestBody.attendees = cleanGuests.map((email) => ({ email }));
}
if (payload.generateMeet) {
requestBody.conferenceData = {
createRequest: {
requestId: `hats-meet-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`,
conferenceSolutionKey: {
type: 'hangoutsMeet',
},
},
};
}
const { data: item, warnings } = await executeEventMutation(
'patch',
calendar,
calendarId,
id,
requestBody,
{
wantsAutoMeet: Boolean(payload.generateMeet),
manualMeetLink,
hasAttendees: cleanGuests.length > 0,
}
);
revalidatePath('/integrated-calendar');
return {
success: true,
data: mapGoogleEventToItem(item),
warning: warnings.length > 0 ? warnings.join(' ') : undefined,
};
} catch (error: unknown) {
console.error('[GOOGLE_CALENDAR] updateCalendarEvent error:', error);
return {
success: false,
error: formatGoogleApiError(error),
};
}
}
/**
* Delete a Google Calendar event.
*/
export async function deleteCalendarEvent(
id: string
): Promise<CalendarActionResponse<{ id: string }>> {
try {
if (!id) {
return { success: false, error: 'ID event diperlukan.' };
}
const { calendar, calendarId } = getGoogleCalendarClient();
await calendar.events.delete({
calendarId,
eventId: id,
sendUpdates: 'all',
});
revalidatePath('/integrated-calendar');
return {
success: true,
data: { id },
};
} catch (error: unknown) {
console.error('[GOOGLE_CALENDAR] deleteCalendarEvent error:', error);
return {
success: false,
error: formatGoogleApiError(error),
};
}
}
+5
View File
@@ -0,0 +1,5 @@
export * from './types';
export * from './constants';
export * from './auth';
export * from './events.actions';
export * from './tasks.actions';
+362
View File
@@ -0,0 +1,362 @@
'use server';
import { revalidatePath } from 'next/cache';
import { calendar_v3 } from 'googleapis';
import dayjs from 'dayjs';
import { getGoogleCalendarClient, formatGoogleApiError } from './auth';
import { getCalendarEvents } from './events.actions';
import {
CalendarActionResponse,
CalendarTaskItem,
CreateTaskInput,
TaskStatus,
UpdateTaskInput,
CalendarSummaryStats,
} from './types';
const TIME_ZONE = 'Asia/Jakarta';
// Helpers to extract clean task title from event summary
function formatTaskSummary(title: string, status: TaskStatus): string {
const cleanTitle = title
.replace(/^\[TASK:DONE\]\s*/i, '')
.replace(/^\[TASK\]\s*/i, '')
.trim();
return status === 'completed'
? `[TASK:DONE] ${cleanTitle}`
: `[TASK] ${cleanTitle}`;
}
function extractTaskTitle(summary: string): string {
return summary
.replace(/^\[TASK:DONE\]\s*/i, '')
.replace(/^\[TASK\]\s*/i, '')
.trim() || summary;
}
/**
* Fetch all task events from Google Calendar.
*/
export async function getCalendarTasks(params?: { timeMin?: string; timeMax?: string; }): Promise<CalendarActionResponse<CalendarTaskItem[]>> {
try {
const { calendar, calendarId } = getGoogleCalendarClient();
const response = await calendar.events.list({
calendarId,
timeMin: params?.timeMin || new Date(Date.now() - 60 * 24 * 60 * 60 * 1000).toISOString(), // 60 days
timeMax: params?.timeMax,
maxResults: 250,
singleEvents: true,
orderBy: 'startTime',
});
const items = response.data.items || [];
// Filter items that are tasks (either by extendedProperties or prefix)
const taskItems: CalendarTaskItem[] = items
.filter((item) => {
const isTaskType = item.extendedProperties?.private?.type === 'task';
const hasTaskPrefix = (item.summary || '').startsWith('[TASK');
return isTaskType || hasTaskPrefix;
})
.map((item) => {
const privateProps = item.extendedProperties?.private || {};
let status: TaskStatus = 'needsAction';
if (privateProps.status === 'completed' || (item.summary || '').startsWith('[TASK:DONE]')) {
status = 'completed';
}
const dueStr = item.start?.dateTime || item.start?.date || '';
const title = privateProps.title || extractTaskTitle(item.summary || '');
return {
id: item.id || '',
title,
description: item.description || '',
due: dueStr,
status,
completedAt: privateProps.completedAt,
htmlLink: item.htmlLink || '',
createdAt: item.created || '',
updatedAt: item.updated || '',
};
});
return {
success: true,
data: taskItems,
};
} catch (error: unknown) {
console.error('[GOOGLE_CALENDAR] getCalendarTasks error:', error);
return {
success: false,
error: formatGoogleApiError(error),
};
}
}
/**
* Create a new task event in Google Calendar.
*/
export async function createCalendarTask(
payload: CreateTaskInput
): Promise<CalendarActionResponse<CalendarTaskItem>> {
try {
if (!payload.title || !payload.title.trim()) {
return { success: false, error: 'Judul task wajib diisi.' };
}
if (!payload.due) {
return { success: false, error: 'Tenggat waktu (due date) wajib diisi.' };
}
const { calendar, calendarId } = getGoogleCalendarClient();
const status: TaskStatus = payload.status || 'needsAction';
const summary = formatTaskSummary(payload.title, status);
// Format start & end: 1 hour window or date
const isDateOnly = !payload.due.includes('T');
let start: calendar_v3.Schema$EventDateTime;
let end: calendar_v3.Schema$EventDateTime;
if (isDateOnly) {
const startDay = dayjs(payload.due).format('YYYY-MM-DD');
const endDay = dayjs(payload.due).add(1, 'day').format('YYYY-MM-DD');
start = { date: startDay };
end = { date: endDay };
} else {
const startDate = new Date(payload.due);
const endDate = new Date(startDate.getTime() + 60 * 60 * 1000); // +1 hour
start = { dateTime: startDate.toISOString(), timeZone: TIME_ZONE };
end = { dateTime: endDate.toISOString(), timeZone: TIME_ZONE };
}
const colorId = status === 'completed' ? '10' : '11'; // 10 = Basil (green), 11 = Tomato (red)
const res = await calendar.events.insert({
calendarId,
requestBody: {
summary,
description: payload.description?.trim() || '',
start,
end,
colorId,
extendedProperties: {
private: {
type: 'task',
status,
title: payload.title.trim(),
completedAt: status === 'completed' ? new Date().toISOString() : '',
source: 'hats-app',
},
},
},
});
const item = res.data;
revalidatePath('/integrated-calendar');
return {
success: true,
data: {
id: item.id || '',
title: payload.title.trim(),
description: item.description || '',
due: item.start?.dateTime || item.start?.date || '',
status,
completedAt: status === 'completed' ? new Date().toISOString() : undefined,
htmlLink: item.htmlLink || '',
createdAt: item.created || '',
updatedAt: item.updated || '',
},
};
} catch (error: unknown) {
console.error('[GOOGLE_CALENDAR] createCalendarTask error:', error);
return {
success: false,
error: formatGoogleApiError(error),
};
}
}
/**
* Update an existing task event in Google Calendar.
*/
export async function updateCalendarTask(
id: string,
payload: UpdateTaskInput
): Promise<CalendarActionResponse<CalendarTaskItem>> {
try {
if (!id) {
return { success: false, error: 'ID task diperlukan.' };
}
const { calendar, calendarId } = getGoogleCalendarClient();
// Fetch existing event first to preserve title/status
const existing = await calendar.events.get({
calendarId,
eventId: id,
});
const prevProps = existing.data.extendedProperties?.private || {};
const newTitle = payload.title !== undefined ? payload.title.trim() : prevProps.title || extractTaskTitle(existing.data.summary || '');
const newStatus: TaskStatus = payload.status !== undefined ? payload.status : (prevProps.status as TaskStatus) || 'needsAction';
const summary = formatTaskSummary(newTitle, newStatus);
const colorId = newStatus === 'completed' ? '10' : '11';
const requestBody: calendar_v3.Schema$Event = {
summary,
colorId,
extendedProperties: {
private: {
...prevProps,
type: 'task',
status: newStatus,
title: newTitle,
completedAt: newStatus === 'completed' ? (prevProps.completedAt || new Date().toISOString()) : '',
},
},
};
if (payload.description !== undefined) {
requestBody.description = payload.description.trim();
}
if (payload.due) {
const isDateOnly = !payload.due.includes('T');
if (isDateOnly) {
const startDay = dayjs(payload.due).format('YYYY-MM-DD');
const endDay = dayjs(payload.due).add(1, 'day').format('YYYY-MM-DD');
requestBody.start = { date: startDay, dateTime: null as unknown as string };
requestBody.end = { date: endDay, dateTime: null as unknown as string };
} else {
const startDate = new Date(payload.due);
const endDate = new Date(startDate.getTime() + 60 * 60 * 1000);
requestBody.start = {
date: null as unknown as string,
dateTime: startDate.toISOString(),
timeZone: TIME_ZONE,
};
requestBody.end = {
date: null as unknown as string,
dateTime: endDate.toISOString(),
timeZone: TIME_ZONE,
};
}
}
const res = await calendar.events.patch({
calendarId,
eventId: id,
requestBody,
});
const item = res.data;
revalidatePath('/integrated-calendar');
return {
success: true,
data: {
id: item.id || '',
title: newTitle,
description: item.description || '',
due: item.start?.dateTime || item.start?.date || '',
status: newStatus,
completedAt: newStatus === 'completed' ? new Date().toISOString() : undefined,
htmlLink: item.htmlLink || '',
createdAt: item.created || '',
updatedAt: item.updated || '',
},
};
} catch (error: unknown) {
console.error('[GOOGLE_CALENDAR] updateCalendarTask error:', error);
return {
success: false,
error: formatGoogleApiError(error),
};
}
}
/**
* Toggle task completion status (needsAction <-> completed).
*/
export async function toggleCalendarTaskStatus(
id: string,
newStatus: TaskStatus
): Promise<CalendarActionResponse<CalendarTaskItem>> {
return updateCalendarTask(id, { status: newStatus });
}
/**
* Delete a task event in Google Calendar.
*/
export async function deleteCalendarTask(
id: string
): Promise<CalendarActionResponse<{ id: string }>> {
try {
if (!id) {
return { success: false, error: 'ID task diperlukan.' };
}
const { calendar, calendarId } = getGoogleCalendarClient();
await calendar.events.delete({
calendarId,
eventId: id,
});
revalidatePath('/integrated-calendar');
return {
success: true,
data: { id },
};
} catch (error: unknown) {
console.error('[GOOGLE_CALENDAR] deleteCalendarTask error:', error);
return {
success: false,
error: formatGoogleApiError(error),
};
}
}
/**
* Get overall summary stats for Events and Tasks.
*/
export async function getCalendarSummaryStats(): Promise<
CalendarActionResponse<CalendarSummaryStats>
> {
try {
const { calendarId, serviceAccountEmail } = getGoogleCalendarClient();
const [eventsRes, tasksRes] = await Promise.all([
getCalendarEvents(),
getCalendarTasks(),
]);
const events = eventsRes.data || [];
const tasks = tasksRes.data || [];
const completedTasks = tasks.filter((t: CalendarTaskItem) => t.status === 'completed').length;
const pendingTasks = tasks.filter((t: CalendarTaskItem) => t.status === 'needsAction').length;
return {
success: true,
data: {
totalEvents: events.length,
totalTasks: tasks.length,
completedTasks,
pendingTasks,
calendarId,
serviceAccountEmail,
},
};
} catch (error: unknown) {
return {
success: false,
error: formatGoogleApiError(error),
};
}
}
+86
View File
@@ -0,0 +1,86 @@
export interface CalendarActionResponse<T = unknown> {
success: boolean;
data?: T;
error?: string;
warning?: string;
}
export interface CalendarEventItem {
id: string;
summary: string;
description?: string;
location?: string;
start: string; // ISO String or YYYY-MM-DD (inclusive for UI)
end: string; // ISO String or YYYY-MM-DD (inclusive for UI)
isAllDay: boolean;
colorId?: string;
attendees?: string[];
hangoutLink?: string;
htmlLink?: string;
creatorEmail?: string;
createdAt?: string;
updatedAt?: string;
}
export interface CreateEventInput {
summary: string;
description?: string;
location?: string;
startDateTime: string; // ISO string or YYYY-MM-DD
endDateTime: string; // ISO string or YYYY-MM-DD (inclusive from form)
isAllDay?: boolean;
colorId?: string;
attendees?: string[];
generateMeet?: boolean;
manualMeetLink?: string;
}
export interface UpdateEventInput {
summary?: string;
description?: string;
location?: string;
startDateTime?: string;
endDateTime?: string;
isAllDay?: boolean;
colorId?: string;
attendees?: string[];
generateMeet?: boolean;
manualMeetLink?: string;
}
export type TaskStatus = 'needsAction' | 'completed';
export interface CalendarTaskItem {
id: string;
title: string;
description?: string;
due: string; // ISO date/time string
status: TaskStatus;
completedAt?: string;
htmlLink?: string;
createdAt?: string;
updatedAt?: string;
}
export interface CreateTaskInput {
title: string;
description?: string;
due: string; // ISO string
status?: TaskStatus;
}
export interface UpdateTaskInput {
title?: string;
description?: string;
due?: string;
status?: TaskStatus;
}
export interface CalendarSummaryStats {
totalEvents: number;
totalTasks: number;
completedTasks: number;
pendingTasks: number;
calendarId: string;
serviceAccountEmail: string;
}
+10
View File
@@ -0,0 +1,10 @@
// Single source for facts repeated across the legal pages.
// Update LEGAL_UPDATED when the policy text changes materially.
export const LEGAL = {
appName: 'HIS Attendance Task System (H.A.T.s)',
shortName: 'H.A.T.s',
operator: 'HIS',
siteUrl: 'https://hats.hisnutech.my.id',
contactEmail: 'his.nutech@gmail.com',
updated: '19 November 2026',
} as const;
+5
View File
@@ -27,6 +27,11 @@ const nextConfig: NextConfig = {
reactStrictMode: false,
experimental: {
authInterrupts: true, // for forbidden page
// MEMORY OPTIMIZING
// 1. Prevent Next.js from loading all route modules into RAM at startup
preloadEntriesOnStart: false,
// 2. Optimize barrel imports (e.g., lucide-react, @mui/icons-material, lodash)
optimizePackageImports: ['lucide-react', 'date-fns', 'lodash'],
},
};
+326 -13
View File
@@ -36,6 +36,7 @@
"firebase": "^12.6.0",
"framer-motion": "^12.23.25",
"get-orientation": "^1.1.2",
"googleapis": "^190.0.0",
"heic2any": "^0.0.4",
"lucide-react": "^1.68.0",
"motion": "^12.38.0",
@@ -65,6 +66,7 @@
},
"devDependencies": {
"@tailwindcss/postcss": "^4",
"@tailwindcss/typography": "^0.5.20",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
@@ -5070,6 +5072,19 @@
"tailwindcss": "4.2.4"
}
},
"node_modules/@tailwindcss/typography": {
"version": "0.5.20",
"resolved": "https://registry.npmjs.org/@tailwindcss/typography/-/typography-0.5.20.tgz",
"integrity": "sha512-hwbzQuNUfcPvbegQFatVPl/MY/tcM9KLl963hQ5laJKPh81TEZ1+dNG9PirGvcaDBkp+BCshExAyKVPW91dozw==",
"dev": true,
"license": "MIT",
"dependencies": {
"postcss-selector-parser": "6.0.10"
},
"peerDependencies": {
"tailwindcss": ">=3.0.0 || >=4.0.0 || insiders"
}
},
"node_modules/@tanstack/react-table": {
"version": "8.21.3",
"resolved": "https://registry.npmjs.org/@tanstack/react-table/-/react-table-8.21.3.tgz",
@@ -5779,6 +5794,15 @@
"acorn": "^6.0.0 || ^7.0.0 || ^8.0.0"
}
},
"node_modules/agent-base": {
"version": "7.1.4",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz",
"integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==",
"license": "MIT",
"engines": {
"node": ">= 14"
}
},
"node_modules/ajv": {
"version": "6.14.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.14.0.tgz",
@@ -6296,6 +6320,15 @@
"node": ">=0.6"
}
},
"node_modules/bignumber.js": {
"version": "9.3.1",
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.3.1.tgz",
"integrity": "sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==",
"license": "MIT",
"engines": {
"node": "*"
}
},
"node_modules/binary": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz",
@@ -6416,6 +6449,12 @@
"node": "*"
}
},
"node_modules/buffer-equal-constant-time": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
"integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==",
"license": "BSD-3-Clause"
},
"node_modules/buffer-indexof-polyfill": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/buffer-indexof-polyfill/-/buffer-indexof-polyfill-1.0.2.tgz",
@@ -6469,7 +6508,6 @@
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
"integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
@@ -6717,6 +6755,19 @@
"node": ">= 8"
}
},
"node_modules/cssesc": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz",
"integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==",
"dev": true,
"license": "MIT",
"bin": {
"cssesc": "bin/cssesc"
},
"engines": {
"node": ">=4"
}
},
"node_modules/csstype": {
"version": "3.2.3",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
@@ -6730,6 +6781,15 @@
"dev": true,
"license": "BSD-2-Clause"
},
"node_modules/data-uri-to-buffer": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==",
"license": "MIT",
"engines": {
"node": ">= 12"
}
},
"node_modules/data-view-buffer": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/data-view-buffer/-/data-view-buffer-1.0.2.tgz",
@@ -6810,7 +6870,6 @@
"version": "4.4.3",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
"dev": true,
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
@@ -6973,6 +7032,15 @@
"safe-buffer": "~5.1.0"
}
},
"node_modules/ecdsa-sig-formatter": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",
"integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==",
"license": "Apache-2.0",
"dependencies": {
"safe-buffer": "^5.0.1"
}
},
"node_modules/electron-to-chromium": {
"version": "1.5.344",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.344.tgz",
@@ -7631,6 +7699,12 @@
"node": ">=8.3.0"
}
},
"node_modules/extend": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
"integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==",
"license": "MIT"
},
"node_modules/fast-csv": {
"version": "4.3.6",
"resolved": "https://registry.npmjs.org/fast-csv/-/fast-csv-4.3.6.tgz",
@@ -7717,6 +7791,29 @@
"node": ">=0.8.0"
}
},
"node_modules/fetch-blob": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
},
{
"type": "paypal",
"url": "https://paypal.me/jimmywarting"
}
],
"license": "MIT",
"dependencies": {
"node-domexception": "^1.0.0",
"web-streams-polyfill": "^3.0.3"
},
"engines": {
"node": "^12.20 || >= 14.13"
}
},
"node_modules/file-entry-cache": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz",
@@ -7881,6 +7978,18 @@
"node": ">= 6"
}
},
"node_modules/formdata-polyfill": {
"version": "4.0.10",
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
"license": "MIT",
"dependencies": {
"fetch-blob": "^3.1.2"
},
"engines": {
"node": ">=12.20.0"
}
},
"node_modules/framer-motion": {
"version": "12.38.0",
"resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-12.38.0.tgz",
@@ -7976,6 +8085,34 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/gaxios": {
"version": "8.3.3",
"resolved": "https://registry.npmjs.org/gaxios/-/gaxios-8.3.3.tgz",
"integrity": "sha512-zqPbbtW5bAOZ8BRjS7bxj5VG7PBY5PwKRxpku9NplLqAPmYMoXExL1KOdaK5fHvwRETu3bPplLEsFGDdUUlrpw==",
"license": "Apache-2.0",
"dependencies": {
"extend": "^3.0.2",
"https-proxy-agent": "^7.0.1",
"node-fetch": "^3.3.2"
},
"engines": {
"node": ">=22"
}
},
"node_modules/gcp-metadata": {
"version": "9.2.3",
"resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-9.2.3.tgz",
"integrity": "sha512-d2OI/dJJ3IIaeOz3c9jvr5j5G5beI5fQzbgilNiWhDKGwvJN9o10Qub70NkbF6PNJSUoNKZ77JKYGz0Fs4+9Lg==",
"license": "Apache-2.0",
"dependencies": {
"gaxios": "^8.3.1",
"google-logging-utils": "^2.1.0",
"json-bigint": "^1.0.0"
},
"engines": {
"node": ">=22"
}
},
"node_modules/generator-function": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/generator-function/-/generator-function-2.0.1.tgz",
@@ -8155,6 +8292,62 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/google-auth-library": {
"version": "11.3.4",
"resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-11.3.4.tgz",
"integrity": "sha512-RaYCDoeYIIFTRgH8hesSxqLrmtC2l+DB3cSCS/SN1TPGjI2VpPdJmF3bfRLUn8VvP/4I2Af9fsktw2f9SvVSVg==",
"license": "Apache-2.0",
"dependencies": {
"base64-js": "^1.3.0",
"ecdsa-sig-formatter": "^1.0.11",
"gaxios": "^8.3.1",
"gcp-metadata": "^9.2.1",
"google-logging-utils": "^2.1.0",
"jws": "^4.0.0"
},
"engines": {
"node": ">=22"
}
},
"node_modules/google-logging-utils": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/google-logging-utils/-/google-logging-utils-2.2.0.tgz",
"integrity": "sha512-Q6HuSEyoaxi0AgqUrOYb2gc77fDl4QugRoHpreI8VpW/VzPsoKyxjL8tGKLmZpWlvC1uVBXM85tykoQpCGBF5g==",
"license": "Apache-2.0",
"engines": {
"node": ">=22"
}
},
"node_modules/googleapis": {
"version": "190.0.0",
"resolved": "https://registry.npmjs.org/googleapis/-/googleapis-190.0.0.tgz",
"integrity": "sha512-/1dTKpv9epj6RPMsrlKdyNtby1flh+d39rCWYCU+6bY4RHgZUPYB+B9cRKYsBqqTWyfBkHum0NCthIWJROcUjw==",
"license": "Apache-2.0",
"dependencies": {
"google-auth-library": "^11.0.0",
"googleapis-common": "^9.0.0"
},
"engines": {
"node": ">=22.0.0"
}
},
"node_modules/googleapis-common": {
"version": "9.3.1",
"resolved": "https://registry.npmjs.org/googleapis-common/-/googleapis-common-9.3.1.tgz",
"integrity": "sha512-wtv/e7JYgmtpIPcSez2EFD/Wx49DPsRX2rj15D7hTwc7tDsP82dcwoX/I4+zE38mu6S9PcghizzzADLf+ZMunA==",
"license": "Apache-2.0",
"dependencies": {
"extend": "^3.0.2",
"gaxios": "^8.3.0",
"google-auth-library": "^11.0.0",
"google-logging-utils": "^2.0.0",
"qs": "^6.7.0",
"url-template": "^2.0.8"
},
"engines": {
"node": ">=22"
}
},
"node_modules/gopd": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
@@ -8293,6 +8486,19 @@
"integrity": "sha512-Pysuw9XpUq5dVc/2SMHpuTY01RFl8fttgcyunjL7eEMhGM3cI4eOmiCycJDVCo/7O7ClfQD3SaI6ftDzqOXYMA==",
"license": "MIT"
},
"node_modules/https-proxy-agent": {
"version": "7.0.6",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz",
"integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==",
"license": "MIT",
"dependencies": {
"agent-base": "^7.1.2",
"debug": "4"
},
"engines": {
"node": ">= 14"
}
},
"node_modules/idb": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/idb/-/idb-7.1.1.tgz",
@@ -8907,6 +9113,15 @@
"node": ">=6"
}
},
"node_modules/json-bigint": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz",
"integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==",
"license": "MIT",
"dependencies": {
"bignumber.js": "^9.0.0"
}
},
"node_modules/json-buffer": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz",
@@ -9014,6 +9229,27 @@
"safe-buffer": "~5.1.0"
}
},
"node_modules/jwa": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.1.tgz",
"integrity": "sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg==",
"license": "MIT",
"dependencies": {
"buffer-equal-constant-time": "^1.0.1",
"ecdsa-sig-formatter": "1.0.11",
"safe-buffer": "^5.0.1"
}
},
"node_modules/jws": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/jws/-/jws-4.0.1.tgz",
"integrity": "sha512-EKI/M/yqPncGUUh44xz0PxSidXFr/+r0pA70+gIYhjv+et7yxM+s29Y+VGDkovRofQem0fs7Uvf4+YmAdyRduA==",
"license": "MIT",
"dependencies": {
"jwa": "^2.0.1",
"safe-buffer": "^5.0.1"
}
},
"node_modules/keyv": {
"version": "4.5.4",
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz",
@@ -9687,7 +9923,6 @@
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"dev": true,
"license": "MIT"
},
"node_modules/nanoid": {
@@ -9854,6 +10089,26 @@
"node": "^10 || ^12 || >=14"
}
},
"node_modules/node-domexception": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
"deprecated": "Use your platform's native DOMException instead",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
},
{
"type": "github",
"url": "https://paypal.me/jimmywarting"
}
],
"license": "MIT",
"engines": {
"node": ">=10.5.0"
}
},
"node_modules/node-exports-info": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/node-exports-info/-/node-exports-info-1.6.0.tgz",
@@ -9873,6 +10128,24 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/node-fetch": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz",
"integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==",
"license": "MIT",
"dependencies": {
"data-uri-to-buffer": "^4.0.0",
"fetch-blob": "^3.1.4",
"formdata-polyfill": "^4.0.10"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/node-fetch"
}
},
"node_modules/node-releases": {
"version": "2.0.38",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.38.tgz",
@@ -9923,7 +10196,6 @@
"version": "1.13.4",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
"integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.4"
@@ -10282,6 +10554,20 @@
"node": "^10 || ^12 || >=14"
}
},
"node_modules/postcss-selector-parser": {
"version": "6.0.10",
"resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.10.tgz",
"integrity": "sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==",
"dev": true,
"license": "MIT",
"dependencies": {
"cssesc": "^3.0.0",
"util-deprecate": "^1.0.2"
},
"engines": {
"node": ">=4"
}
},
"node_modules/preact": {
"version": "10.29.1",
"resolved": "https://registry.npmjs.org/preact/-/preact-10.29.1.tgz",
@@ -10392,6 +10678,22 @@
"node": ">=6"
}
},
"node_modules/qs": {
"version": "6.17.1",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.17.1.tgz",
"integrity": "sha512-jd3COkaKVgGUW+ZHyEHCG9bH7RoaaiWuMgzsIBjUMVjLAaWGWpoUAVwljVvBHxRu/2qEHnadLGZrkutYUBPQJA==",
"license": "BSD-3-Clause",
"dependencies": {
"es-define-property": "^1.0.1",
"side-channel": "^1.1.1"
},
"engines": {
"node": ">=0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/queue-microtask": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
@@ -11260,15 +11562,14 @@
}
},
"node_modules/side-channel": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",
"integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",
"dev": true,
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz",
"integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.3",
"side-channel-list": "^1.0.0",
"object-inspect": "^1.13.4",
"side-channel-list": "^1.0.1",
"side-channel-map": "^1.0.1",
"side-channel-weakmap": "^1.0.2"
},
@@ -11283,7 +11584,6 @@
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz",
"integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==",
"dev": true,
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
@@ -11300,7 +11600,6 @@
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
"integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
@@ -11319,7 +11618,6 @@
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
"integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
"dev": true,
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
@@ -12168,6 +12466,12 @@
"punycode": "^2.1.0"
}
},
"node_modules/url-template": {
"version": "2.0.8",
"resolved": "https://registry.npmjs.org/url-template/-/url-template-2.0.8.tgz",
"integrity": "sha512-XdVKMF4SJ0nP/O7XIPB0JwAEuT9lDIYnNsK8yGVe43y0AWoKeJNdv3ZNWh7ksJ6KqQFjOO6ox/VEitLnaVNufw==",
"license": "BSD"
},
"node_modules/use-callback-ref": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/use-callback-ref/-/use-callback-ref-1.3.3.tgz",
@@ -12265,6 +12569,15 @@
}
}
},
"node_modules/web-streams-polyfill": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz",
"integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==",
"license": "MIT",
"engines": {
"node": ">= 8"
}
},
"node_modules/web-vitals": {
"version": "4.2.4",
"resolved": "https://registry.npmjs.org/web-vitals/-/web-vitals-4.2.4.tgz",
+4 -2
View File
@@ -12,7 +12,7 @@
"url": "https://github.com/ichsankurnia/hats-app/issues"
},
"scripts": {
"dev": "next dev -p 1209",
"dev": "set NODE_OPTIONS=\"--max-old-space-size=2048\" && next dev -p 1209",
"dev:save": "set NODE_TLS_REJECT_UNAUTHORIZED='0' && next dev -p 1209",
"build": "next build",
"start": "next start -p 7002",
@@ -51,6 +51,7 @@
"firebase": "^12.6.0",
"framer-motion": "^12.23.25",
"get-orientation": "^1.1.2",
"googleapis": "^190.0.0",
"heic2any": "^0.0.4",
"lucide-react": "^1.68.0",
"motion": "^12.38.0",
@@ -80,6 +81,7 @@
},
"devDependencies": {
"@tailwindcss/postcss": "^4",
"@tailwindcss/typography": "^0.5.20",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
@@ -93,4 +95,4 @@
"tw-animate-css": "^1.4.0",
"typescript": "^5"
}
}
}
+1 -1
View File
@@ -30,5 +30,5 @@
".next/dev/types/**/*.ts",
"**/*.mts"
],
"exclude": ["node_modules", "**/*.old.tsx", "**/*.old.ts"]
"exclude": ["node_modules", ".next", "**/*.old.tsx", "**/*.old.ts"]
}