Add roll-call Start/Stop UX to business and customer dashboards.
Owners/admins can run timed work days, manage tasks in a modal, and stop from the FAB or row control. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
ac287e02cc
commit
c4e846564e
@@ -0,0 +1,102 @@
|
||||
import { apiRequest } from '../lib/api'
|
||||
import { getActiveBusinessId } from '../lib/businessContext'
|
||||
|
||||
export interface RollCallTask {
|
||||
id: string
|
||||
title: string
|
||||
sortOrder: number
|
||||
}
|
||||
|
||||
export interface RollCall {
|
||||
id: string
|
||||
businessId: string
|
||||
userId: string
|
||||
workDate: string
|
||||
startTime: string
|
||||
endTime: string
|
||||
workingMinutes: number
|
||||
taskCount: number
|
||||
tasks: RollCallTask[]
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export interface RollCallSummary {
|
||||
totalDays: number
|
||||
totalWorkingMinutes: number
|
||||
totalTasks: number
|
||||
}
|
||||
|
||||
export interface RollCallsListResponse {
|
||||
items: RollCall[]
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
summary: RollCallSummary
|
||||
}
|
||||
|
||||
export interface ListRollCallsParams {
|
||||
dateFrom?: string
|
||||
dateTo?: string
|
||||
page?: number
|
||||
pageSize?: number
|
||||
}
|
||||
|
||||
export interface RollCallInput {
|
||||
workDate: string
|
||||
startTime: string
|
||||
endTime: string
|
||||
tasks?: { title: string }[]
|
||||
}
|
||||
|
||||
export type RollCallPatch = Partial<RollCallInput>
|
||||
|
||||
function businessPath(suffix = '') {
|
||||
const businessId = getActiveBusinessId()
|
||||
if (!businessId) {
|
||||
throw new Error('No active business selected. Please sign in again.')
|
||||
}
|
||||
return `/businesses/${businessId}/roll-calls${suffix}`
|
||||
}
|
||||
|
||||
export async function listRollCalls(
|
||||
params: ListRollCallsParams = {},
|
||||
signal?: AbortSignal,
|
||||
) {
|
||||
const q = new URLSearchParams()
|
||||
if (params.dateFrom) q.set('dateFrom', params.dateFrom)
|
||||
if (params.dateTo) q.set('dateTo', params.dateTo)
|
||||
if (params.page !== undefined) q.set('page', String(params.page))
|
||||
if (params.pageSize !== undefined) q.set('pageSize', String(params.pageSize))
|
||||
const query = q.toString()
|
||||
return apiRequest<RollCallsListResponse>(
|
||||
`${businessPath()}${query ? `?${query}` : ''}`,
|
||||
{ auth: true, signal },
|
||||
)
|
||||
}
|
||||
|
||||
export async function createRollCall(input: RollCallInput) {
|
||||
return apiRequest<{ rollCall: RollCall; message: string }>(businessPath(), {
|
||||
method: 'POST',
|
||||
auth: true,
|
||||
body: input,
|
||||
})
|
||||
}
|
||||
|
||||
export async function updateRollCall(rollCallId: string, input: RollCallPatch) {
|
||||
return apiRequest<{ rollCall: RollCall; message: string }>(
|
||||
businessPath(`/${rollCallId}`),
|
||||
{
|
||||
method: 'PATCH',
|
||||
auth: true,
|
||||
body: input,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
export async function removeRollCall(rollCallId: string) {
|
||||
return apiRequest<{ message: string }>(businessPath(`/${rollCallId}`), {
|
||||
method: 'DELETE',
|
||||
auth: true,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user