You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Mobile/components/quiz/NameQuestion.tsx

34 lines
951 B

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>
);
});