From 9e423f073060e181fa829ddf42e8f223fba8f141 Mon Sep 17 00:00:00 2001 From: suryacp23 Date: Thu, 16 Jul 2026 19:28:49 +0530 Subject: [PATCH] added all logs page and presetalias added to mylogs --- src/App.tsx | 7 ++- src/api/client.ts | 1 + src/api/types.ts | 1 + src/components/rv/DailyLogsView.tsx | 5 +- src/components/rv/RecordView.tsx | 7 ++- src/screens/AllDailyLogsPage.tsx | 95 +++++++++++++++++++++++++++++ src/screens/ConsoleLayout.tsx | 4 +- src/screens/tabs.ts | 7 ++- 8 files changed, 117 insertions(+), 10 deletions(-) create mode 100644 src/screens/AllDailyLogsPage.tsx diff --git a/src/App.tsx b/src/App.tsx index 5a981c2..8f57cb5 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -6,6 +6,7 @@ import { OrdersPage } from './screens/OrdersPage' import { CallsPage } from './screens/CallsPage' import { StoresPage } from './screens/StoresPage' import { DailyLogsPage } from './screens/DailyLogsPage' +import { AllDailyLogsPage } from './screens/AllDailyLogsPage' import { AnalyticsPage } from './screens/AnalyticsPage' function App() { return ( @@ -26,9 +27,13 @@ function App() { } /> } /> + } /> + } /> + + } /> - } /> + } /> diff --git a/src/api/client.ts b/src/api/client.ts index a30bfad..3f1f9fa 100644 --- a/src/api/client.ts +++ b/src/api/client.ts @@ -146,6 +146,7 @@ export class ZinoClient { recordView(rvUid: string, params: RecordViewParams = {}): Promise { return this.request('POST', `/app/${APP_ID}/view/recordview`, { rv_template_uid: rvUid, + preset_alias: params.preset_alias, search_query: { page: params.page ?? 1, limit: params.limit ?? 50, diff --git a/src/api/types.ts b/src/api/types.ts index c8a1298..42ee795 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -53,6 +53,7 @@ export interface RecordViewParams { sortDir?: 'asc' | 'desc'; search?: string; filters?: Array<{ field_key: string; value: string; data_type?: string }>; + preset_alias?: string; } // --- Form schema (POST /app/{appId}/view/form-screens) --- diff --git a/src/components/rv/DailyLogsView.tsx b/src/components/rv/DailyLogsView.tsx index e7b8c2b..b74960d 100644 --- a/src/components/rv/DailyLogsView.tsx +++ b/src/components/rv/DailyLogsView.tsx @@ -5,16 +5,17 @@ import type { WiredRecordViewProps } from './OrdersView'; import { DailyLogCard } from '../cards/DailyLogCard'; /** Daily Logs record view (Daily Reports workflow). */ -export function DailyLogsView({ onRowClick, onPunchOutRow, pageSize, headerActions, refreshKey }: WiredRecordViewProps & { onPunchOutRow?: (row: any) => void }) { +export function DailyLogsView({ onRowClick, onPunchOutRow, pageSize, headerActions, refreshKey, preset_alias = "my_logs", title = "Daily Logs" }: WiredRecordViewProps & { onPunchOutRow?: (row: any) => void, preset_alias?: string, title?: string }) { return ( { live = false; }; - }, [client, rvUid, page, pageSize, debounced, filtersParam, refreshKey, sortBy, sortDir]); + }, [client, rvUid, preset_alias, page, pageSize, debounced, filtersParam, refreshKey, sortBy, sortDir]); const fields: RecordViewField[] = useMemo(() => { const all = resp?.config.fields ?? []; diff --git a/src/screens/AllDailyLogsPage.tsx b/src/screens/AllDailyLogsPage.tsx new file mode 100644 index 0000000..c0c9dec --- /dev/null +++ b/src/screens/AllDailyLogsPage.tsx @@ -0,0 +1,95 @@ +import { useNavigate, useParams } from 'react-router-dom'; +import { Modal } from '../components/reusable'; +import { DailyLogsView } from '../components/rv'; +import { DailyLogDetail } from '../components/dv'; +import { useState } from 'react'; + +import { ClipboardList } from 'lucide-react'; +import { DynamicForm } from '../components/forms/DynamicForm'; +import { DAILY_REPORTS } from '../api/config'; +import { dailyReportsClient } from '../api/clients'; + +export function AllDailyLogsPage() { + const params = useParams(); + const instanceId = params.instanceId ? Number(params.instanceId) : undefined; + const navigate = useNavigate(); + const [isCreating, setIsCreating] = useState(false); + const [createTitle, setCreateTitle] = useState("Punch In"); + const [punchOutInstanceId, setPunchOutInstanceId] = useState(null); + const [punchOutTitle, setPunchOutTitle] = useState("Punch Out"); + const [refreshKey, setRefreshKey] = useState(0); + + return ( + <> + { + const id = row.instance_id as number | string | undefined; + if (id != null) navigate(`/all-daily/${id}`); + }} + onPunchOutRow={(row) => { + setPunchOutInstanceId(row.instance_id as string | number); + setPunchOutTitle("Punch Out"); + }} + /> + + {/* Global Floating Action Button for Punch In */} + + + setIsCreating(false)} + title={createTitle} + width="md" + > + { + setIsCreating(false); + setRefreshKey(k => k + 1); + }} + onCancel={() => setIsCreating(false)} + onActivityChange={(name) => setCreateTitle(name)} + /> + + + setPunchOutInstanceId(null)} + title={punchOutTitle} + width="md" + > + {punchOutInstanceId != null && ( + { + setPunchOutInstanceId(null); + setRefreshKey(k => k + 1); + }} + onCancel={() => setPunchOutInstanceId(null)} + onActivityChange={(name) => setPunchOutTitle(name)} + /> + )} + + + navigate(`/all-daily`)} + title={instanceId != null ? `Daily Log #${instanceId}` : undefined} + width="lg" + > + {instanceId != null && } + + + ); +} diff --git a/src/screens/ConsoleLayout.tsx b/src/screens/ConsoleLayout.tsx index ffa3d79..ac5454b 100644 --- a/src/screens/ConsoleLayout.tsx +++ b/src/screens/ConsoleLayout.tsx @@ -52,9 +52,9 @@ export function ConsoleLayout() {