From 909c22dc45c826eadba904ce31eefa87340419c1 Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Sat, 24 Jan 2026 03:33:48 +0530 Subject: [PATCH] fix --- .gitignore | 1 + firebase-debug.log | 14 + src/app/dashboard/agent-types/page.tsx | 433 +++++++++ .../dashboard/profile-sections/[id]/page.tsx | 890 ++++++++++++++++++ src/app/dashboard/profile-sections/page.tsx | 491 ++++++++++ src/app/globals.css | 7 - src/components/Sidebar.tsx | 28 + src/services/agent-types.service.ts | 66 ++ src/services/index.ts | 32 + src/services/profile-fields.service.ts | 166 ++++ src/services/profile-sections.service.ts | 125 +++ 11 files changed, 2246 insertions(+), 7 deletions(-) create mode 100644 firebase-debug.log create mode 100644 src/app/dashboard/agent-types/page.tsx create mode 100644 src/app/dashboard/profile-sections/[id]/page.tsx create mode 100644 src/app/dashboard/profile-sections/page.tsx create mode 100644 src/services/agent-types.service.ts create mode 100644 src/services/profile-fields.service.ts create mode 100644 src/services/profile-sections.service.ts diff --git a/.gitignore b/.gitignore index 5ef6a52..00a54a7 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts +CLAUDE.md diff --git a/firebase-debug.log b/firebase-debug.log new file mode 100644 index 0000000..d446700 --- /dev/null +++ b/firebase-debug.log @@ -0,0 +1,14 @@ +[debug] [2026-01-23T19:18:31.890Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"] +[debug] [2026-01-23T19:18:31.892Z] > authorizing via signed-in user (ppradeepd@gmail.com) +[debug] [2026-01-23T19:18:31.892Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"] +[debug] [2026-01-23T19:18:31.892Z] > authorizing via signed-in user (ppradeepd@gmail.com) +[debug] [2026-01-23T19:18:31.901Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"] +[debug] [2026-01-23T19:18:31.902Z] > authorizing via signed-in user (ppradeepd@gmail.com) +[debug] [2026-01-23T19:18:32.021Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"] +[debug] [2026-01-23T19:18:32.021Z] > authorizing via signed-in user (ppradeepd@gmail.com) +[debug] [2026-01-23T19:18:32.022Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"] +[debug] [2026-01-23T19:18:32.022Z] > authorizing via signed-in user (ppradeepd@gmail.com) +[debug] [2026-01-23T19:18:32.057Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"] +[debug] [2026-01-23T19:18:32.057Z] > authorizing via signed-in user (ppradeepd@gmail.com) +[debug] [2026-01-23T19:18:32.058Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"] +[debug] [2026-01-23T19:18:32.058Z] > authorizing via signed-in user (ppradeepd@gmail.com) diff --git a/src/app/dashboard/agent-types/page.tsx b/src/app/dashboard/agent-types/page.tsx new file mode 100644 index 0000000..05207e5 --- /dev/null +++ b/src/app/dashboard/agent-types/page.tsx @@ -0,0 +1,433 @@ +'use client'; + +import { useEffect, useState } from 'react'; +import { useRouter } from 'next/navigation'; +import { agentTypesService, AgentType, CreateAgentTypeDto, UpdateAgentTypeDto, getErrorMessage } from '@/services'; + +type ModalType = 'create' | 'edit' | 'delete' | null; + +export default function AgentTypesPage() { + const router = useRouter(); + const [agentTypes, setAgentTypes] = useState([]); + const [isLoading, setIsLoading] = useState(true); + const [error, setError] = useState(''); + const [showInactive, setShowInactive] = useState(true); + + // Modal state + const [modalType, setModalType] = useState(null); + const [selectedType, setSelectedType] = useState(null); + const [isSubmitting, setIsSubmitting] = useState(false); + const [modalError, setModalError] = useState(''); + + // Form state + const [formData, setFormData] = useState({ + name: '', + description: '', + icon: '', + isActive: true, + sortOrder: 0, + }); + + useEffect(() => { + fetchAgentTypes(); + }, [showInactive]); + + const fetchAgentTypes = async () => { + setIsLoading(true); + setError(''); + try { + const data = await agentTypesService.getAll(showInactive); + setAgentTypes(data); + } catch (err) { + const errorMessage = getErrorMessage(err); + setError(errorMessage); + if (errorMessage.includes('Unauthorized')) { + router.push('/login'); + } + } finally { + setIsLoading(false); + } + }; + + const openCreateModal = () => { + setFormData({ + name: '', + description: '', + icon: '', + isActive: true, + sortOrder: 0, + }); + setModalError(''); + setModalType('create'); + }; + + const openEditModal = (agentType: AgentType) => { + setSelectedType(agentType); + setFormData({ + name: agentType.name, + description: agentType.description || '', + icon: agentType.icon || '', + isActive: agentType.isActive, + sortOrder: agentType.sortOrder, + }); + setModalError(''); + setModalType('edit'); + }; + + const openDeleteModal = (agentType: AgentType) => { + setSelectedType(agentType); + setModalError(''); + setModalType('delete'); + }; + + const closeModal = () => { + setModalType(null); + setSelectedType(null); + setModalError(''); + }; + + const handleCreate = async (e: React.FormEvent) => { + e.preventDefault(); + setIsSubmitting(true); + setModalError(''); + try { + await agentTypesService.create(formData); + closeModal(); + fetchAgentTypes(); + } catch (err) { + setModalError(getErrorMessage(err)); + } finally { + setIsSubmitting(false); + } + }; + + const handleUpdate = async (e: React.FormEvent) => { + e.preventDefault(); + if (!selectedType) return; + setIsSubmitting(true); + setModalError(''); + try { + await agentTypesService.update(selectedType.id, formData as UpdateAgentTypeDto); + closeModal(); + fetchAgentTypes(); + } catch (err) { + setModalError(getErrorMessage(err)); + } finally { + setIsSubmitting(false); + } + }; + + const handleDelete = async () => { + if (!selectedType) return; + setIsSubmitting(true); + setModalError(''); + try { + await agentTypesService.delete(selectedType.id); + closeModal(); + fetchAgentTypes(); + } catch (err) { + setModalError(getErrorMessage(err)); + } finally { + setIsSubmitting(false); + } + }; + + const toggleStatus = async (agentType: AgentType) => { + try { + await agentTypesService.update(agentType.id, { isActive: !agentType.isActive }); + fetchAgentTypes(); + } catch (err) { + setError(getErrorMessage(err)); + } + }; + + return ( +
+ {/* Page Title */} +
+

Agent Types

+

Manage agent categories and types

+
+ + {/* Agent Types Table */} +
+
+
+
+ +
+
+ + +
+
+
+ + {error && ( +
+

{error}

+
+ )} + +
+ {isLoading ? ( +
+
+
+ ) : agentTypes.length === 0 ? ( +
+ + + +

No agent types found

+ +
+ ) : ( + + + + + + + + + + + + + + {agentTypes.map((agentType) => ( + + + + + + + + + + ))} + +
+ Name + + Description + + Icon + + Sort Order + + Status + + Agents + + Actions +
+
{agentType.name}
+
+
+ {agentType.description || '-'} +
+
+
{agentType.icon || '-'}
+
+
{agentType.sortOrder}
+
+ + +
{agentType._count?.agents || 0}
+
+ + +
+ )} +
+
+ + {/* Create/Edit Modal */} + {(modalType === 'create' || modalType === 'edit') && ( +
+
+
+

+ {modalType === 'create' ? 'Create Agent Type' : 'Edit Agent Type'} +

+
+
+
+ {modalError && ( +
+

{modalError}

+
+ )} +
+ + setFormData({ ...formData, name: e.target.value })} + className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-gray-900 bg-white" + required + /> +
+
+ +