Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
{/* With NavBar */}
{/* Redirect if no match */}
)
}
}
const mapStateToProps = Reselect.createStructuredSelector({
currentUserId: selectors.users.currentId,
})
export default ReactRedux.connect(
mapStateToProps
)(Routes)
// @flow
import type { DispatchType } from 'constants/redux'
import * as ReactRedux from 'react-redux'
import * as Reselect from 'reselect'
import selectors from 'redux/selectors'
import shoppingCartAction from 'redux/actions/shopping-cart'
import * as ShoppingCart from '../index'
const mapStateToProps = Reselect.createStructuredSelector({
order: selectors.orders.shoppingCart,
orderId: selectors.users.shoppingCartOrderId,
walletAddress: selectors.wallet.address,
})
const mapDispatchToProps = (dispatch: DispatchType) => ({
onResetShoppingCart: () => {
dispatch(shoppingCartAction.reset())
},
})
export default ReactRedux.connect(
mapStateToProps,
mapDispatchToProps
)(ShoppingCart.default)
): ThunkActionType<{ order: ?OrderType, orderId: ?IdType }> => (
dispatch,
getState
) => {
const state = getState()
const shoppingCartOrderId = selector.users.shoppingCartOrderId(state)
let order = null
let orderId = null
if (inputOrderId) {
orderId = inputOrderId
order = selector.orders.order(state, { orderId })
} else if (shoppingCartOrderId) {
order = selector.orders.shoppingCart(state)
orderId = shoppingCartOrderId
}
console.log({ orderId, shoppingCartOrderId, order })
return { order, orderId }
}
const mapStateToProps = state => ({
auth: selectors.getAuthState(state),
items: selectors.getItemsState(state),
orders: selectors.orders.all(state),
shoppingCartOrderId: selectors.users.shoppingCartOrderId(state),
})
): ThunkActionType> => async (
dispatch,
getState,
{ getFirebase }
) => {
const state = getState()
const currentUserId = selectors.users.currentId(state)
await getFirebase()
.collection('users')
.doc(currentUserId)
.update({
shoppingCartOrderId: orderId,
})
}
import * as ReactRedux from 'react-redux'
import * as Reselect from 'reselect'
import currentUser from 'redux/actions/current-user'
import selectors from 'redux/selectors'
import SignInOAuth from '..'
const mapStateToProps = Reselect.createStructuredSelector({
userId: selectors.users.currentId,
storeId: selectors.users.currentStoreId,
})
const mapDispatchToProps = dispatch => ({
signInWithOAuth: service => dispatch(currentUser.signInWithOAuth(service)),
})
export default ReactRedux.connect(
mapStateToProps,
mapDispatchToProps
)(SignInOAuth)
import * as ReactRedux from 'react-redux'
import * as ReactRouter from 'react-router'
import * as Reselect from 'reselect'
import selectors from 'redux/selectors'
import currentUserAction from 'redux/actions/current-user'
import shopAction from 'redux/actions/shop'
import * as Profile from '../index'
type OwnPropsType = ReactRouter.ContextRouter
const mapStateToProp = Reselect.createStructuredSelector({
authError: selectors.getAuthError,
email: selectors.users.current,
walletAddress: selectors.wallet.address,
store: selectors.shop.current,
storeId: selectors.users.currentStoreId,
})
const mapDispatchToProps = (dispatch: DispatchType) => ({
signOut: () => dispatch(currentUserAction.signOut()),
onUpdateAddress: async ({
walletAddress,
storeId,
}: {
walletAddress: string,
storeId: IdType,
}) => {
const data = { walletAddress }
}: $Shape): ThunkActionType> => async (
dispatch,
getState,
{ getFirestore }
) => {
const state = getState()
const uid = selectors.users.currentId(state)
if (!uid) {
dispatch({
type: ACTIONS.SHOP_SIGNUP_ERROR,
payload: 'First, you should login or signup user account',
})
return false
}
if (!storeName) {
dispatch({
type: ACTIONS.SHOP_SIGNUP_ERROR,
payload: 'Store name is empty. Please type it in.',
})
return false
}
const resetTransaction = (): ThunkActionType> => async (
dispatch,
getState,
{ getFirestore }
) => {
const state = getState()
const orderId = selectors.users.shoppingCartOrderId(state)
await getFirestore()
.collection('orders')
.doc(orderId)
.update({
txHash: null,
txConfirmed: null,
})
}
import orderAction from 'redux/actions/order'
import selectors from 'redux/selectors'
import ItemCard from '../item-card'
type OwnPropsType = {
item: ItemType,
itemId: IdType,
isFirstInRow: boolean,
isEditing: boolean,
}
const mapStateToProps = Reselect.createStructuredSelector({
item: selectors.items.item,
orderId: selectors.users.shoppingCartOrderId,
shoppingCartOrderItem: selectors.items.shoppingCartOrderItem,
})
const mapDispatchToProps = (
dispatch: DispatchType,
ownProps: OwnPropsType
) => ({
onBadgeClick: async () => {
const { itemId } = ownProps
await dispatch(orderAction.removeItem({ itemId }))
},
onPhotoClick: async () => {
const { itemId } = ownProps
await dispatch(orderAction.addItem({ itemId }))
},
})