components#SdnInputForm TypeScript Examples

The following examples show how to use components#SdnInputForm. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EnterReceiptPage.tsx    From solo with MIT License 5 votes vote down vote up
EnterReceiptPage: React.FC = () => {
  const {
    docs,
    addSdn,
    submitAllLoadingStatus,
    submitAll,
    modifyDocument,
    removeDocument
  } = useEnterReceiptDocuments();

  const columns = useMemo(() => createColumns(modifyDocument, removeDocument), [
    modifyDocument,
    removeDocument
  ]);

  const [duplicateSdn, setDuplicateSdn] = useState(false);
  const onAddSdn = (sdn: string) => {
    setDuplicateSdn(false);
    const isDuplicate = docs.some(doc => doc.sdn === sdn);
    if (isDuplicate) {
      setDuplicateSdn(true);
    } else if (sdn !== "") {
      addSdn(sdn);
    }
  };

  return (
    <div className="tablet:margin-x-8 overflow-x-auto">
      <Title>Enter Receipt</Title>
      <EnterReceiptStatusIndicator {...submitAllLoadingStatus} />
      <Table<Document>
        columns={columns}
        data={docs}
        manualPagination={false}
        manualSortBy={false}
      />
      <DuplicateSdnIndicator isDuplicate={duplicateSdn} />
      <div className="grid-row flex-align-start flex-justify margin-bottom-1em">
        <SdnInputForm
          onSubmit={onAddSdn}
          disabled={submitAllLoadingStatus.loading}
        />
        <Button
          onClick={submitAll}
          className="margin-top-1"
          disabled={submitAllLoadingStatus.loading || docs.length < 1}
        >
          Submit All
        </Button>
      </div>
    </div>
  );
}