Skip to content

Commit

Permalink
feat(webapp): update new affiliate table
Browse files Browse the repository at this point in the history
  • Loading branch information
leisterfrancisco committed Jan 19, 2022
1 parent f73feda commit 25e534a
Showing 1 changed file with 45 additions and 34 deletions.
79 changes: 45 additions & 34 deletions webapp/src/routes/Admin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,11 @@ const Admin = () => {
}
})

await loadNewUsers({
variables: {
offset: newUsersPagination.page * newUsersPagination.rowsPerPage,
limit: newUsersPagination.rowsPerPage,
where: {
state: { _eq: affiliateUtil.JOIN_REQUEST_STATUS.pending }
}
await loadJoinRequestUsers({
offset: newUsersPagination.page * newUsersPagination.rowsPerPage,
limit: newUsersPagination.rowsPerPage,
where: {
state: { _eq: affiliateUtil.JOIN_REQUEST_STATUS.pending }
}
})

Expand All @@ -369,6 +367,7 @@ const Admin = () => {
setOpenInfoModal(false)
setSelected({ tableName: null })
setUserAccounts([])
reloadJoinRequestUsers()
} catch (error) {
showMessage({ type: 'error', content: error })
}
Expand Down Expand Up @@ -412,6 +411,7 @@ const Admin = () => {
})

reloadUsers()
reloadJoinRequestUsers()
} catch (error) {
showMessage({ type: 'error', content: getUALError(error) })
}
Expand All @@ -426,6 +426,12 @@ const Admin = () => {
setTimeout(handleOnLoadMoreUsers, 1500)
}

const reloadJoinRequestUsers = async () => {
setFetchingData(true)
setNewUsersPagination(initNewUsersPagination)
setTimeout(loadJoinRequestUsers, 1500)
}

const handleOnSelectItem = (tableName, items, accounts) => {
if (!items.length) {
setSelected({ tableName: null })
Expand All @@ -443,13 +449,11 @@ const Admin = () => {
page
}))

await loadNewUsers({
variables: {
offset: page * newUsersPagination.rowsPerPage,
limit: newUsersPagination.rowsPerPage,
where: {
state: { _eq: affiliateUtil.JOIN_REQUEST_STATUS.pending }
}
await loadJoinRequestUsers({
offset: page * newUsersPagination.rowsPerPage,
limit: newUsersPagination.rowsPerPage,
where: {
state: { _eq: affiliateUtil.JOIN_REQUEST_STATUS.pending }
}
})
}
Expand All @@ -460,13 +464,11 @@ const Admin = () => {
rowsPerPage: e.target.value
}))

await loadNewUsers({
variables: {
offset: newUsersPagination.page * e.target.value,
limit: e.target.value,
where: {
state: { _eq: affiliateUtil.JOIN_REQUEST_STATUS.pending }
}
await loadJoinRequestUsers({
offset: newUsersPagination.page * e.target.value,
limit: e.target.value,
where: {
state: { _eq: affiliateUtil.JOIN_REQUEST_STATUS.pending }
}
})
}
Expand Down Expand Up @@ -692,6 +694,23 @@ const Admin = () => {
setRejectPayment({ isOpen: false, previousModal: null })
}

const loadJoinRequestUsers = async ({
offset = 0,
limit = 5,
where = {
state: { _eq: affiliateUtil.JOIN_REQUEST_STATUS.pending }
}
} = {}) => {
await loadNewUsers({
variables: {
offset,
limit,
where
}
})
setFetchingData(false)
}

useEffect(() => {
if (loading || !joinRequest) return

Expand Down Expand Up @@ -741,15 +760,7 @@ const Admin = () => {
useEffect(() => {
handleOnLoadMoreUsers()
handleOnLoadMoreReferrals()
loadNewUsers({
variables: {
offset: 0,
limit: 5,
where: {
state: { _eq: affiliateUtil.JOIN_REQUEST_STATUS.pending }
}
}
})
loadJoinRequestUsers()
}, [])

useEffect(() => {
Expand Down Expand Up @@ -858,6 +869,10 @@ const Admin = () => {
</Box>
<OptionFAB
type={selected.tableName}
onClickApproveNewUser={() => {
approveNewUser()
setOpenFAB(false)
}}
onClickReject={() => {
setOpenInfoModal(true)
setOpenFAB(false)
Expand All @@ -875,10 +890,6 @@ const Admin = () => {
setOpenFAB(false)
}}
allowPayment={allowPayment}
onClickApproveNewUser={() => {
approveNewUser()
setOpenFAB(false)
}}
/>
</Box>
</FloatingMenu>
Expand Down

0 comments on commit 25e534a

Please sign in to comment.