-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cms] feat: change proposaltoken to proposalname on invoice lineitem
This diff now allows users to select proposals by its name, instead of its token. Since getting proposals names require a batching request, and those requests are bounded by 20 proposals for each request, those requests have to be done more than once in case the token from the invoice (details and diff), or the proposal (new and edit actions) are not on the dropdown list.
- Loading branch information
1 parent
990dcb6
commit a689f16
Showing
20 changed files
with
293 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/components/InvoiceDatasheet/components/LazySelector.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React, { useState, useCallback, useMemo } from "react"; | ||
import { Select } from "pi-ui"; | ||
|
||
const fetchingOption = { | ||
isFetchingOption: true, | ||
label: "Fetch more...", | ||
value: "" | ||
}; | ||
|
||
const LazySelector = ({ options, onFetch, needsFetch, onChange, onCommit }) => { | ||
const [selected, setSelected] = useState(); | ||
const getValueObj = useCallback( | ||
(value) => options.find((op) => op.value === value), | ||
[options] | ||
); | ||
|
||
const handleChange = useCallback( | ||
({ isFetchingOption = false, value }) => { | ||
if (isFetchingOption) { | ||
onFetch(); | ||
} else { | ||
setSelected(getValueObj(value)); | ||
onChange(value); | ||
onCommit(value); | ||
} | ||
}, | ||
[onFetch, setSelected, onChange, onCommit, getValueObj] | ||
); | ||
|
||
const ops = useMemo( | ||
() => (needsFetch ? [...options, fetchingOption] : options), | ||
[options, needsFetch] | ||
); | ||
return <Select options={ops} value={selected} onChange={handleChange} />; | ||
}; | ||
|
||
export default LazySelector; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.