diff --git a/package.json b/package.json
index 9db54f6..8a3e4be 100644
--- a/package.json
+++ b/package.json
@@ -68,7 +68,7 @@
"react-native-elements": "^1.1.0",
"react-native-firebase": "^5.3.1",
"react-native-gesture-handler": "^1.1.0",
- "react-native-gifted-chat": "^0.7.3",
+ "react-native-gifted-chat": "^0.9.2",
"react-native-image-crop-picker": "^0.23.1",
"react-native-keyboard-aware-scrollview": "^2.0.0",
"react-native-linear-gradient": "^2.5.4",
@@ -78,6 +78,7 @@
"react-native-simple-radio-button": "^2.7.3",
"react-native-super-grid": "^3.0.4",
"react-native-vector-icons": "^6.4.2",
+ "react-native-video": "^4.4.1",
"react-navigation": "^3.8.1",
"react-navigation-fluid-transitions": "^0.3.1",
"react-navigation-props-mapper": "^1.0.1",
diff --git a/src/actions/index.js b/src/actions/index.js
index a57b474..5e630ea 100644
--- a/src/actions/index.js
+++ b/src/actions/index.js
@@ -3,17 +3,6 @@ import LoginWithAmazon from 'react-native-login-with-amazon'
import { fetchConversations, sendMessage as localSendMessage } from '../screens/Messaging/actions'
import { fetchArtisans, fetchProducts } from '../screens/ArtisanHub/actions'
-export function fetchAll(cgaID) {
- return (dispatch) => {
- return new Promise(async (resolve) => {
- let artisans = fetchArtisans(cgaID)
- let conversations = fetchConversations(cgaID)
-
- Promise.all([artisans, conversations]).then(() => resolve())
- })
- }
-}
-
export function sendMessage(sender, message, recipients) {
return localSendMessage(sender, message, recipients)
}
diff --git a/src/components/UserInput/index.js b/src/components/UserInput/index.js
index bda1bd1..a67e517 100644
--- a/src/components/UserInput/index.js
+++ b/src/components/UserInput/index.js
@@ -15,7 +15,7 @@ export default class UserInput extends Component {
)
diff --git a/src/components/Wallpaper/index.js b/src/components/Wallpaper/index.js
index 41851d2..2c5c8e3 100644
--- a/src/components/Wallpaper/index.js
+++ b/src/components/Wallpaper/index.js
@@ -1,16 +1,13 @@
import PropTypes from 'prop-types'
import React, { Component } from 'react'
import { StyleSheet } from 'react-native'
-import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scrollview'
import LinearGradient from 'react-native-linear-gradient'
export default class Wallpaper extends Component {
render() {
return (
-
-
- {this.props.children}
-
+
+ {this.props.children}
)
}
@@ -21,10 +18,6 @@ Wallpaper.propTypes = {
}
const styles = StyleSheet.create({
- container: {
- width: '100%',
- height: '100%',
- },
content: {
flex: 1,
flexDirection: 'column',
diff --git a/src/screens/ArtisanHub/AddArtisan.js b/src/screens/ArtisanHub/AddArtisan.js
index 37f8977..8bbbb71 100644
--- a/src/screens/ArtisanHub/AddArtisan.js
+++ b/src/screens/ArtisanHub/AddArtisan.js
@@ -123,72 +123,74 @@ export default class AddArtisan extends Component {
render() {
return (
-
-
- this.pickImage()}
- style={styles.image}
- />
-
-
+
+
+
+ this.pickImage()}
+ style={styles.image}
+ />
+
+
+ this.setState({ name: newText })}
+ onFocus={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, name: true } })}
+ onBlur={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, name: false } })}
+ style={styles.smallInput1}
+ />
+
+
+ this.setState({ focusedInputs: { ...this.state.focusedInputs, phoneNumber: true } })}
+ onBlur={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, phoneNumber: false } })}
+ style={styles.smallInput2}
+ keyboardType="number-pad"
+ />
+
+
+
+
+
this.setState({ name: newText })}
- onFocus={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, name: true } })}
- onBlur={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, name: false } })}
- style={styles.smallInput1}
+ iconName="map"
+ placeholder="Location"
+ value={this.state.location}
+ onChangeText={(newText) => this.setState({ location: newText })}
+ onFocus={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, location: true } })}
+ onBlur={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, location: false } })}
+ style={styles.smallInput3}
/>
-
+
this.setState({ focusedInputs: { ...this.state.focusedInputs, phoneNumber: true } })}
- onBlur={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, phoneNumber: false } })}
- style={styles.smallInput2}
- keyboardType="number-pad"
+ placeholder="Describe this artisan"
+ value={this.state.description}
+ onChangeText={(newText) => this.setState({ description: newText })}
+ onFocus={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, description: true } })}
+ onBlur={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, description: false } })}
+ style={styles.largeInputs}
+ multiline={true}
/>
+
-
-
- this.setState({ location: newText })}
- onFocus={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, location: true } })}
- onBlur={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, location: false } })}
- style={styles.smallInput3}
- />
-
-
- this.setState({ description: newText })}
- onFocus={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, description: true } })}
- onBlur={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, description: false } })}
- style={styles.largeInputs}
- multiline={true}
- />
-
-
-
)
}
@@ -196,8 +198,9 @@ export default class AddArtisan extends Component {
const styles = StyleSheet.create({
container: {
+ flex: 1,
flexDirection: 'column',
- justifyContent: 'flex-start',
+ justifyContent: 'space-between',
padding: '2%'
},
image: {
diff --git a/src/screens/ArtisanHub/ArtisanDetail.js b/src/screens/ArtisanHub/ArtisanDetail.js
index 1ab8193..e2c8990 100644
--- a/src/screens/ArtisanHub/ArtisanDetail.js
+++ b/src/screens/ArtisanHub/ArtisanDetail.js
@@ -18,6 +18,7 @@ import {
} from 'react-native'
import { withMappedNavigationParams } from 'react-navigation-props-mapper'
import { FlatGrid } from 'react-native-super-grid'
+
class ArtisanDetail extends Component {
static navigationOptions = () => {
return {
diff --git a/src/screens/ArtisanHub/ArtisanList.js b/src/screens/ArtisanHub/ArtisanList.js
index d346cca..f6c00ff 100644
--- a/src/screens/ArtisanHub/ArtisanList.js
+++ b/src/screens/ArtisanHub/ArtisanList.js
@@ -9,7 +9,8 @@ import {
TextInput,
TouchableOpacity,
View,
- Platform
+ Platform,
+ RefreshControl
} from 'react-native'
import { ProfilePicture } from '../../components'
@@ -69,7 +70,10 @@ export default class ArtisanList extends Component {
fetchArtisans() {
this.setState({ fetchingArtisans: true })
this.props.fetchArtisans(this.props.User.uid).then(() => {
- this.setState({ fetchingArtisans: false })
+ this.setState({
+ fetchingArtisans: false,
+ artisans: this.sortedArtisans()
+ })
})
}
@@ -160,6 +164,12 @@ export default class ArtisanList extends Component {
keyExtractor={this._keyExtractor}
renderItem={this._renderArtisanItem}
extraData={this.state}
+ refreshControl={
+
+ }
/>
}
@@ -199,14 +209,13 @@ const styles = StyleSheet.create({
color: '#444444',
marginLeft: 5
},
-
input: {
- margin: 15,
- height: 40,
- padding: 10,
- backgroundColor: "white",
- borderColor: '#444444',
- borderWidth: 1
+ height: 60,
+ backgroundColor: 'rgba(255,255,255,0.85)',
+ paddingHorizontal: 20,
+ borderRadius: 10,
+ margin: 10,
+ fontSize: 20
},
submitButton: {
backgroundColor: '#7a42f4',
diff --git a/src/screens/ArtisanHub/EditArtisan.js b/src/screens/ArtisanHub/EditArtisan.js
index 5ea1ee5..47acc3a 100644
--- a/src/screens/ArtisanHub/EditArtisan.js
+++ b/src/screens/ArtisanHub/EditArtisan.js
@@ -121,71 +121,73 @@ class EditArtisan extends Component {
render() {
return (
-
-
- this.pickImage()}
- style={styles.image}
- />
-
-
+
+
+
+ this.pickImage()}
+ style={styles.image}
+ />
+
+
+ this.setState({ name: newText })}
+ onFocus={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, name: true } })}
+ onBlur={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, name: false } })}
+ style={styles.smallInput1}
+ />
+
+
+ this.setState({ focusedInputs: { ...this.state.focusedInputs, phoneNumber: true } })}
+ onBlur={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, phoneNumber: false } })}
+ style={styles.smallInput2}
+ keyboardType="number-pad"
+ />
+
+
+
+
+
this.setState({ name: newText })}
- onFocus={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, name: true } })}
- onBlur={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, name: false } })}
- style={styles.smallInput1}
+ iconName="map"
+ placeholder="Location"
+ value={this.state.location}
+ onChangeText={(newText) => this.setState({ location: newText })}
+ onFocus={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, location: true } })}
+ onBlur={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, location: false } })}
+ style={styles.smallInput3}
/>
-
+
this.setState({ focusedInputs: { ...this.state.focusedInputs, phoneNumber: true } })}
- onBlur={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, phoneNumber: false } })}
- style={styles.smallInput2}
- keyboardType="number-pad"
+ placeholder="Describe this artisan"
+ value={this.state.description}
+ onChangeText={(newText) => this.setState({ description: newText })}
+ onFocus={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, description: true } })}
+ onBlur={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, description: false } })}
+ style={styles.largeInputs}
+ multiline={true}
/>
+ this.saveArtisan()}
+ style={styles.button}
+ spinning={this.state.adding}
+ />
-
-
- this.setState({ location: newText })}
- onFocus={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, location: true } })}
- onBlur={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, location: false } })}
- style={styles.smallInput3}
- />
-
-
- this.setState({ description: newText })}
- onFocus={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, description: true } })}
- onBlur={() => this.setState({ focusedInputs: { ...this.state.focusedInputs, description: false } })}
- style={styles.largeInputs}
- multiline={true}
- />
-
-
- this.saveArtisan()}
- style={styles.button}
- spinning={this.state.adding}
- />
)
}
@@ -193,8 +195,9 @@ class EditArtisan extends Component {
const styles = StyleSheet.create({
container: {
+ flex: 1,
flexDirection: 'column',
- justifyContent: 'flex-start',
+ justifyContent: 'space-between',
padding: '2%'
},
image: {
diff --git a/src/screens/ArtisanHub/actions.js b/src/screens/ArtisanHub/actions.js
index 3cca110..8111e4c 100644
--- a/src/screens/ArtisanHub/actions.js
+++ b/src/screens/ArtisanHub/actions.js
@@ -61,7 +61,7 @@ export function fetchArtisans(cgaID) {
}
}
- resolve()
+ resolve(artisanArray)
dispatch({type: 'GET_ARTISANS', artisans: artisanArray})
})
}
@@ -131,7 +131,7 @@ export function fetchProducts(artisanID) {
let productKeys = productSnapshot.val()? Object.keys(productSnapshot.val()): []
productArray = productArray.filter(obj => productKeys.includes(obj.productID))
- resolve()
+ resolve(productArray)
dispatch({ type: 'GET_PRODUCTS', products: productArray })
})
}
diff --git a/src/screens/Auth/Login.js b/src/screens/Auth/Login.js
index 604a626..d9e4c0e 100644
--- a/src/screens/Auth/Login.js
+++ b/src/screens/Auth/Login.js
@@ -29,9 +29,7 @@ export default class Login extends Component {
loginWithAmazon() {
this.setState({amazonWaiting: true})
- this.props.amazonLogin().then((cgaID) => {
- return this.props.fetchAll(cgaID)
- }).then(() => {
+ this.props.amazonLogin().then(() => {
this.setState({amazonWaiting: false})
if(this.props.User)
this.props.navigation.navigate("Home")
diff --git a/src/screens/Launch/Launch.js b/src/screens/Launch/Launch.js
index db8dc92..ae3e289 100644
--- a/src/screens/Launch/Launch.js
+++ b/src/screens/Launch/Launch.js
@@ -1,5 +1,6 @@
import { Logo, Wallpaper } from '@components'
import React, { Component } from 'react'
+import { StyleSheet, Text, ActivityIndicator } from 'react-native'
export default class Launch extends Component {
constructor(props) {
@@ -7,8 +8,9 @@ export default class Launch extends Component {
}
componentDidMount() {
- if(this.props.User)
+ if(this.props.User) {
this.props.navigation.navigate("Home")
+ }
else
this.props.navigation.navigate("Login")
}
@@ -17,7 +19,18 @@ export default class Launch extends Component {
return (
+
)
}
-}
\ No newline at end of file
+}
+
+const styles = StyleSheet.create({
+ text: {
+
+ }
+})
\ No newline at end of file
diff --git a/src/screens/Launch/index.js b/src/screens/Launch/index.js
index 92807ff..52f7670 100644
--- a/src/screens/Launch/index.js
+++ b/src/screens/Launch/index.js
@@ -1,5 +1,7 @@
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
+import { fetchArtisans, fetchProducts } from '../ArtisanHub/actions.js'
+import { fetchConversations } from '../Messaging/actions.js'
import * as globalActions from '@actions'
function mapStateToProps(state) {
@@ -10,7 +12,7 @@ function mapStateToProps(state) {
}
function mapDispatchToProps(dispatch) {
- return bindActionCreators(globalActions, dispatch)
+ return bindActionCreators({fetchArtisans, fetchProducts, fetchConversations, ...globalActions}, dispatch)
}
import Launch from './Launch'
diff --git a/src/screens/Messaging/Conversation.js b/src/screens/Messaging/Conversation.js
index 9504a54..2027d03 100644
--- a/src/screens/Messaging/Conversation.js
+++ b/src/screens/Messaging/Conversation.js
@@ -1,6 +1,6 @@
import React, { Component } from 'react'
import { Wallpaper } from '../../components'
-import { GiftedChat } from 'react-native-gifted-chat'
+import { GiftedChat, Day } from 'react-native-gifted-chat'
import { withMappedNavigationParams } from 'react-navigation-props-mapper'
import ImagePicker from 'react-native-image-crop-picker'
import firebase from 'react-native-firebase'
@@ -118,6 +118,10 @@ class Conversation extends Component {
})
})
}
+
+ renderDay(props) {
+ return
+ }
render() {
return (
@@ -125,10 +129,12 @@ class Conversation extends Component {
this.onSend(messages)}
+ bottomOffset={50}
user={{
_id: this.props.User.uid
}}
placeholder="Type a message..."
+ renderDay={this.renderDay}
/>
)
diff --git a/src/screens/Messaging/actions.js b/src/screens/Messaging/actions.js
index 38dd891..912bb58 100644
--- a/src/screens/Messaging/actions.js
+++ b/src/screens/Messaging/actions.js
@@ -26,7 +26,7 @@ export function fetchConversations(cgaID) {
}
}
- resolve()
+ resolve(conversationArray)
dispatch({type: 'GET_CONVERSATIONS', conversations: conversationArray})
})
}
diff --git a/src/screens/MoneyManagement/LogPayout.js b/src/screens/MoneyManagement/LogPayout.js
index b6d6395..e68381c 100644
--- a/src/screens/MoneyManagement/LogPayout.js
+++ b/src/screens/MoneyManagement/LogPayout.js
@@ -13,25 +13,10 @@ class LogPayout extends Component {
constructor(props) {
super(props)
- this.logPayoutButtons = [
- {
- title: 'View All',
- onPress: () => console.log("button pressed")
- },
- {
- title: 'Stats',
- onPress: () => console.log("button pressed")
- }
- ]
-
- console.log(this.props)
-
this.state = {
amount: "",
description: "",
logging: false,
-
- focusedInputs: {amount: false, desc: false}
}
this.logPayout = this.logPayout.bind(this)
@@ -54,28 +39,20 @@ class LogPayout extends Component {
return (
-
- this.setState({amount: newText})}
- onFocus={()=> this.setState({focusedInputs: {...this.state.focusedInputs, amount: true}})}
- onBlur={()=> this.setState({focusedInputs: {...this.state.focusedInputs, amount: false}})}
- style={styles.smallInput1}
- />
-
-
- this.setState({description: newText})}
- onFocus={()=> this.setState({focusedInputs: {...this.state.focusedInputs, desc: true}})}
- onBlur={()=> this.setState({focusedInputs: {...this.state.focusedInputs, desc: false}})}
- style={styles.largeInputs}
- multiline={true}
- />
-
+ this.setState({amount: newText})}
+ style={styles.smallInput1}
+ />
+ this.setState({description: newText})}
+ style={styles.largeInputs}
+ multiline={true}
+ />
{
return {
title: 'Money Management'
@@ -21,116 +24,112 @@ export default class MoneyManagement extends Component {
constructor(props) {
super(props)
this.state = {
- paidAmount: null,
- amountOwed: null
+ payouts: [],
+ products: [],
+ paidAmount: 0,
+ amountOwed: 0,
+ productsSold: 0,
+ productsRevenue: 0,
+ fetching: false
}
- this.transactionButtons = [
- {
- title: 'View All',
- onPress: () => console.log("Nav to Transactions for artisans")
- },
- {
- title: 'Stats',
- onPress: () => console.log("Clicked on Transaction Stats")
- }
- ]
-
this.payoutButtons = [
{
title: 'View All',
- onPress: () => this.props.navigation.navigate('PayoutList')
- },
- {
- title: 'Stats',
- onPress: () => console.log("Clicked on Payout Stats")
+ onPress: () => this.navigateToPayoutList()
}
]
+ this.updateNumbers = this.updateNumbers.bind(this)
+ this.fetchPayoutsAndTransactions = this.fetchPayoutsAndTransactions.bind(this)
this.navigateToPayoutList = this.navigateToPayoutList.bind(this)
- this.getPayoutsTotal = this.getPayoutsTotal.bind(this)
- this.getPayoutsTotalForArtisan = this.getPayoutsTotalForArtisan.bind(this)
- this.getProductsRevenueTotal = this.getProductsRevenueTotal.bind(this)
- this.getProductsRevenueTotalForArtisan = this.getProductsRevenueTotalForArtisan.bind(this)
}
componentDidMount() {
- payoutsTotal = this.getPayoutsTotal()
- revenueTotal = this.getProductsRevenueTotal()
- this.setState({
- amountOwed: revenueTotal - payoutsTotal,
- paidAmount: payoutsTotal
- })
+ this.updateNumbers()
}
- navigateToPayoutList() {
- navigation.navigate('PayoutList')
+ updateNumbers() {
+ this.fetchPayoutsAndTransactions().then(() => {
+ payoutsTotal = this.state.payouts.reduce((total, current) => {
+ return total + current.amount
+ }, 0)
+
+ productsTotal = this.state.products.reduce((total, current) => {
+ return total + (current.TimesSold * current.StandardPrice)
+ }, 0)
+
+ numProductsSold = this.state.products.reduce((total, current) => {
+ return total + current.TimesSold
+ }, 0)
+
+ this.setState({
+ fetching: false,
+ paidAmount: payoutsTotal,
+ amountOwed: productsTotal - payoutsTotal,
+ productsRevenue: productsTotal,
+ productsSold: numProductsSold
+ })
+ })
}
- getPayoutsTotal() {
- var totalAmount = 0.0
- var artisanIds = this.props.Artisans.map(artisan => artisan.uid)
- artisanIds.forEach(artisanId => {
- totalAmount += this.getPayoutsTotalForArtisan(artisanId)
- })
+ async fetchPayoutsAndTransactions() {
+ this.setState({fetching: true})
- return totalAmount
- }
+ var promises = []
- getProductsRevenueTotal() {
- var totalAmount = 0.0
- var artisanIds = this.props.Artisans.map(artisan => artisan.uid)
- artisanIds.forEach(artisanId => {
- totalAmount += this.getProductsRevenueTotalForArtisan(artisanId)
+ let artisans = await this.props.fetchArtisans(this.props.User.uid)
+ let payouts = await this.props.fetchPayouts(this.props.User.uid)
+ var allProducts = []
+ artisans.forEach(artisan => {
+ let productPromise = this.props.fetchProducts(artisan.uid).then(products => {
+ allProducts = allProducts.concat(products)
+ })
+ promises.push(productPromise)
})
- return totalAmount
- }
-
- getPayoutsTotalForArtisan(artisanUID) {
- artisanPayouts = this.props.Payouts.filter(payout => {
- return payout.artisanId == artisanUID
- })
-
- var totalAmount = 0.0
- artisanPayouts.forEach(payout => {
- totalAmount += payout.amount
+ return Promise.all(promises).then(() => {
+ this.setState({
+ payouts: payouts,
+ products: allProducts
+ })
})
-
- return totalAmount
}
- getProductsRevenueTotalForArtisan(artisanUID) {
- artisanProductIds = this.props.Artisans.filter(artisan => {
- return artisan.uid == artisanUID
- })[0].products
-
- if(!artisanProductIds)
- return 0
- artisanProductIds = Object.keys(artisanProductIds)
-
- artisanProducts = this.props.Products.filter(product =>
- artisanProductIds.includes(product.productID))
-
- var totalAmount = 0.0
- artisanProducts.forEach(product => {
- totalAmount += (parseInt(product.TimesSold) * parseFloat(product.StandardPrice))
- })
-
- return totalAmount
+ navigateToPayoutList() {
+ this.props.navigation.navigate('PayoutList', {
+ ...this.props,
+ products: [].concat(this.state.products),
+ payouts: [].concat(this.state.payouts)
+ })
}
render() {
return (
-
+ {this.state.fetching ?
+
+ :
+
+ }
+ >
- Money Owed: {this.state.amountOwed}
- Total payments: {this.state.paidAmount}
+ Money Owed: ${this.state.amountOwed.toFixed(2)}
+ Total payments: ${this.state.paidAmount.toFixed(2)}
@@ -139,11 +138,12 @@ export default class MoneyManagement extends Component {
buttonsArray={this.transactionButtons}
>
- Number items sold:
- Overall Product Income:
+ Number items sold: {this.state.productsSold}
+ Overall Product Income: ${this.state.productsRevenue.toFixed(2)}
+ }
)
}
@@ -173,4 +173,6 @@ const styles = StyleSheet.create({
fontSize: 20,
color: '#444444'
}
-})
\ No newline at end of file
+})
+
+export default withMappedNavigationParams()(MoneyManagement)
\ No newline at end of file
diff --git a/src/screens/MoneyManagement/PayoutList.js b/src/screens/MoneyManagement/PayoutList.js
index c415632..f1eacb0 100644
--- a/src/screens/MoneyManagement/PayoutList.js
+++ b/src/screens/MoneyManagement/PayoutList.js
@@ -18,7 +18,6 @@ class PayoutList extends Component {
return {
title: 'PayoutList'
}
-
}
constructor(props) {
@@ -38,8 +37,25 @@ class PayoutList extends Component {
})
}
+ getLastPayoutDate(artisanUID) {
+ var payouts = this.props.payouts.filter(payout => {
+ return payout.artisanId === artisanUID
+ })
+
+ payouts.sort((first, second) => {
+ return second.date - first.date
+ })
+
+ console.log(payouts)
+
+ if(payouts.length > 0)
+ return payouts[payouts.length - 1].date
+ else
+ return null
+ }
+
getPayoutsTotalForArtisan(artisanUID) {
- artisanPayouts = this.props.Payouts.filter(payout => {
+ artisanPayouts = this.props.payouts.filter(payout => {
return payout.artisanId == artisanUID
})
@@ -52,15 +68,15 @@ class PayoutList extends Component {
}
getProductsRevenueTotalForArtisan(artisanUID) {
- artisanProductIds = this.props.Artisans.filter(artisan => {
- return artisan.uid == artisanUID
- })[0].products
+ artisanProductIds = this.props.Artisans.filter(artisan => {
+ return artisan.uid == artisanUID
+ })[0].products
- if(!artisanProductIds)
- return 0
- artisanProductIds = Object.keys(artisanProductIds)
+ if(!artisanProductIds)
+ return 0
+ artisanProductIds = Object.keys(artisanProductIds)
- artisanProducts = this.props.Products.filter(product =>
+ artisanProducts = this.props.products.filter(product =>
artisanProductIds.includes(product.productID))
var totalAmount = 0.0
@@ -74,6 +90,8 @@ class PayoutList extends Component {
_renderPayoutListItem = ({item, index}) => {
productsRevenueTotal = this.getProductsRevenueTotalForArtisan(item.uid)
payoutsTotal = this.getPayoutsTotalForArtisan(item.uid)
+ payoutDate = this.getLastPayoutDate(item.uid)
+ payoutDateString = payoutDate ? new Date(payoutDate).toDateString() : "Never"
return (
{item.name}
- {`Last Payout: ${Math.floor(Math.random() * 11 + 1)}/${Math.floor(Math.random() * 27 + 1)}/19`}
- {`Owed: $${productsRevenueTotal - payoutsTotal}`}
- {`Paid: $${payoutsTotal}`}
+ {`Last Payout: ${payoutDateString}`}
+ {`Owed: $${(productsRevenueTotal - payoutsTotal).toFixed(2)}`}
+ {`Paid: $${payoutsTotal.toFixed(2)}`}
)
diff --git a/src/screens/MoneyManagement/actions.js b/src/screens/MoneyManagement/actions.js
index d2f2e57..8848528 100644
--- a/src/screens/MoneyManagement/actions.js
+++ b/src/screens/MoneyManagement/actions.js
@@ -10,7 +10,7 @@ export function fetchPayouts(cgaID) {
payoutsArray = []
for (var uid in payouts) {
- if (payoutIds.includes(uid)) {
+ if(payoutIds.includes(uid)) {
payoutsArray.push({
...payouts[uid],
uid: uid
@@ -18,7 +18,7 @@ export function fetchPayouts(cgaID) {
}
}
- resolve()
+ resolve(payoutsArray)
dispatch({ type: 'GET_PAYOUTS', payouts: payoutsArray })
})
}
diff --git a/src/screens/MoneyManagement/index.js b/src/screens/MoneyManagement/index.js
index 23b5315..8e377e8 100644
--- a/src/screens/MoneyManagement/index.js
+++ b/src/screens/MoneyManagement/index.js
@@ -1,5 +1,6 @@
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
+import { fetchArtisans, fetchProducts } from '../ArtisanHub/actions.js'
import * as actions from './actions'
import * as globalActions from '@actions'
@@ -15,7 +16,7 @@ function mapStateToProps(state) {
}
function mapDispatchToProps(dispatch) {
- return bindActionCreators({ ...actions, ...globalActions }, dispatch)
+ return bindActionCreators({ fetchArtisans, fetchProducts, ...actions, ...globalActions }, dispatch)
}
import { default as UnconnectedMoneyManagement } from './MoneyManagement'
diff --git a/src/screens/Products/AddProduct.js b/src/screens/Products/AddProduct.js
index fda9fd7..22c36ff 100644
--- a/src/screens/Products/AddProduct.js
+++ b/src/screens/Products/AddProduct.js
@@ -1,6 +1,15 @@
import { AddImage, AsyncButton, Wallpaper } from '@components'
import React, { Component } from 'react'
-import { StyleSheet, ScrollView, View, Text, TextInput, Picker, Platform } from 'react-native'
+import {
+ StyleSheet,
+ ScrollView,
+ View,
+ Text,
+ TextInput,
+ Picker,
+ Platform
+} from 'react-native'
+import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scrollview'
import ImagePicker from 'react-native-image-crop-picker'
import { withMappedNavigationParams } from 'react-navigation-props-mapper'
import { ProductCategories } from './ProductCategories'
@@ -111,7 +120,7 @@ class AddProduct extends Component {
render() {
return (
-
+
-
+
)
}
diff --git a/src/screens/Products/LogSale.js b/src/screens/Products/LogSale.js
index 518ff47..0fe462c 100644
--- a/src/screens/Products/LogSale.js
+++ b/src/screens/Products/LogSale.js
@@ -36,7 +36,6 @@ class LogSale extends Component {
quantity: parseInt(this.state.quantity)
}).then((totalSales) => {
this.setState({logging: false})
- this.props.navigation.state.params.ProductDetailScreen.setState({numSales: totalSales})
this.props.navigation.goBack()
}).catch(error => {
this.props.displayError(error)
@@ -45,19 +44,15 @@ class LogSale extends Component {
render() {
return (
-
+
-
- this.setState({quantity: newText})}
- onFocus={()=> this.setState({focusedInputs: {...this.state.focusedInputs, quantity: true}})}
- onBlur={()=> this.setState({focusedInputs: {...this.state.focusedInputs, quantity: false}})}
- style={styles.smallInput1}
- keyboardType="numeric"
- />
-
+ this.setState({quantity: newText})}
+ style={styles.smallInput1}
+ keyboardType="numeric"
+ />
{
+ return {
+ title: 'Settings'
+ }
+ }
+
constructor(props) {
super(props)
@@ -19,12 +25,7 @@ export default class Settings extends Component {
render() {
return (
-
-
-
- {"Settings"}
-
-
+
-
+
)
}
}
const styles = StyleSheet.create({
- container: {
- flex: 1,
- padding: 20
- },
- textContainer: {
- flex: 8,
- marginTop: 10,
- marginBottom: 30,
- justifyContent: 'flex-start',
- alignItems: 'center',
- },
- text: {
- fontSize: 20
+ wallpaper: {
+ padding: 10
},
button: {
- flex: 1
+ flex: 0,
+ height: 50
}
})
\ No newline at end of file