Remove unused libraries

This commit is contained in:
abhay-raizada
2024-08-11 18:10:54 +05:30
parent 2f0c7ddadb
commit 4de8f3112f
9 changed files with 64 additions and 1017 deletions

View File

@@ -1,105 +0,0 @@
import {
DatePicker,
DatePickerView,
InputItem,
List,
Text,
TextareaItem,
View,
} from '@ant-design/react-native';
import {V1AnswerSettings, AnswerTypes} from '@formstr/sdk/dist/interfaces';
import {useState} from 'react';
import RNPickerSelect from 'react-native-picker-select';
interface InputFillerProps {
answerType: AnswerTypes;
answerSettings: V1AnswerSettings;
onChange: (answer: string) => void;
defaultValue?: string | number | boolean;
}
export const InputFiller: React.FC<InputFillerProps> = ({
answerType,
answerSettings,
onChange,
defaultValue,
}) => {
const [inputValue, setInputValue] = useState('');
const handleInputChange = (e: any) => {
console.log('E is', e);
setInputValue(e);
onChange(e);
};
const handleValueChange = (value: string) => {
if (!value) return;
setInputValue(value);
onChange(value);
};
const getInput = (
answerType: AnswerTypes,
answerSettings: V1AnswerSettings,
) => {
const dropdownItems = (answerSettings.choices || []).map(choice => {
return {
label: choice.label,
value: choice.choiceId,
key: choice.choiceId,
};
});
const INPUT_TYPE_COMPONENT_MAP: {[key in AnswerTypes]?: JSX.Element} = {
[AnswerTypes.label]: <></>,
[AnswerTypes.shortText]: (
<InputItem
onChange={handleValueChange}
defaultValue={defaultValue as string}
placeholder="enter a value..."
placeholderTextColor="#aaaaaa"></InputItem>
),
[AnswerTypes.paragraph]: (
<TextareaItem
rows={10}
placeholder="enter a value.."
placeholderTextColor="#aaaaaa"
onChange={handleInputChange}
autoHeight
style={{paddingVertical: 5}}
/>
),
[AnswerTypes.number]: <View></View>,
[AnswerTypes.radioButton]: <View></View>,
[AnswerTypes.checkboxes]: <View></View>,
[AnswerTypes.dropdown]: (
<RNPickerSelect
onValueChange={handleValueChange}
items={dropdownItems}
placeholder={{}}
key="picker"
value={inputValue}>
<Text>
{inputValue
? answerSettings.choices?.filter(choice => {
return choice.choiceId === inputValue;
})[0].label
: 'Select an option'}
</Text>
</RNPickerSelect>
),
[AnswerTypes.date]: (
<List>
<DatePicker key="Datepicker" />
</List>
),
[AnswerTypes.time]: (
<List>
<DatePicker key="time" />
</List>
),
};
return INPUT_TYPE_COMPONENT_MAP[answerType];
};
return <>{getInput(answerType, answerSettings)}</>;
};

View File

@@ -1,7 +1,7 @@
import {Text, TextInput, View} from 'react-native';
import {Section} from './Section';
import {styles, TextTheme} from './styles';
import {styles, TextTheme} from '../common/styles';
import {useState} from 'react';
import {Section} from '../common/Section';
interface AddressForm {
address_line_1?: string;

View File

@@ -1,6 +1,6 @@
import {Text, TextInput, View} from 'react-native';
import {Section} from './Section';
import {styles, TextTheme} from './styles';
import {Section} from '../common/Section';
import {styles, TextTheme} from '../common/styles';
import {useState} from 'react';
interface MedicineForm {

View File

@@ -1,9 +1,8 @@
import {Text, TextInput, View} from 'react-native';
import {Section} from './Section';
import {styles, TextTheme} from './styles';
import {Text, TextInput, View, Button} from 'react-native';
import {Section} from '../common/Section';
import {styles, TextTheme} from '../common/styles';
import {useState} from 'react';
import DatePicker from 'react-native-date-picker';
import {Button} from '@ant-design/react-native';
interface PatientForm {
name?: string;
@@ -46,21 +45,19 @@ export const PatientForm: React.FC<PatientFormProps> = ({
<View>
<Text style={TextTheme}>{form.date_of_birth}</Text>
<Button
size="small"
onPress={() => {
setOpenDate(true);
}}>
Edit
</Button>
}}
title="Edit"
/>
</View>
) : (
<Button
onPress={() => {
setOpenDate(true);
}}
size="small">
Pick a date
</Button>
title="Pick a date"
/>
)}
<DatePicker
modal

View File

@@ -1,8 +1,14 @@
import {Alert, Appearance, Dimensions, Image, Text, View} from 'react-native';
import {
Alert,
Appearance,
Dimensions,
Image,
Text,
View,
Button,
} from 'react-native';
import {Colors} from 'react-native/Libraries/NewAppScreen';
import {useEffect, useState} from 'react';
import {Button} from '@ant-design/react-native';
// import { SendPrescription } from './sendPrescription';
import {Dropdown} from 'react-native-element-dropdown';
import {
SimplePool,
@@ -14,7 +20,7 @@ import {
} from 'nostr-tools';
import EncryptedStorage from 'react-native-encrypted-storage';
import {ImportNsec} from './ImportNsec';
import {Section} from './Section';
import {Section} from '../common/Section';
import {PatientForm} from './PatientForm';
import {AddressForm} from './AddressForm';
import {MedicineForm} from './MedicineForm';
@@ -203,12 +209,11 @@ export const PrescriptionCreator = () => {
<Section title="PeerScribe">
From the practice of {loggedInNpub}
<Button
size="small"
onPress={() => {
setShowImportNsec(true);
}}>
Edit!
</Button>
}}
title="edit"
/>
</Section>
<Section title="Choose a Pharmacy">
@@ -232,17 +237,16 @@ export const PrescriptionCreator = () => {
<PatientForm nestedFormCallback={nestedFormCallback} />
<AddressForm nestedFormCallback={nestedFormCallback} />
<MedicineForm nestedFormCallback={nestedFormCallback} />
<Button type="primary" onPress={handleButtonPress}>
<Text
<Button onPress={handleButtonPress} title="Create Rx" />
{/* <Text
style={[
{
color: Colors.light,
},
]}>
{' '}
Create RX{' '}
</Text>
</Button>
</Button> */}
</View>
</Section>
<ImportNsec

View File

@@ -10,8 +10,6 @@
"test": "jest"
},
"dependencies": {
"@ant-design/react-native": "^5.1.0",
"@formstr/sdk": "^0.0.4-alpha",
"@react-native-community/datetimepicker": "^8.0.1",
"@react-native-community/segmented-control": "^2.2.2",
"@react-native-community/slider": "^4.5.0",

919
yarn.lock

File diff suppressed because it is too large Load Diff