import { useCancelOrderProducts, useOrderStaticData } from '../../../store';
import { CancelOrderProductsType } from '../../../types';
import OrderActionsDropdown from '../../Dropdown';
import React from 'react';
function ReturnReason() {
  const [orderStaticData] = useOrderStaticData();
  const [, setCancelOrderProducts] = useCancelOrderProducts();

  const returnReasonsOptions = orderStaticData?.return_reasons?.map(
    (option: any) => ({
      label: option?.reason,
      value: option?.reason,
    })
  );
  const onSelect = (selectedValue: any) => {
    setCancelOrderProducts((prev: CancelOrderProductsType[]) =>
      prev?.map((item: any) => ({
        ...item,
        action: 'return',
        return_reason: selectedValue,
      }))
    );
  };
  // const onSearch = () => {};

  return (
    <OrderActionsDropdown
      label="Return Reason"
      placeholder="Select Return Reason"
      options={returnReasonsOptions}
      onSelect={onSelect}
      // onSearch={onSearch}
    />
  );
}

export default ReturnReason;
