-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c07f2ff
commit d9a26a0
Showing
6 changed files
with
112 additions
and
4 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
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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { Formik } from 'formik'; | ||
import { t } from 'i18next'; | ||
import { Text, View } from 'native-base'; | ||
import { withTranslation } from 'react-i18next'; | ||
import { StyleSheet } from 'react-native'; | ||
import { connect, useDispatch } from 'react-redux'; | ||
import { createDelivery, getPrice } from '../../redux/Store/actions'; | ||
import FormInput from './components/FormInput'; | ||
import ModalFormWrapper from './ModalFormWrapper'; | ||
|
||
function NewDeliveryPrice(props) { | ||
const dispatch = useDispatch(); | ||
const delivery = props.route.params?.delivery; | ||
if (!delivery) return; | ||
dispatch(getPrice(delivery)); | ||
|
||
function submit(values) { | ||
dispatch( | ||
createDelivery(values, () => { | ||
props.navigation.navigate('StoreHome'); | ||
}), | ||
); | ||
} | ||
|
||
return ( | ||
<Formik | ||
initialValues={delivery} | ||
onSubmit={submit} | ||
validateOnBlur={false} | ||
validateOnChange={false}> | ||
{({ handleSubmit }) => ( | ||
<ModalFormWrapper handleSubmit={handleSubmit} t={t} isSubmit> | ||
<View style={styles.formGroup}> | ||
<Text style={styles.label}>Price excluding tax</Text> | ||
<FormInput value={props.priceExcludingTax} editable={false} /> | ||
</View> | ||
<View style={styles.formGroup}> | ||
<Text style={styles.label}>Total</Text> | ||
<FormInput value={props.price} editable={false} /> | ||
</View> | ||
</ModalFormWrapper> | ||
)} | ||
</Formik> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
label: { | ||
marginBottom: 8, | ||
fontWeight: '500', | ||
}, | ||
formGroup: { | ||
marginBottom: 10, | ||
}, | ||
}); | ||
|
||
function mapStateToProps(state) { | ||
const price = state.store.price; | ||
const priceExcludingTax = state.store.priceExcludingTax; | ||
return { | ||
price, | ||
priceExcludingTax, | ||
}; | ||
} | ||
export default connect(mapStateToProps)(withTranslation()(NewDeliveryPrice)); |
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