{ claim.overdue && (
{ sprintf(
/* translators: %d: target days set by the shop */ __(
'Open for longer than your target of %d days. The law asks for a remedy within a reasonable time.',
'abcreate-warranty-desk'
),
claim.target_days
) }
) }
{ claim.defect }
{ claim.state === 'needs_review' && (
{ __( 'Why it is in review', 'abcreate-warranty-desk' ) }
{ claim.review_reasons.map( ( reason ) => (
{ reviewReasonLabel( reason ) }
) ) }
) }
{ __( 'Units and dates', 'abcreate-warranty-desk' ) }
{ __( 'Close with a WooCommerce refund', 'abcreate-warranty-desk' ) }
{ __(
'Make the refund in WooCommerce first (order screen, Refund button), then come back: the claim keeps only its number.',
'abcreate-warranty-desk'
) }
) : (
{ __(
'Price reduction or termination of the contract (art. 135-bis c. 4 and 5). The money moves only through the WooCommerce refund.',
'abcreate-warranty-desk'
) }
}
submitLabel={ __( 'Close the claim', 'abcreate-warranty-desk' ) }
secondary
fields={ [
{
name: 'outcome',
label: __( 'Outcome', 'abcreate-warranty-desk' ),
type: 'select',
options: [
{
value: 'price_reduced',
label: outcomeLabel( 'price_reduced' ),
},
{
value: 'terminated',
label: outcomeLabel( 'terminated' ),
},
],
},
{
name: 'refund_id',
label: __( 'Refund', 'abcreate-warranty-desk' ),
type: 'select',
options: refundOptions,
},
...( someOtherLine
? [
{
name: 'confirm_other_line',
label: __(
'If the refund is for another line: I checked it is the right one',
'abcreate-warranty-desk'
),
type: 'checkbox' as const,
},
]
: [] ),
{
name: 'defect_not_minor',
label: __(
'The defect is not minor (needed for a termination)',
'abcreate-warranty-desk'
),
type: 'checkbox',
},
{
name: 'date',
label: __( 'Date', 'abcreate-warranty-desk' ),
type: 'date',
required: true,
},
{
name: 'reason',
label: __( 'Reason', 'abcreate-warranty-desk' ),
type: 'text',
required: true,
},
] }
/>
);
const withoutRemedy = ( outcomes: Field[ 'options' ] ) => (
{ __(
'"Out of warranty" needs a confirmed delivery and a defect that appeared after the end of the guarantee (record the day above). A late report alone is not enough. Prescription never closes a claim on its own.',
'abcreate-warranty-desk'
) }
}
submitLabel={ __( 'Close the claim', 'abcreate-warranty-desk' ) }
secondary
fields={ [
{
name: 'outcome',
label: __( 'Outcome', 'abcreate-warranty-desk' ),
type: 'select',
options: outcomes,
help: __(
'"Request withdrawn" means the customer dropped this guarantee request. It is not the 14-day right of withdrawal from the purchase: handle that as a return in WooCommerce.',
'abcreate-warranty-desk'
),
},
{
name: 'date',
label: __( 'Date', 'abcreate-warranty-desk' ),
type: 'date',
required: true,
},
{
name: 'reason',
label: __(
'Reason given to the customer',
'abcreate-warranty-desk'
),
type: 'textarea',
required: true,
},
] }
/>
);
if ( claim.state === 'needs_review' ) {
const settledByRefund =
claim.outcome === null &&
claim.review_reasons.length > 0 &&
claim.review_reasons.every( ( r ) => REFUND_REASONS.includes( r ) );
return (
{ __( 'Next step', 'abcreate-warranty-desk' ) }
{ __(
'Fix what the reasons above say (on the units, or in WooCommerce), then reconcile.',
'abcreate-warranty-desk'
) }
}
extra={ { seen_facts: claim.order_now?.token ?? '' } }
submitLabel={ __( 'Back to work', 'abcreate-warranty-desk' ) }
fields={ [
...( claim.review_reasons.includes( '@order_refunded' )
? [
{
name: 'goods_kept',
label: __(
'The refund left the goods with the customer (a discount): the units are still there',
'abcreate-warranty-desk'
),
type: 'checkbox' as const,
},
]
: [] ),
{
name: 'reason',
label: __( 'What you checked', 'abcreate-warranty-desk' ),
type: 'text',
required: true,
},
] }
/>
{ claim.review_reasons.length === 1 &&
claim.review_reasons[ 0 ] === '@informativa_uncertain' && (
) }
{ settledByRefund && (
<>
{ refundForm }
{ withoutRemedy( [
{
value: 'withdrawn',
label: outcomeLabel( 'withdrawn' ),
},
] ) }
>
) }
{ claim.loaner_out && (
) }
{ claim.outcome !== 'terminated' && (
{ __(
'The claim goes to review and the units are held again. A repaired unit gets no second extension.',
'abcreate-warranty-desk'
) }
}
submitLabel={ __(
'Reopen for the defect',
'abcreate-warranty-desk'
) }
secondary
fields={ [
{
name: 'reason',
label: __(
'What the customer reported',
'abcreate-warranty-desk'
),
type: 'text',
required: true,
},
] }
/>
) }
{ __(
'A repair or a termination recorded by mistake is revoked with a compensating event; the history keeps both.',
'abcreate-warranty-desk'
) }
}
submitLabel={ __( 'Reopen', 'abcreate-warranty-desk' ) }
secondary
fields={ [
{
name: 'reason',
label: __( 'What was wrong', 'abcreate-warranty-desk' ),
type: 'text',
required: true,
},
] }
/>
);
}
// Open claim: the steps of art. 135-bis and 135-ter, in order.
const informed = claim.informed_on !== null;
return (
{ __( 'Next steps', 'abcreate-warranty-desk' ) }
{ claim.informativa_required
? __( '1. Inform the consumer', 'abcreate-warranty-desk' )
: __(
'1. Informativa (not required for this contract)',
'abcreate-warranty-desk'
) }
{ ! claim.informativa_required && (
{ __(
'Not required for this claim: the contract is older than 31 July 2026, the buyer is not a consumer, or the defect appeared after the guarantee. A repair brings no extension.',
'abcreate-warranty-desk'
) }
) }
{ informed && (
{ sprintf(
/* translators: 1: date, 2: channel (email, phone…), 3: version of the text */
__(
'Informed on %1$s (%2$s, text %3$s).',
'abcreate-warranty-desk'
),
formatDate( claim.informed_on ),
channelLabel( claim.informed_via ),
claim.informativa_version ?? ''
) }
{ claim.informed_via === 'email' &&
` ${ __(
'The email was accepted by the mail system; delivery cannot be confirmed.',
'abcreate-warranty-desk'
) }` }
) }
{ claim.informativa_required && ! informed && (
<>
{ sprintf(
/* translators: %s: email address */ __(
'Preview of the email to %s',
'abcreate-warranty-desk'
),
claim.informativa.to ||
__(
'(no email on the order)',
'abcreate-warranty-desk'
)
) }
{ claim.informativa.subject }
{ __(
'The guarantee of the units is extended by 12 months, once, if the buyer is a consumer and the defect appeared within the guarantee.',
'abcreate-warranty-desk'
) }
) : null
}
submitLabel={ __( 'Record repair', 'abcreate-warranty-desk' ) }
fields={ [
{
name: 'date',
label: __( 'Date', 'abcreate-warranty-desk' ),
type: 'date',
required: true,
},
{
name: 'reason',
label: __( 'What was done', 'abcreate-warranty-desk' ),
type: 'text',
},
] }
/>
) }
{ claim.choice === 'replacement' && (
{ __(
'A replacement brings no 12-month extension. Whether the guarantee starts again for the new good is not settled by the law: the plugin does not decide it. If you grant a new end, write it below; leave it empty to keep the current end.',
'abcreate-warranty-desk'
) }
}
submitLabel={ __(
'Record replacement',
'abcreate-warranty-desk'
) }
fields={ [
{
name: 'date',
label: __( 'Date', 'abcreate-warranty-desk' ),
type: 'date',
required: true,
},
...( claim.refurbished_requested
? [
{
name: 'refurbished',
label: __(
'The replacement is refurbished',
'abcreate-warranty-desk'
),
type: 'checkbox' as const,
},
]
: [] ),
{
name: 'new_end',
label: __(
'New end of the guarantee (optional)',
'abcreate-warranty-desk'
),
type: 'date',
allowFuture: true,
help: __(
'Your decision, for the replaced units.',
'abcreate-warranty-desk'
),
},
{
name: 'reason',
label: __( 'Note', 'abcreate-warranty-desk' ),
type: 'text',
},
] }
/>
) }
{ more && (
<>
{ ! claim.remedy_refused && (
{ __(
'Only when both are impossible or disproportionately expensive (art. 135-bis c. 3). The consumer can then have a price reduction or terminate the contract.',
'abcreate-warranty-desk'
) }
}
submitLabel={ __(
'Record refusal',
'abcreate-warranty-desk'
) }
secondary
fields={ [
{
name: 'reason',
label: __(
'Written reason',
'abcreate-warranty-desk'
),
type: 'textarea',
required: true,
},
] }
/>
) }
{ refundForm }
{ withoutRemedy( [
{
value: 'rejected_not_covered',
label: outcomeLabel( 'rejected_not_covered' ),
},
{
value: 'rejected_out_of_warranty',
label: outcomeLabel(
'rejected_out_of_warranty'
),
},
{
value: 'rejected_not_consumer',
label: outcomeLabel( 'rejected_not_consumer' ),
},
{
value: 'withdrawn',
label: outcomeLabel( 'withdrawn' ),
},
] ) }
>
) }
{ claim.manifested_on
? sprintf(
/* translators: %s: date the defect appeared */ __(
'The defect appeared on %s.',
'abcreate-warranty-desk'
),
formatDate( claim.manifested_on )
)
: __(
'When the defect appeared: not recorded.',
'abcreate-warranty-desk'
) }
{ ' ' }
{ canEdit && ! editing && ! needed && (
) }
{ canEdit && ( editing || needed ) && (
{ __(
'As the customer declares it. It can be before the report, never after. It decides "out of warranty" and the extension.',
'abcreate-warranty-desk'
) }
}
submitLabel={ __( 'Save', 'abcreate-warranty-desk' ) }
secondary={ ! needed }
fields={ [
{
name: 'date',
label: __( 'Appeared on', 'abcreate-warranty-desk' ),
type: 'date',
required: true,
initial: claim.manifested_on ?? '',
},
{
name: 'reason',
label: __(
'Source (what the customer said, when)',
'abcreate-warranty-desk'
),
type: 'text',
required: true,
},
] }
onDone={ ( result ) => {
setEditing( false );
onUpdated( result as Claim );
} }
onStale={ onReload }
/>
) }
);
}
/**
* The order as WooCommerce has it now: reconciling accepts exactly this.
* @param root0
* @param root0.claim
*/
function OrderNow( { claim }: { claim: Claim } ) {
const now = claim.order_now;
if ( ! now ) {
return null;
}
let line: string = sprintf(
/* translators: 1: product name, 2: quantity */
__( '%1$s × %2$d', 'abcreate-warranty-desk' ),
now.product,
now.quantity
);
if ( now.order_deleted ) {
line = __( 'order deleted', 'abcreate-warranty-desk' );
} else if ( now.line_removed ) {
line = __( 'line removed from the order', 'abcreate-warranty-desk' );
}
return (
{ sprintf(
/* translators: 1: order status, 2: product and quantity of the line */
__(
'WooCommerce now: %1$s, %2$s. Reconciling accepts the order as shown here; if it changes meanwhile you will be asked to check again.',
'abcreate-warranty-desk'
),
now.status || '-',
line
) }