import { Label, TextArea } from '@bjsdistribution/dms-component-library';
import React from 'react';
import styled from 'styled-components';
import { useOrderDetails } from '../../../store';

function OrderStatusNote() {
  const [orderDetails, setOrderDetails] = useOrderDetails();

  const onChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
    setOrderDetails(prev => {
      return {
        ...prev,
        order_status_note: e.target.value,
      };
    });
  };

  return (
    <Container>
      <Label label="Order Status Note" />
      <CustomTextArea
        value={orderDetails?.order_status_note || ''}
        placeholder='add order status note'
        onChange={onChange}
      />
    </Container>
  );
}

const CustomTextArea = styled(TextArea)`
  flex: 1;
  resize: none;
`;

const Container = styled.div`
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
`;

export default OrderStatusNote;
