export const requestReturnSchema = {
  body: {
    type: 'object',
    required: ['order_id', 'order_product_id', 'returned_quantity', 'returned_weight', 'reason', 'target_stage_id', 'returned_date'],
    properties: {
      order_id: { type: 'string' },
      order_product_id: { type: 'string' },
      returned_quantity: { type: 'integer', minimum: 1 },
      returned_weight: { type: 'number', exclusiveMinimum: 0 },
      reason: { type: 'string', minLength: 1 },
      target_stage_id: { type: 'string' },
      returned_date: { type: 'string', format: 'date-time' },
      next_delivery_date: { type: 'string', format: 'date', nullable: true },
    },
  },
};

// Same editable fields as requestReturnSchema, minus order_id/order_product_id
// — updateRequest() never changes which line a return targets, only the
// details captured at request time.
export const updateReturnSchema = {
  body: {
    type: 'object',
    required: ['returned_quantity', 'returned_weight', 'reason', 'target_stage_id', 'returned_date'],
    properties: {
      returned_quantity: { type: 'integer', minimum: 1 },
      returned_weight: { type: 'number', exclusiveMinimum: 0 },
      reason: { type: 'string', minLength: 1 },
      target_stage_id: { type: 'string' },
      returned_date: { type: 'string', format: 'date-time' },
      next_delivery_date: { type: 'string', format: 'date', nullable: true },
    },
  },
};

export const rejectReturnSchema = {
  body: {
    type: 'object',
    required: ['reason'],
    properties: {
      reason: { type: 'string', minLength: 1 },
    },
  },
};
