Skip to content

Commit

Permalink
feat: add feedback form (MN-391) (#611)
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakglobant authored Nov 22, 2023
1 parent f94ef55 commit a68e1cd
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 85 deletions.
2 changes: 1 addition & 1 deletion src/screens/InspectionCapture/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function InspectionCapture() {
{ cancelable: true },
);
} else if (isLastTour) {
navigation.navigate(names.INSPECTION_REPORT, { inspectionId, vehicleType });
navigation.navigate(names.INSPECTION_FEEDBACK, { inspectionId, vehicleType });
} else {
navigation.navigate(names.LANDING, { inspectionId });
}
Expand Down
190 changes: 107 additions & 83 deletions src/screens/InspectionFeedback/index.js
Original file line number Diff line number Diff line change
@@ -1,100 +1,124 @@
import React, { useCallback, useState } from 'react';
import { LinearGradient } from 'expo-linear-gradient';
import { useMediaQuery } from 'react-responsive';
import { Card, List, useTheme } from 'react-native-paper';
import { View, useWindowDimensions } from 'react-native';
import { useNavigation, useRoute } from '@react-navigation/native';
import { useTranslation } from 'react-i18next';
import { version } from '@package/json';

import { Feedback } from '@monkvision/feedback';
import { View } from 'react-native';
import { Container } from '@monkvision/ui';
import * as names from 'screens/names';

import Artwork from '../Landing/Artwork';
import styles from './styles';

