-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #239 from SFTtech/milo/remove-formik
remove formik in favor of react-hook-form
- Loading branch information
Showing
78 changed files
with
1,226 additions
and
1,303 deletions.
There are no files selected for viewing
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,27 @@ | ||
import * as React from "react"; | ||
import { Control, Controller } from "react-hook-form"; | ||
import { Checkbox, HelperText, CheckboxItemProps } from "react-native-paper"; | ||
|
||
export type FormCheckboxProps = Omit<CheckboxItemProps, "onPress" | "status"> & { | ||
name: string; | ||
control: Control<any, any>; | ||
}; | ||
|
||
export const FormCheckbox: React.FC<FormCheckboxProps> = ({ name, control, ...props }) => { | ||
return ( | ||
<Controller | ||
name={name} | ||
control={control} | ||
render={({ field: { onChange, value }, fieldState: { error } }) => ( | ||
<> | ||
<Checkbox.Item | ||
status={value ? "checked" : "unchecked"} | ||
onPress={() => onChange(!value)} | ||
{...props} | ||
/> | ||
{error && <HelperText type="error">{error.message}</HelperText>} | ||
</> | ||
)} | ||
/> | ||
); | ||
}; |
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 * as React from "react"; | ||
import { Control, Controller } from "react-hook-form"; | ||
import { HelperText } from "react-native-paper"; | ||
import DateTimeInput, { DateTimeInputProps } from "./DateTimeInput"; | ||
import { fromISOStringNullable, toISODateStringNullable } from "@abrechnung/utils"; | ||
|
||
export type FormDateTimeInputProps = Omit<DateTimeInputProps, "onChange" | "value" | "error"> & { | ||
name: string; | ||
control: Control<any, any>; | ||
}; | ||
|
||
export const FormDateTimeInput: React.FC<FormDateTimeInputProps> = ({ name, control, ...props }) => { | ||
return ( | ||
<Controller | ||
control={control} | ||
name={name} | ||
render={({ field: { onChange, value }, fieldState: { error } }) => ( | ||
<> | ||
<DateTimeInput | ||
value={fromISOStringNullable(value)} | ||
onChange={(val) => onChange(toISODateStringNullable(val))} | ||
error={!!error} | ||
{...props} | ||
/> | ||
{error && <HelperText type="error">{error.message}</HelperText>} | ||
</> | ||
)} | ||
/> | ||
); | ||
}; |
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,24 @@ | ||
import * as React from "react"; | ||
import { Control, Controller } from "react-hook-form"; | ||
import { HelperText } from "react-native-paper"; | ||
import { NumericInput, NumericInputProps } from "./NumericInput"; | ||
|
||
export type FormNumericInput = Omit<NumericInputProps, "onChange" | "value" | "error"> & { | ||
name: string; | ||
control: Control<any, any>; | ||
}; | ||
|
||
export const FormNumericInput: React.FC<FormNumericInput> = ({ name, control, ...props }) => { | ||
return ( | ||
<Controller | ||
name={name} | ||
control={control} | ||
render={({ field: { onChange, onBlur, value }, fieldState: { error } }) => ( | ||
<> | ||
<NumericInput error={!!error} onChange={onChange} onBlur={onBlur} value={value} {...props} /> | ||
{error && <HelperText type="error">{error.message}</HelperText>} | ||
</> | ||
)} | ||
/> | ||
); | ||
}; |
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,24 @@ | ||
import * as React from "react"; | ||
import { Control, Controller } from "react-hook-form"; | ||
import { HelperText } from "react-native-paper"; | ||
import { TagSelect, TagSelectProps } from "./tag-select"; | ||
|
||
export type FormTagSelect = Omit<TagSelectProps, "value" | "onChange"> & { | ||
name: string; | ||
control: Control<any, any>; | ||
}; | ||
|
||
export const FormTagSelect: React.FC<FormTagSelect> = ({ name, control, ...props }) => { | ||
return ( | ||
<Controller | ||
control={control} | ||
name={name} | ||
render={({ field: { onChange, value }, fieldState: { error } }) => ( | ||
<> | ||
<TagSelect value={value} onChange={onChange} {...props} /> | ||
{error && <HelperText type="error">{error.message}</HelperText>} | ||
</> | ||
)} | ||
/> | ||
); | ||
}; |
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,23 @@ | ||
import * as React from "react"; | ||
import { Control, Controller } from "react-hook-form"; | ||
import { HelperText, TextInput, TextInputProps } from "react-native-paper"; | ||
|
||
export type FormTextInputProps = Omit<TextInputProps, "onChange" | "value" | "error"> & { | ||
name: string; | ||
control: Control<any, any>; | ||
}; | ||
|
||
export const FormTextInput: React.FC<FormTextInputProps> = ({ name, control, ...props }) => { | ||
return ( | ||
<Controller | ||
name={name} | ||
control={control} | ||
render={({ field: { onChange, onBlur, value }, fieldState: { error } }) => ( | ||
<> | ||
<TextInput error={!!error} onChange={onChange} onBlur={onBlur} value={value} {...props} /> | ||
{error && <HelperText type="error">{error.message}</HelperText>} | ||
</> | ||
)} | ||
/> | ||
); | ||
}; |
24 changes: 24 additions & 0 deletions
24
frontend/apps/mobile/src/components/FormTransactionShareInput.tsx
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,24 @@ | ||
import * as React from "react"; | ||
import { Control, Controller } from "react-hook-form"; | ||
import { HelperText } from "react-native-paper"; | ||
import { TransactionShareInput, TransactionShareInputProps } from "./transaction-shares/TransactionShareInput"; | ||
|
||
export type FormTransactionShareInputProps = Omit<TransactionShareInputProps, "value" | "onChange"> & { | ||
name: string; | ||
control: Control<any, any>; | ||
}; | ||
|
||
export const FormTransactionShareInput: React.FC<FormTransactionShareInputProps> = ({ name, control, ...props }) => { | ||
return ( | ||
<Controller | ||
control={control} | ||
name={name} | ||
render={({ field: { onChange, value }, fieldState: { error } }) => ( | ||
<> | ||
<TransactionShareInput value={value} onChange={onChange} error={!!error} {...props} /> | ||
{error && <HelperText type="error">{error.message}</HelperText>} | ||
</> | ||
)} | ||
/> | ||
); | ||
}; |
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
Oops, something went wrong.