diff --git a/src/components/campaign/activity/ActivityForm.tsx b/src/components/campaign/activity/ActivityForm.tsx index bae58c56..d69e1d10 100644 --- a/src/components/campaign/activity/ActivityForm.tsx +++ b/src/components/campaign/activity/ActivityForm.tsx @@ -90,6 +90,8 @@ export type ActivityFormFieldsProps = { submittedTitle?: string searchContacts: (query: string) => Promise searchLeaderships: (query: string) => Promise + /** When true (hybrid/offline edit), hide tasks/demands — outbox cannot persist them. */ + deferOfflineUnsupportedFields?: boolean } const editableStatuses = ['rascunho', 'planejado'] as const @@ -104,6 +106,7 @@ const ActivityFormFields = ({ submittedTitle, searchContacts, searchLeaderships, + deferOfflineUnsupportedFields = false, }: ActivityFormFieldsProps) => { const errorFor = (name: string) => fieldError(fieldErrors, name) const statusIsEditable = @@ -457,27 +460,39 @@ const ActivityFormFields = ({ - - - Tarefas - - - - - + {deferOfflineUnsupportedFields ? ( + + Tarefas e demandas + + Edição offline grava só os campos principais. Para alterar tarefas ou criar demandas, + use a atividade com conexão. + + + ) : ( + <> + + + Tarefas + + + + + - - - Demandas - - - - - + + + Demandas + + + + + + + )} ) } @@ -580,12 +595,12 @@ export const ActivityForm = ({ const responsible = typeof responsibleRaw === 'string' && Number.isInteger(Number(responsibleRaw)) ? Number(responsibleRaw) - : undefined + : null const leadershipRaw = data.get('leadership') const leadershipId = typeof leadershipRaw === 'string' && Number.isInteger(Number(leadershipRaw)) ? Number(leadershipRaw) - : undefined + : null const startAtRaw = readOptionalFormText(data, 'startAt') const endAtRaw = readOptionalFormText(data, 'endAt') const deadlineRaw = readOptionalFormText(data, 'deadline') @@ -611,16 +626,14 @@ export const ActivityForm = ({ startAt, endAt, deadline, - ...(responsible !== undefined ? { responsible } : {}), - ...(leadershipId !== undefined ? { leadership: leadershipId } : {}), + responsible, + leadership: leadershipId, }, baseUpdatedAt: mirrorUpdatedAt ?? activity.updatedAt, }).then( () => { setHybridPending(false) - setHybridMessage( - 'Alterações enfileiradas (campos principais). Tarefas e novas demandas exigem conexão.', - ) + setHybridMessage('Alterações enfileiradas.') }, (error: unknown) => { setHybridPending(false) @@ -672,6 +685,7 @@ export const ActivityForm = ({ submittedTitle={state.submittedTitle} searchContacts={searchContacts} searchLeaderships={searchLeaderships} + deferOfflineUnsupportedFields={hybridUpdate} />