Files
PeerScribe/components/PrescriptionCreator/index.tsx
Abhay Raizada db290cd5dc Add Inputs
2024-03-21 23:12:11 +05:30

119 lines
2.9 KiB
TypeScript

import {Dimensions, Image, StyleSheet, Text, View} from 'react-native';
import {Colors} from 'react-native/Libraries/NewAppScreen';
import {PropsWithChildren} from 'react';
import {Button, Card} from '@ant-design/react-native';
import { V1Field } from '@formstr/sdk/dist/interfaces';
import { InputFiller } from '../Inputs/Inputs';
type SectionProps = PropsWithChildren<{
title: string;
}>;
const backgroundStyle = {
backgroundColor: Colors.darker,
};
const styles = StyleSheet.create({
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
width: Dimensions.get('window').width - 80,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
},
highlight: {
fontWeight: '500',
},
});
function Section({children, title}: SectionProps): React.JSX.Element {
return (
<View style={styles.sectionContainer}>
<Text
style={[
styles.sectionTitle,
{
color: Colors.white,
},
]}>
{title}
</Text>
<Text
style={[
styles.sectionDescription,
{
color: Colors.light,
},
]}>
{children}
</Text>
</View>
);
}
export const PrescriptionCreator = ({form} : {form: any}) => {
if(form === null) return <View><Text>Loading...</Text></View>
return (
<View
style={{
backgroundColor: Colors.black,
}}>
<Image
style={{
height: 100,
width: Dimensions.get('window').width,
}}
source={{
uri: form.settings.titleImageUrl,
}}
/>
<Section title="PeerScribe">
From the practice of {form.name}
</Section>
<Section title="Prescription">
<View style={{display: 'flex', flexDirection: 'column', width: "100%"}}>
{form.fields.map((field: V1Field) => {
return (
<Card
key={field.questionId}
style={{
display: 'flex',
flexDirection: 'column',
padding: 10,
backgroundColor: Colors.white,
margin: 10,
width: 350,
height: 'auto',
}}>
<Text
style={{
color: Colors.green,
}}>
{field.question}
</Text>
{/* <Text
style={{
color: Colors.light,
}}>
{field.answerType}
</Text> */}
<InputFiller answerSettings={field.answerSettings} answerType={field.answerType} onChange={() => {}} />
</Card>
);
})}
<Button type='primary'> Create RX </Button>
</View>
</Section>
</View>
);
};