Commit 049713f4 authored by YoonDongMin's avatar YoonDongMin
Browse files

YdM

parent 55abadbf
import React from 'react';
import {StyleSheet, View, Text} from 'react-native';
export default function ReviewDetails() {
return (
<View style = {styles.container}>
<Text>ReviewDetails Screen</Text>
</View>
)
}
const styles = StyleSheet.create({
container: (
padding: 24
)
});
\ No newline at end of file
import React from 'react';
import { StyleSheet, Button, TextInput, View, Text } from 'react-native';
import { globalStyles } from '../styles/global.js'
import { Formik } from 'formik';
import * as yup from 'yup';
const ReviewSchema = yup.object({
title: yup.string()
.required()
.min(4),
body: yup.string()
.required()
.min(8),
rating: yup.string()
.required()
.test('is-num-1-5', 'Rating must be a number 1 -5', (val) => {
return parseInt(val) < 6 && passInt(val) > 0;
})
})
export default function ReviewForm(addReview) {
return (
<View style={globalStyles.container} >
<Formik
initialValues={{ title: '', body: '', rating: '' }}
validationSchema={ReviewSchema}
onSubmit={(values) => {
addReview(values);
}}
>
{(props) => (
<View>
<TextInput
style={globalStyles.input}
placeholder='Review title'
onChangeText={props.handleChange('title')}
value={props.values.title}
/>
<TextInput
multiline
style={globalStyles.input}
placeholder='Review body'
onChangeText={props.handleChange('body')}
value={props.values.body}
/>
<TextInput
multiline
style={globalStyles.input}
placeholder='Rating (1-5)'
onChangeText={props.handleChange('rating')}
value={props.values.rating}
keyboardType = 'numeric'
/>
<Button title='submit' color='maroon' onPress={props.handleSubmit} />
</View>
)}
</Formik>
</View >
)
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment