Skip to content

Commit

Permalink
Filter operators already registered in form
Browse files Browse the repository at this point in the history
  • Loading branch information
ccali11 committed Aug 9, 2023
1 parent d93728d commit 66e9392
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions apps/web/src/pages/operators/Operator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const onSelectOperatorIDBlur = () => {
}, 200)
}
// @chris need a way to find out possible operators on selecting a wallet address
const possibleOperatorID = ref([] as string[])
const availableOperatorIDs = ref([] as string[])
const selectedPublicNodeURL = ref()
const selectedCollateral = ref()
Expand Down Expand Up @@ -88,12 +88,14 @@ watch(selectedWallet, () =>{
selectedOperatorID.value = ''
selectedPublicNodeURL.value = ''
selectedCollateral.value = ''
if (selectedWallet.value.address === '') {
possibleOperatorID.value = []
availableOperatorIDs.value = []
} else {
possibleOperatorID.value = operators.value.filter((operator: any) => {
return operator.ownerAddress === selectedWallet.value.address && !registeredOperators.value.includes(operator.id)
availableOperatorIDs.value = operators.value.filter((operator: any) => {
const sameAddress = operator.ownerAddress === selectedWallet.value.address
const idRegistered = registeredOperators.value.find((registeredOperator: any) => registeredOperator.id === operator.id)
return sameAddress && !idRegistered
}).map((operator: any) => operator.id)
}
})
Expand Down Expand Up @@ -195,7 +197,7 @@ async function submitRegisterOperatorForm() {
selectedOperatorID.value = ''
selectedPublicNodeURL.value = ''
selectedCollateral.value = ''
possibleOperatorID.value = []
availableOperatorIDs.value = []
openAddOperatorModal.value = false
}
Expand Down Expand Up @@ -341,14 +343,14 @@ async function submitRegisterOperatorForm() {
Avaliable Operators
</h6>
<div
v-if="possibleOperatorID.length === 0"
v-if="availableOperatorIDs.length === 0"
class="border-y border-y-grey_1
text-grey_4 my-[10px] text-center truncate"
>
No Operators Found
</div>
<button
v-for="operator in possibleOperatorID"
v-for="operator in availableOperatorIDs"
v-else
:key="operator"
type="button"
Expand Down

0 comments on commit 66e9392

Please sign in to comment.