-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: pass task type param to task creation screen * feat: outline json doc, update enum * fix: so Matt can see * feat: parse JSON and fix format to maintain order * feat(AddressComponent.tsx): added address component to be reused throughout taskCreation.tsx * feat: frontend components for task creation * style: formatting * style: format fix * style(TaskCreation): moved the component down and fixed radioButton component * feat(TaskCreation): added functionality to store information/input from user * feat: radio buttons grey when not selected * fix: add an add task button to home page --------- Co-authored-by: narayansharma-21 <[email protected]> Co-authored-by: Matt McCoy <[email protected]>
- Loading branch information
1 parent
e1a3312
commit 7f3ff78
Showing
20 changed files
with
391 additions
and
67 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
File renamed without changes.
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,55 @@ | ||
import React from 'react'; | ||
import { Text, TextInput, View } from 'react-native'; | ||
|
||
export function AddressComponent() { | ||
return ( | ||
<View> | ||
<View className="m-4 mb-0"> | ||
<Text className="mb-2">Street Address</Text> | ||
<TextInput | ||
className="border-gray-300 w-full rounded-md border px-4 py-2" | ||
placeholder={'Fill in blank'} | ||
autoComplete="street-address" | ||
/> | ||
</View> | ||
|
||
<View className="m-4 mb-0 flex flex-row"> | ||
<View className="w-[49%]"> | ||
<Text className="mb-2">City</Text> | ||
<TextInput | ||
className="border-gray-300 w-full rounded-md border px-4 py-2" | ||
placeholder={'Fill in blank'} | ||
/> | ||
</View> | ||
<View className="ml-2 w-[49%]"> | ||
<Text className="mb-2">State</Text> | ||
<TextInput | ||
className="border-gray-300 w-full rounded-md border px-4 py-2" | ||
placeholder={'Fill in blank'} | ||
/> | ||
</View> | ||
</View> | ||
|
||
<View className="m-4 mb-0 flex flex-row"> | ||
<View className="w-[49%]"> | ||
<Text className="mb-2">Zip Code</Text> | ||
<TextInput | ||
className="border-gray-300 w-full rounded-md border px-4 py-2" | ||
placeholder={'Fill in blank'} | ||
autoComplete="postal-code" | ||
keyboardType="numeric" | ||
/> | ||
</View> | ||
<View className="ml-2 w-[49%]"> | ||
<Text className="mb-2">Phone Number</Text> | ||
<TextInput | ||
className="border-gray-300 w-full rounded-md border px-4 py-2" | ||
placeholder={'Fill in blank'} | ||
autoComplete="tel" | ||
keyboardType="phone-pad" | ||
/> | ||
</View> | ||
</View> | ||
</View> | ||
); | ||
} |
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,42 @@ | ||
import React, { useState } from 'react'; | ||
import { Text, TouchableOpacity, View } from 'react-native'; | ||
|
||
import ButtonCircle from '../../assets/radio-button-circle.svg'; | ||
|
||
interface RadioGroupProps { | ||
title: string; | ||
options: string[]; | ||
onChange?: (value: string) => void; | ||
} | ||
|
||
export function RadioGroup({ title, options, onChange }: RadioGroupProps) { | ||
const [selectedOption, setSelectedOption] = useState(''); | ||
|
||
const handleOptionSelect = (option: string) => { | ||
setSelectedOption(option); | ||
console.log('Selected option:', option); | ||
if (onChange) { | ||
onChange(option); | ||
} | ||
}; | ||
|
||
return ( | ||
<View className="m-4 mb-0"> | ||
<Text className="mb-2">{title}</Text> | ||
<View className="flex flex-row justify-between"> | ||
{options.map((option, index) => ( | ||
<TouchableOpacity | ||
key={index} | ||
className={`flex h-12 flex-row items-center space-x-2 rounded-md border px-4 py-2 ${option === selectedOption ? 'bg-carewallet-gray' : ''}`} | ||
onPress={() => { | ||
handleOptionSelect(option); | ||
}} | ||
> | ||
<ButtonCircle /> | ||
<Text>{option}</Text> | ||
</TouchableOpacity> | ||
))} | ||
</View> | ||
</View> | ||
); | ||
} |
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,30 @@ | ||
import React, { useState } from 'react'; | ||
import { Text, TextInput, View } from 'react-native'; | ||
|
||
interface TextInputLineProps { | ||
title: string; | ||
onChange?: (value: string) => void; | ||
} | ||
|
||
export function TextInputLine({ title, onChange }: TextInputLineProps) { | ||
const [inputValue, setInputValue] = useState(''); | ||
|
||
const handleInputChange = (value: string) => { | ||
setInputValue(value); | ||
if (onChange) { | ||
onChange(value); | ||
} | ||
}; | ||
|
||
return ( | ||
<View className="m-4 mb-0"> | ||
<Text className="mb-2">{title}</Text> | ||
<TextInput | ||
className="border-gray-300 w-full rounded-md border px-4 py-2" | ||
placeholder={'Fill in blank'} | ||
onChangeText={handleInputChange} | ||
value={inputValue} | ||
/> | ||
</View> | ||
); | ||
} |
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,36 @@ | ||
import React, { useState } from 'react'; | ||
import { Text, TextInput, View } from 'react-native'; | ||
|
||
interface TextInputParagraphProps { | ||
title: string; | ||
onChange?: (value: string) => void; | ||
} | ||
|
||
export function TextInputParagraph({ | ||
title, | ||
onChange | ||
}: TextInputParagraphProps) { | ||
const [inputValue, setInputValue] = useState(''); | ||
|
||
const handleInputChange = (value: string) => { | ||
setInputValue(value); | ||
if (onChange) { | ||
onChange(value); | ||
} | ||
}; | ||
|
||
return ( | ||
<View className="m-4 mb-0"> | ||
<Text className="mb-2">{title}</Text> | ||
<TextInput | ||
style={{ height: 100 }} | ||
className="border-gray-300 w-full rounded-md border px-4 py-2" | ||
placeholder={'Fill in blank'} | ||
multiline={true} | ||
numberOfLines={4} | ||
onChangeText={handleInputChange} | ||
value={inputValue} | ||
/> | ||
</View> | ||
); | ||
} |
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
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,92 @@ | ||
import React, { useState } from 'react'; | ||
import { Text, View } from 'react-native'; | ||
|
||
import { RouteProp, useRoute } from '@react-navigation/native'; | ||
import { | ||
GestureHandlerRootView, | ||
ScrollView | ||
} from 'react-native-gesture-handler'; | ||
|
||
import { BackButton } from '../components/nav_buttons/BackButton'; | ||
import { AddressComponent } from '../components/task_creation/AddressComponent.tsx'; | ||
import { RadioGroup } from '../components/task_creation/RadioGroup.tsx'; | ||
import { TextInputLine } from '../components/task_creation/TextInputLine.tsx'; | ||
import { TextInputParagraph } from '../components/task_creation/TextInputParagraph.tsx'; | ||
import { TaskCreationJson } from '../types/task-creation-json.ts'; | ||
|
||
type ParamList = { | ||
mt: { | ||
taskType: string; | ||
}; | ||
}; | ||
|
||
export function TaskCreation() { | ||
const route = useRoute<RouteProp<ParamList, 'mt'>>(); | ||
const { taskType } = route.params; | ||
|
||
const header = TaskCreationJson.types.find((t) => | ||
taskType.includes(t.Header) | ||
)?.Header; | ||
|
||
const body = TaskCreationJson.types.find((t) => | ||
taskType.includes(t.Header) | ||
)?.Body; | ||
|
||
const compList: { key: string; value: string }[] = []; | ||
|
||
body?.forEach((item) => { | ||
Object.entries(item).forEach(([key, value]) => { | ||
compList.push({ key, value }); | ||
}); | ||
}); | ||
|
||
const [values, setValues] = useState<{ [key: string]: string }>({}); | ||
|
||
const handleChange = (key: string, value: string) => { | ||
setValues((prevValues) => ({ | ||
...prevValues, | ||
[key]: value | ||
})); | ||
console.log('Current values:', values); | ||
}; | ||
|
||
return ( | ||
<GestureHandlerRootView> | ||
<ScrollView className="mt-10"> | ||
<View className="flex w-full flex-row items-center justify-center"> | ||
<View className="mr-[95px]"> | ||
<BackButton /> | ||
</View> | ||
<Text className="mr-auto self-center text-center text-carewallet-gray"> | ||
Step 1 of 2 | ||
</Text> | ||
</View> | ||
<Text className="text-center text-2xl font-bold">{header}</Text> | ||
{compList.map((item, index) => ( | ||
<View key={index}> | ||
{item.key === 'Address' && <AddressComponent />} | ||
{item.value === 'TextInputLine' && ( | ||
<TextInputLine | ||
title={item.key} | ||
onChange={(value) => handleChange(item.key, value)} | ||
/> | ||
)} | ||
{item.value === 'TextInputParagraph' && ( | ||
<TextInputParagraph | ||
title={item.key} | ||
onChange={(value) => handleChange(item.key, value)} | ||
/> | ||
)} | ||
{item.value.startsWith('RadioGroup') && ( | ||
<RadioGroup | ||
title={item.key} | ||
options={item.value.substring(12).split(', ')} | ||
onChange={(value) => handleChange(item.key, value)} | ||
/> | ||
)} | ||
</View> | ||
))} | ||
</ScrollView> | ||
</GestureHandlerRootView> | ||
); | ||
} |
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
Oops, something went wrong.