@fayz-ai/plugin-agenda 0.24.1 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { EntityDef, FieldDef } from '@fayz-ai/core';
|
|
2
3
|
import type { CalendarBooking } from '../types';
|
|
3
4
|
export interface CheckinRequirement {
|
|
4
5
|
/** Nome do que falta — "Anamnese", "Termo de consentimento". */
|
|
@@ -12,6 +13,8 @@ export interface CheckinRequirement {
|
|
|
12
13
|
label: string;
|
|
13
14
|
onClick: () => void;
|
|
14
15
|
};
|
|
16
|
+
/** A record field the reception can answer here, in the client record modal. */
|
|
17
|
+
field?: FieldDef;
|
|
15
18
|
}
|
|
16
19
|
export interface CheckinDialogProps {
|
|
17
20
|
booking: CalendarBooking;
|
|
@@ -29,8 +32,14 @@ export interface CheckinDialogProps {
|
|
|
29
32
|
* novo. Receber continua valendo; a recepção cobra na saída.
|
|
30
33
|
*/
|
|
31
34
|
onConfirm?: (b: CalendarBooking) => Promise<void>;
|
|
35
|
+
/** The client record, edited in a modal over the check-in. Without it, `field` requirements fall back to their `action`. */
|
|
36
|
+
clientRecord?: {
|
|
37
|
+
entityDef: EntityDef;
|
|
38
|
+
load: () => Promise<Record<string, any> | null>;
|
|
39
|
+
save: (data: Record<string, any>) => Promise<void>;
|
|
40
|
+
};
|
|
32
41
|
onClose: () => void;
|
|
33
42
|
formatCurrency?: (n: number) => string;
|
|
34
43
|
}
|
|
35
|
-
export declare function CheckinDialog({ booking, statusLabel, requirements, onReceive, onConfirm, onClose, formatCurrency, }: CheckinDialogProps): React.JSX.Element;
|
|
44
|
+
export declare function CheckinDialog({ booking, statusLabel, requirements, onReceive, onConfirm, clientRecord, onClose, formatCurrency, }: CheckinDialogProps): React.JSX.Element;
|
|
36
45
|
//# sourceMappingURL=CheckinDialog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckinDialog.d.ts","sourceRoot":"","sources":["../../src/components/CheckinDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAsB/C,MAAM,WAAW,kBAAkB;IACjC,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAA;IACb,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAA;IACd,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,oDAAoD;IACpD,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,IAAI,CAAA;KAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"CheckinDialog.d.ts","sourceRoot":"","sources":["../../src/components/CheckinDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAsB/C,MAAM,WAAW,kBAAkB;IACjC,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAA;IACb,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAA;IACd,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,oDAAoD;IACpD,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,IAAI,CAAA;KAAE,CAAA;IAC/C,gFAAgF;IAChF,KAAK,CAAC,EAAE,QAAQ,CAAA;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,eAAe,CAAA;IACxB,WAAW,EAAE,MAAM,CAAA;IACnB,sFAAsF;IACtF,YAAY,CAAC,EAAE,kBAAkB,EAAE,CAAA;IACnC,mFAAmF;IACnF,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,eAAe,KAAK,IAAI,CAAA;IACxC;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACjD,4HAA4H;IAC5H,YAAY,CAAC,EAAE;QACb,SAAS,EAAE,SAAS,CAAA;QACpB,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;QAC/C,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;KACnD,CAAA;IACD,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;CACvC;AAID,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EAAE,WAAW,EAAE,YAAiB,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,cAAoB,GAC3G,EAAE,kBAAkB,qBA+JpB"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createMockAgendaProvider, createSupabasePublicBookingProvider } from './chunk-A77PUFY5.js';
|
|
2
2
|
export { createMockAgendaProvider } from './chunk-A77PUFY5.js';
|
|
3
3
|
import React23, { useState, useEffect, useRef, useMemo, useCallback, useLayoutEffect } from 'react';
|
|
4
|
-
import { tl, recordRailFields, RECORD_GROUP, activeFacet, connectionStatus, createConnectionStore, getActiveTenantId, createSafeDataProvider, todayLocal, getSupabaseClientOptional, registerTranslations, registerMessageDefaults, connectorRuntimeToken, CONNECTOR_RUNTIME_TOKEN_HEADER, getActiveUnitId, assertWrote, emitDataChanged, globalCache, usePluginRuntimeOptional, useTranslation, useActiveUnitId, emitDomainEvent, getCurrentLocale, localDateKey, useDataChanged, describeError, formatCurrency
|
|
5
|
-
import { createPluginContext, fayzConnectorOAuth, UNIT_DETAIL_ZONES, setScheduleBlockConfig, getScheduleBlockConfig, registerPersonActions, PluginSettingsPanel, adminNavigateTo, createArchetypeLookup, dedup, usePluginPrefs, PersonLink, useTenantPluginSettings, SettingsGroup, ToggleRow, SelectRow, usePermissionOptional, useAdminPath, PageActions, useRightRailStore, useFieldRules, deriveEntityKey, openEntity, ScheduleEditor, useLimitGuard, useLookupCreate, CrudFormPage, CrudDetailPage, ContactPicker, PaymentStatusBadge as PaymentStatusBadge$1, RightRailPage, invalidateLimit } from '@fayz-ai/admin';
|
|
4
|
+
import { tl, recordRailFields, RECORD_GROUP, activeFacet, connectionStatus, createConnectionStore, getActiveTenantId, createSafeDataProvider, todayLocal, getSupabaseClientOptional, registerTranslations, registerMessageDefaults, connectorRuntimeToken, CONNECTOR_RUNTIME_TOKEN_HEADER, getActiveUnitId, assertWrote, emitDataChanged, globalCache, usePluginRuntimeOptional, useTranslation, useActiveUnitId, emitDomainEvent, getCurrentLocale, localDateKey, useDataChanged, resolveDataProvider, describeError, formatCurrency } from '@fayz-ai/core';
|
|
5
|
+
import { createPluginContext, fayzConnectorOAuth, UNIT_DETAIL_ZONES, setScheduleBlockConfig, getScheduleBlockConfig, registerPersonActions, PluginSettingsPanel, adminNavigateTo, createArchetypeLookup, dedup, usePluginPrefs, PersonLink, useTenantPluginSettings, SettingsGroup, ToggleRow, SelectRow, usePermissionOptional, useAdminPath, PageActions, useRightRailStore, useFieldRules, deriveEntityKey, openEntity, ScheduleEditor, useLimitGuard, useLookupCreate, CrudFormPage, CrudDetailPage, ContactPicker, PaymentStatusBadge as PaymentStatusBadge$1, RightRailPage, CrudRecordModal, invalidateLimit } from '@fayz-ai/admin';
|
|
6
6
|
import FullCalendar from '@fullcalendar/react';
|
|
7
7
|
import dayGridPlugin from '@fullcalendar/daygrid';
|
|
8
8
|
import timeGridPlugin from '@fullcalendar/timegrid';
|
|
@@ -6041,9 +6041,12 @@ function CheckinDialog({
|
|
|
6041
6041
|
requirements = [],
|
|
6042
6042
|
onReceive,
|
|
6043
6043
|
onConfirm,
|
|
6044
|
+
clientRecord,
|
|
6044
6045
|
onClose,
|
|
6045
6046
|
formatCurrency: formatCurrency2 = brl
|
|
6046
6047
|
}) {
|
|
6048
|
+
const canCompleteInline = !!clientRecord && requirements.some((r) => r.field);
|
|
6049
|
+
const [completing, setCompleting] = React23.useState(false);
|
|
6047
6050
|
const [busy, setBusy] = React23.useState(false);
|
|
6048
6051
|
const [preenchendo, setPreenchendo] = React23.useState(null);
|
|
6049
6052
|
const [preenchidos, setPreenchidos] = React23.useState(0);
|
|
@@ -6092,16 +6095,28 @@ function CheckinDialog({
|
|
|
6092
6095
|
label: r.label,
|
|
6093
6096
|
state: r.blocking ? "late" : "todo",
|
|
6094
6097
|
detail: r.detail,
|
|
6095
|
-
action: r.action
|
|
6098
|
+
action: r.field && canCompleteInline ? { label: "Completar cadastro", onClick: () => setCompleting(true) } : r.action
|
|
6096
6099
|
})),
|
|
6097
6100
|
onPending: setPendencias,
|
|
6098
6101
|
onFill: (templateId) => setPreenchendo(templateId)
|
|
6099
6102
|
}
|
|
6100
6103
|
),
|
|
6104
|
+
canCompleteInline && /* @__PURE__ */ jsx(
|
|
6105
|
+
CrudRecordModal,
|
|
6106
|
+
{
|
|
6107
|
+
open: completing,
|
|
6108
|
+
onClose: () => setCompleting(false),
|
|
6109
|
+
onSaved: () => setCompleting(false),
|
|
6110
|
+
entityDef: clientRecord.entityDef,
|
|
6111
|
+
load: clientRecord.load,
|
|
6112
|
+
save: clientRecord.save,
|
|
6113
|
+
title: `Completar cadastro \u2014 ${booking.clientName ?? "cliente"}`,
|
|
6114
|
+
highlightMissing: true
|
|
6115
|
+
}
|
|
6116
|
+
),
|
|
6101
6117
|
preenchendo && booking.clientId && /* @__PURE__ */ jsx(
|
|
6102
6118
|
FormFillDialog,
|
|
6103
6119
|
{
|
|
6104
|
-
frame: "inline",
|
|
6105
6120
|
templateId: preenchendo,
|
|
6106
6121
|
personId: booking.clientId,
|
|
6107
6122
|
personName: booking.clientName,
|
|
@@ -6365,6 +6380,22 @@ function CheckinView({ onReceive, onOpenBooking, onOpenAttendance }) {
|
|
|
6365
6380
|
window.removeEventListener("hashchange", again);
|
|
6366
6381
|
};
|
|
6367
6382
|
}, []);
|
|
6383
|
+
const clientProvider = React23.useMemo(
|
|
6384
|
+
() => clientDef ? resolveDataProvider(clientDef) : null,
|
|
6385
|
+
[clientDef]
|
|
6386
|
+
);
|
|
6387
|
+
const clientRecord = clientDef && clientProvider && reviewing?.clientId ? {
|
|
6388
|
+
// The house's rules (CPF required…) are what the check-in judged; the modal must agree.
|
|
6389
|
+
entityDef: { ...clientDef, fields: clientFields },
|
|
6390
|
+
load: async () => {
|
|
6391
|
+
const res = await clientProvider.list({ filters: { id: reviewing.clientId }, pageSize: 1, countMode: "none" });
|
|
6392
|
+
return res?.data?.[0] ?? null;
|
|
6393
|
+
},
|
|
6394
|
+
save: async (data) => {
|
|
6395
|
+
await clientProvider.update(reviewing.clientId, data);
|
|
6396
|
+
setClientRowVersion((n) => n + 1);
|
|
6397
|
+
}
|
|
6398
|
+
} : void 0;
|
|
6368
6399
|
const editing = panel?.kind === "edit" ? panel.booking : null;
|
|
6369
6400
|
const charging = panel?.kind === "charge" ? panel.booking : null;
|
|
6370
6401
|
const setReviewing = (b) => setPanel(b ? { kind: "review", booking: b } : null);
|
|
@@ -6395,6 +6426,7 @@ function CheckinView({ onReceive, onOpenBooking, onOpenAttendance }) {
|
|
|
6395
6426
|
label: m.label,
|
|
6396
6427
|
detail: "obrigat\xF3rio no cadastro",
|
|
6397
6428
|
blocking: true,
|
|
6429
|
+
field: clientFields.find((f) => f.key === m.key),
|
|
6398
6430
|
action: { label: "Completar cadastro", onClick: () => openEntity(b.clientId, "person", "customer") }
|
|
6399
6431
|
});
|
|
6400
6432
|
}
|
|
@@ -6792,6 +6824,7 @@ function CheckinView({ onReceive, onOpenBooking, onOpenAttendance }) {
|
|
|
6792
6824
|
setCharging(b);
|
|
6793
6825
|
} : void 0,
|
|
6794
6826
|
onConfirm: reviewing.status === "waiting" || reviewing.status === "in_progress" ? void 0 : confirmCheckin,
|
|
6827
|
+
clientRecord,
|
|
6795
6828
|
onClose: () => setReviewing(null)
|
|
6796
6829
|
}
|
|
6797
6830
|
),
|