fix exchange selection
This commit is contained in:
parent
0bfd4523b3
commit
668c0430c2
@ -36,6 +36,7 @@ export function SelectList({
|
|||||||
onChange,
|
onChange,
|
||||||
label,
|
label,
|
||||||
description,
|
description,
|
||||||
|
canBeNull,
|
||||||
}: Props): VNode {
|
}: Props): VNode {
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
@ -49,20 +50,21 @@ export function SelectList({
|
|||||||
<NiceSelect>
|
<NiceSelect>
|
||||||
<select
|
<select
|
||||||
name={name}
|
name={name}
|
||||||
|
value={value}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
console.log(e.currentTarget.value, value);
|
|
||||||
onChange(e.currentTarget.value);
|
onChange(e.currentTarget.value);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{value !== undefined ? (
|
{value === undefined ||
|
||||||
<option selected>{list[value]}</option>
|
(canBeNull && (
|
||||||
) : (
|
<option selected disabled>
|
||||||
<option selected disabled>
|
Select one option
|
||||||
Select one option
|
</option>
|
||||||
</option>
|
// ) : (
|
||||||
)}
|
// <option selected>{list[value]}</option>
|
||||||
|
))}
|
||||||
{Object.keys(list)
|
{Object.keys(list)
|
||||||
.filter((l) => l !== value)
|
// .filter((l) => l !== value)
|
||||||
.map((key) => (
|
.map((key) => (
|
||||||
<option value={key} key={key}>
|
<option value={key} key={key}>
|
||||||
{list[key]}
|
{list[key]}
|
||||||
|
@ -79,9 +79,11 @@ export function View({
|
|||||||
}: ViewProps): VNode {
|
}: ViewProps): VNode {
|
||||||
const needsReview = terms.status === "changed" || terms.status === "new";
|
const needsReview = terms.status === "changed" || terms.status === "new";
|
||||||
|
|
||||||
const [switchingExchange, setSwitchingExchange] = useState<
|
const [switchingExchange, setSwitchingExchange] = useState(false);
|
||||||
string | undefined
|
const [nextExchange, setNextExchange] = useState<string | undefined>(
|
||||||
>(undefined);
|
undefined,
|
||||||
|
);
|
||||||
|
|
||||||
const exchanges = knownExchanges.reduce(
|
const exchanges = knownExchanges.reduce(
|
||||||
(prev, ex) => ({ ...prev, [ex.exchangeBaseUrl]: ex.exchangeBaseUrl }),
|
(prev, ex) => ({ ...prev, [ex.exchangeBaseUrl]: ex.exchangeBaseUrl }),
|
||||||
{},
|
{},
|
||||||
@ -117,25 +119,33 @@ export function View({
|
|||||||
</section>
|
</section>
|
||||||
{!reviewing && (
|
{!reviewing && (
|
||||||
<section>
|
<section>
|
||||||
{switchingExchange !== undefined ? (
|
{switchingExchange ? (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<div>
|
<div>
|
||||||
<SelectList
|
<SelectList
|
||||||
label="Known exchanges"
|
label="Known exchanges"
|
||||||
list={exchanges}
|
list={exchanges}
|
||||||
name=""
|
value={nextExchange}
|
||||||
onChange={onSwitchExchange}
|
name="switchingExchange"
|
||||||
|
onChange={setNextExchange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<LinkSuccess
|
<LinkSuccess
|
||||||
upperCased
|
upperCased
|
||||||
onClick={() => onSwitchExchange(switchingExchange)}
|
onClick={() => {
|
||||||
|
if (nextExchange !== undefined) {
|
||||||
|
onSwitchExchange(nextExchange);
|
||||||
|
}
|
||||||
|
setSwitchingExchange(false);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{i18n.str`Confirm exchange selection`}
|
{nextExchange === undefined
|
||||||
|
? i18n.str`Cancel exchange selection`
|
||||||
|
: i18n.str`Confirm exchange selection`}
|
||||||
</LinkSuccess>
|
</LinkSuccess>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
) : (
|
) : (
|
||||||
<LinkSuccess upperCased onClick={() => setSwitchingExchange("")}>
|
<LinkSuccess upperCased onClick={() => setSwitchingExchange(true)}>
|
||||||
{i18n.str`Switch exchange`}
|
{i18n.str`Switch exchange`}
|
||||||
</LinkSuccess>
|
</LinkSuccess>
|
||||||
)}
|
)}
|
||||||
|
Loading…
Reference in New Issue
Block a user