parent
4cba2025cf
commit
a3e567f291
@ -0,0 +1,33 @@
|
||||
import { StringUtils } from "@/utils/string.utils";
|
||||
import React, { forwardRef, useImperativeHandle, useState } from "react";
|
||||
import { View } from "react-native";
|
||||
import FormInput from "../form/FormInput";
|
||||
import Question, { QuestionChildProps } from "./Question";
|
||||
|
||||
export interface NameQuestionRef {
|
||||
getAnswer: () => string;
|
||||
isOk: () => boolean;
|
||||
}
|
||||
|
||||
export default forwardRef<any, QuestionChildProps>(({ ...props }, ref) => {
|
||||
const [answer, setAnswer] = useState<string>();
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
getAnswer: () => answer,
|
||||
isOk: () => !StringUtils.IsNullOrEnptyWhiteSpace(answer ?? ""),
|
||||
}));
|
||||
|
||||
return (
|
||||
<Question question="Quel est votre nom ?" {...props} {...ref}>
|
||||
<View className="gap-4">
|
||||
<FormInput
|
||||
beforeIcon="user"
|
||||
placeholder="Ex: Michel"
|
||||
label={"Prénom"}
|
||||
value={answer}
|
||||
onChangeText={setAnswer}
|
||||
/>
|
||||
</View>
|
||||
</Question>
|
||||
);
|
||||
});
|
@ -0,0 +1,5 @@
|
||||
export class StringUtils {
|
||||
public static IsNullOrEnptyWhiteSpace(str: string | undefined): boolean {
|
||||
return str === null || str === undefined || str.trim() === "";
|
||||
}
|
||||
}
|
Loading…
Reference in new issue