mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-27 06:13:06 +00:00
OH14 — remove orphaned transitionDemandFormAction after outbox-only path
Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
This commit is contained in:
parent
9b56b641a6
commit
36f85e96d9
1 changed files with 0 additions and 34 deletions
|
|
@ -5,21 +5,14 @@ import { revalidatePath } from 'next/cache'
|
||||||
import {
|
import {
|
||||||
attachCampaignDemandReceiptRecord,
|
attachCampaignDemandReceiptRecord,
|
||||||
setCampaignDemandCost,
|
setCampaignDemandCost,
|
||||||
transitionCampaignDemand,
|
|
||||||
} from '@/app/(campaign)/campanha/actions/demand'
|
} from '@/app/(campaign)/campanha/actions/demand'
|
||||||
import {
|
import {
|
||||||
FormDataBoundaryError,
|
FormDataBoundaryError,
|
||||||
nullableFormText,
|
|
||||||
requiredFormText,
|
|
||||||
requiredRelationshipFormValue,
|
requiredRelationshipFormValue,
|
||||||
} from '@/lib/formData'
|
} from '@/lib/formData'
|
||||||
import {
|
import {
|
||||||
CAMPAIGN_DEMAND_COST_STAFF_MESSAGE,
|
CAMPAIGN_DEMAND_COST_STAFF_MESSAGE,
|
||||||
CAMPAIGN_DEMAND_INVALID_STATUS_MESSAGE,
|
|
||||||
CAMPAIGN_DEMAND_RECEIPT_SAFE_MESSAGES,
|
CAMPAIGN_DEMAND_RECEIPT_SAFE_MESSAGES,
|
||||||
CAMPAIGN_DEMAND_TRANSITION_SAFE_MESSAGES,
|
|
||||||
campaignDemandStatuses,
|
|
||||||
type CampaignDemandStatus,
|
|
||||||
} from '@/lib/schemas/campaignDemand'
|
} from '@/lib/schemas/campaignDemand'
|
||||||
import { getCampaignActionContext } from '@/utilities/campaignActionContext'
|
import { getCampaignActionContext } from '@/utilities/campaignActionContext'
|
||||||
import {
|
import {
|
||||||
|
|
@ -27,33 +20,6 @@ import {
|
||||||
type CampaignFormActionState,
|
type CampaignFormActionState,
|
||||||
} from '@/utilities/campaignFormActionError'
|
} from '@/utilities/campaignFormActionError'
|
||||||
|
|
||||||
const INVALID_STATUS_MESSAGE = CAMPAIGN_DEMAND_INVALID_STATUS_MESSAGE
|
|
||||||
|
|
||||||
const transitionSafeMessages = CAMPAIGN_DEMAND_TRANSITION_SAFE_MESSAGES
|
|
||||||
|
|
||||||
export const transitionDemandFormAction = async (
|
|
||||||
_state: CampaignFormActionState,
|
|
||||||
formData: FormData,
|
|
||||||
): Promise<CampaignFormActionState> =>
|
|
||||||
runCampaignFormAction({
|
|
||||||
execute: async () => {
|
|
||||||
const rawStatus = requiredFormText(formData, 'status')
|
|
||||||
if (!campaignDemandStatuses.includes(rawStatus as CampaignDemandStatus)) {
|
|
||||||
throw new Error(INVALID_STATUS_MESSAGE)
|
|
||||||
}
|
|
||||||
|
|
||||||
await transitionCampaignDemand({
|
|
||||||
id: requiredRelationshipFormValue(formData, 'demandId'),
|
|
||||||
status: rawStatus as CampaignDemandStatus,
|
|
||||||
decisionNote: nullableFormText(formData, 'decisionNote'),
|
|
||||||
})
|
|
||||||
revalidatePath('/campanha/demandas/[slug]', 'page')
|
|
||||||
return { message: 'Demanda atualizada.' }
|
|
||||||
},
|
|
||||||
safeMessages: transitionSafeMessages,
|
|
||||||
genericMessage: 'Não foi possível mover a demanda. Verifique seu acesso e tente novamente.',
|
|
||||||
})
|
|
||||||
|
|
||||||
export const setDemandCostFormAction = async (
|
export const setDemandCostFormAction = async (
|
||||||
_state: CampaignFormActionState,
|
_state: CampaignFormActionState,
|
||||||
formData: FormData,
|
formData: FormData,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue