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

  const returnActionOptions = orderStaticData?.order_product_return_action?.map(
    (option: any) => ({
      label: option?.value,
      value: option?.value,
    })
  );

  const onSelect = (selectedValue: any) => {
    setCancelOrderProducts((prev: CancelOrderProductsType[]) =>
      prev?.map((item: any) => ({
        ...item,
        action: 'return',
        return_action: selectedValue,
      }))
    );
  };

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

export default ReturnAction;