export default function InspectionFeedback() {
const [interior, setInterior] = useState('');
const [windShieldCondition, setWindShieldCondition] = useState('');
const { colors } = useTheme();
const { height } = useWindowDimensions();
const { t } = useTranslation();
const navigation = useNavigation();
const isPortrait = useMediaQuery({ query: '(orientation: portrait)' });

const route = useRoute();
const { inspectionId, vehicleType } = route.params || {};

const [tireCondition, setTireCondition] = useState('');
const [tireConditionSingleSelect, setTireConditionSingleSelect] = useState('');
const [tireConditionMultiSelect, setTireConditionMultiSelect] = useState([]);
const [windShieldCondition, setWindShieldCondition] = useState('');
const [vehicleInterior, setVehicleInterior] = useState('');
const [additionInfo, setAdditionInfo] = useState('');

const handleSubmit = useCallback(() => {
console.log('🚀 interior : ', interior);
console.log('🚀 windShieldCondition : ', windShieldCondition);
console.log('🚀 tireCondition : ', tireCondition);
console.log('🚀 tireConditionSingleSelect : ', tireConditionSingleSelect);
console.log('🚀 tireConditionMultiSelect : ', tireConditionMultiSelect);
console.log('🚀 vehicleInterior : ', vehicleInterior);
const data = {
tireCondition,
windShieldCondition,
vehicleInterior,
additionInfo
}
console.log('🚀 ~ handleSubmit ~ data : ', data);
navigation.navigate(names.INSPECTION_REPORT, { inspectionId, vehicleType });
}, [
interior,
windShieldCondition,
inspectionId,
vehicleType,
navigation,
tireCondition,
tireConditionSingleSelect,
tireConditionMultiSelect,
vehicleInterior
windShieldCondition,
vehicleInterior,
additionInfo,
]);

return (
<View style={{ backgroundColor: '#121212', flex: 1, padding: 15 }}>
<Feedback
questions={[{
type: 'text',
question: 'How is the interior of the vehicle?',
answer: interior,
onChange: (value) => setInterior(value)
}, {
type: 'radio',
question: 'Is the windshield in good condition?',
answer: windShieldCondition,
onChange: (data) => setWindShieldCondition(data.value),
options: [
{ label: 'Y', value: true },
{ label: 'N', value: false },
],
}, {
type: 'select',
question: 'Is the tire condition normal (Single Select)?',
answer: tireConditionSingleSelect,
onChange: (data) => setTireConditionSingleSelect(data),
options: [
{ label: 'Poor', value: 'Poor' },
{ label: 'Medium', value: 'Medium' },
{ label: 'Good', value: 'Good' },
{ label: 'Great', value: 'Great' },
],
}, {
type: 'select',
question: 'Is the tire condition normal (Multi Select)?',
answer: tireConditionMultiSelect,
config: {
isMulti: true,
},
onChange: (data) => setTireConditionMultiSelect(data),
options: [
{ label: 'Poor', value: 'Poor' },
{ label: 'Medium', value: 'Medium' },
{ label: 'Good', value: 'Good' },
{ label: 'Great', value: 'Great' },
],
}, {
type: 'radio',
question: 'Is the tire condition normal?',
answer: tireCondition,
onChange: (data) => setTireCondition(data.value),
options: [
{ label: 'Poor', value: 'Poor' },
{ label: 'Medium', value: 'Medium' },
{ label: 'Good', value: 'Good' },
{ label: 'Great', value: 'Great' },
],
}, {
type: 'radio',
question: 'How is the interior of the vehicle?',
answer: vehicleInterior,
onChange: (data) => setVehicleInterior(data.value),
options: [
{ label: 'Poor', value: 'Poor' },
{ label: 'Medium', value: 'Medium' },
{ label: 'Good', value: 'Good' },
],
}, {
type: 'button',
question: 'Submit',
onChange: () => handleSubmit()
}]}
<View style={[styles.root, { minHeight: height, backgroundColor: colors.background }]}>
<LinearGradient
colors={[colors.gradient, colors.background]}
style={[styles.background, { height }]}
/>
<Container style={[styles.container, isPortrait ? styles.portrait : {}]}>
<View style={[styles.left, isPortrait ? styles.leftPortrait : {}]}>
<Artwork />
</View>
<Card style={[styles.card, styles.right, isPortrait ? styles.rightPortrait : {}]}>
<List.Section style={styles.textAlignRight}>
<List.Subheader>
{t('landing.appVersion')}
{': '}
{version}
</List.Subheader>
</List.Section>
<List.Section>
<List.Subheader>Feedback</List.Subheader>
<View style={styles.feedbackWrapper}>
<Feedback
questions={[{
type: 'radio',
question: 'What is the condition of the tires?',
answer: tireCondition,
onChange: (data) => setTireCondition(data.value),
options: [
{ label: 'Poor', value: 'Poor' },
{ label: 'Average', value: 'Average' },
{ label: 'Good', value: 'Good' },
],
}, {
type: 'radio',
question: 'What is the condition of the windshield?',
answer: windShieldCondition,
onChange: (data) => setWindShieldCondition(data.value),
options: [
{ label: 'Poor', value: 'Poor' },
{ label: 'Average', value: 'Average' },
{ label: 'Good', value: 'Good' },
],
}, {
type: 'radio',
question: 'What is the condition of the vehicle\'s interior?',
answer: vehicleInterior,
onChange: (data) => setVehicleInterior(data.value),
options: [
{ label: 'Poor', value: 'Poor' },
{ label: 'Average', value: 'Average' },
{ label: 'Good', value: 'Good' },
],
}, {
type: 'text',
question: 'Any additional info?',
answer: additionInfo,
onChange: (value) => setAdditionInfo(value),
}, {
type: 'button',
question: 'Skip',
onChange: () => handleSubmit()
}, {
type: 'button',
question: 'Validate',
onChange: () => handleSubmit()
}]}
/>
</View>
</List.Section>
</Card>
</Container>
</View>
);
}
Expand Down
48 changes: 47 additions & 1 deletion src/screens/InspectionFeedback/styles.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
import { utils } from '@monkvision/toolkit';
import { StyleSheet } from 'react-native';

export default StyleSheet.create({});
export default StyleSheet.create({
root: {
position: 'relative',
},
container: {
flex: 1,
display: 'flex',
justifyContent: 'space-around',
flexDirection: 'row',
position: 'relative',
},
portrait: {
flex: 1,
display: 'flex',
justifyContent: 'flex-start',
flexDirection: 'column',
},
background: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
},
left: {
flex: 0.75,
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
paddingVertical: utils.styles.spacing(2),
paddingRight: utils.styles.spacing(2),
},
right: {
flex: 1.25,
display: 'flex',
},
card: {
borderRadius: 0,
},
textAlignRight: {
alignItems: 'flex-end',
},
feedbackWrapper: {
marginHorizontal: 15
}
});

0 comments on commit a68e1cd

Please sign in to comment.