-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from mrowe009/admin-overhaul
Admin overhaul
- Loading branch information
Showing
54 changed files
with
348 additions
and
114 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
### TODO: | ||
- (Feature): Better manage Group Feature | ||
- (Feature): Enhance toolbar to scroll away animate | ||
- (Feature): Edit transactions - long hold | ||
- (Feature): update splash screen | ||
- (Feature): Edit transactions - long hold |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-553 Bytes
(80%)
android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-107 Bytes
(97%)
android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-200 Bytes
(87%)
android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+11 Bytes
(100%)
android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.25 KB
(71%)
android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-173 Bytes
(97%)
android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3.68 KB
(58%)
android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-747 Bytes
(91%)
android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-7.38 KB
(51%)
android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.48 KB
(88%)
android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Diff not rendered.
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
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.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,37 @@ | ||
import React, { useCallback, useState, useMemo, Fragment } from 'react' | ||
import PropTypes from 'prop-types' | ||
import { IonContent, IonText, useIonViewWillEnter } from '@ionic/react' | ||
import { useQuery, useMutation } from '@apollo/react-hooks' | ||
import useMountedState from 'react-use/lib/useMountedState' | ||
import get from 'lodash/fp/get' | ||
import map from 'lodash/fp/map' | ||
import concat from 'lodash/fp/concat' | ||
import reject from 'lodash/fp/reject' | ||
import groupBy from 'lodash/fp/groupBy' | ||
import includes from 'lodash/fp/includes' | ||
import React, { useCallback, useState } from 'react' | ||
import { IonToolbar, IonSegment, IonSegmentButton, IonLabel } from '@ionic/react' | ||
|
||
import { useAdminViewStyles } from '../util' | ||
import { GroupTransactions, PayTransactions } from '../admin.gql' | ||
import { Button } from 'elements' | ||
import { Toolbar, TransactionEntry, FullPageLoader, PullToRefresh } from 'components' | ||
import routes from 'routes' | ||
import PayTransaction from './PayTab' | ||
import Users from './UsersTab' | ||
import { Toolbar } from 'components' | ||
|
||
const Admin = ({ history }) => { | ||
const isMounted = useMountedState() | ||
const classes = useAdminViewStyles() | ||
const [transactionIds, handleIds] = useState([]) | ||
const [payTransaction, { loading: ptLoading }] = useMutation(PayTransactions, { | ||
variables: { transactionIds }, | ||
awaitRefetchQueries: true, | ||
refetchQueries: ['UserTransactions'], | ||
onCompleted: () => history.push(routes.home) | ||
}) | ||
const { data, loading, refetch } = useQuery(GroupTransactions) | ||
const checkboxClick = useCallback( | ||
id => e => handleIds(_ids => (e.target.checked ? concat(_ids)(id) : reject(_id => _id === id)(_ids))), | ||
[] | ||
) | ||
const onRefresh = useCallback(e => refetch().then(e.detail.complete), [refetch]) | ||
const transactions = useMemo(() => groupBy('owner')(get('admin.groupTransactions')(data)), [data]) | ||
|
||
useIonViewWillEnter(() => { | ||
if (isMounted()) { | ||
handleIds([]) | ||
refetch() | ||
} | ||
}) | ||
|
||
if (loading) { | ||
return <FullPageLoader /> | ||
} | ||
const Admin = () => { | ||
const [activeTab, changeTab] = useState('pay') | ||
const handleTabChange = useCallback(e => changeTab(e.target.value), []) | ||
|
||
return ( | ||
<> | ||
<Toolbar color="medium" title="Pay Transactions" /> | ||
<IonContent color="dark"> | ||
<PullToRefresh onRefresh={onRefresh} /> | ||
<div className={classes.wrapper}> | ||
<div className={classes.transactions}> | ||
{Object.keys(transactions).map(email => ( | ||
<Fragment key={email}> | ||
<IonText color="textSecondary"> | ||
<h5 className={classes.headers}>{email}</h5> | ||
</IonText> | ||
{map(t => ( | ||
<TransactionEntry | ||
key={t.id} | ||
onCheckboxClick={checkboxClick} | ||
checked={includes(t.id)(transactionIds)} | ||
{...t} | ||
/> | ||
))(transactions[email])} | ||
</Fragment> | ||
))} | ||
</div> | ||
<Button | ||
type="button" | ||
className={classes.button} | ||
disabled={ptLoading || !transactionIds.length} | ||
loading={ptLoading} | ||
onClick={payTransaction} | ||
> | ||
Pay | ||
</Button> | ||
</div> | ||
</IonContent> | ||
<Toolbar | ||
color="medium" | ||
title="Admin" | ||
extraToolbar={( | ||
<IonToolbar color="medium"> | ||
<IonSegment onIonChange={handleTabChange} value={activeTab}> | ||
<IonSegmentButton value="pay"> | ||
<IonLabel>Pay</IonLabel> | ||
</IonSegmentButton> | ||
|
||
<IonSegmentButton value="users"> | ||
<IonLabel>Users</IonLabel> | ||
</IonSegmentButton> | ||
</IonSegment> | ||
</IonToolbar> | ||
)} | ||
/> | ||
{activeTab === 'pay' && <PayTransaction />} | ||
{activeTab === 'users' && <Users />} | ||
</> | ||
) | ||
} | ||
|
||
Admin.propTypes = { | ||
history: PropTypes.object | ||
} | ||
|
||
export default Admin |
Oops, something went wrong.