i have in issue to solve, in last days i tring update my DB in firestore but unfortunately i can’t, i read the documentation and i read anothers from stackoverflow questions, but don’t make my update funcionar, don’t know what i make wrong, bellow is my code.
here is my button who send to edit screen he is located in home Screen where i have a list of my informations he is inside a map
<IconButton
icon={<Icon as={AntDesign} name="edit" color="success.900" />}
borderRadius="full"
onPress={() =>
navigation.navigate("EditScreen", { userId: user.id }) //here i passing a user id to
editing
}
/>
here is code of my EditScreen
export const EditScreen = ({ navigation }) => {
const [name, setName] = useState("");
const [cep, setCep] = useState("");
const [logradouro, setLogradouro] = useState("");
const [numero, setNumero] = useState("");
const [bairro, setBairro] = useState("");
const [uf, setUf] = useState("");
const usersCollectionRef = collection(db, "users");
const handleChangeName = (value) => setName(value);
const handleChangeCep = (number) => setCep(number);
const handleChangeLogradouro = (value) => setLogradouro(value);
const handleChangeNumero = (number) => setNumero(number);
const handleChangeBairro = (value) => setBairro(value);
const handleChangeUf = (value) => setUf(value);
const updateUser = async (id) => {
const userDoc = doc(usersCollectionRef, id);
const newFields = {
name: handleChangeName,
cep: handleChangeCep,
logradouro: handleChangeLogradouro,
numero: setNuhandleChangeNumeromero,
bairro: handleChangeBairro,
uf: handleChangeUf,
};
await updateDoc(userDoc, newFields);
navigation.navigate("HomeScreen");
};
return (
<SafeAreaView style={{ backgroundColor: "#D4D4D8" }}>
<Center h="100%" bg="dark.600">
<Box ml="-300px" mb="80px" flexDirection="row" alignItems='center'>
<IconButton
size="lg"
icon={<Icon as={AntDesign} name="left" color="orange.600" />}
borderRadius="full"
onPress={() => navigation.navigate("HomeScreen")}
/>
</Box>
<Box mb="25px" w="360px">
<FormControl.Label ml="12px">
<Text bold>Nome</Text>
</FormControl.Label>
<TextInput value={name} onChangeText={handleChangeName} />
</Box>
<Box w="360px">
<FormControl.Label ml="12px">
<Text bold>CEP</Text>
</FormControl.Label>
<TextInput value={cep} onChangeText={handleChangeCep} />
</Box>
<Text fontSize="12px">
busque automaticamente seu edereço atraves do cep
</Text>
<Box flexDirection="row" mt="47px">
<Box w="208px" mr="34px">
<FormControl.Label ml="12px">
<Text bold>Logradouro</Text>
</FormControl.Label>
<TextInput
value={logradouro}
onChangeText={handleChangeLogradouro}
/>
</Box>
<Box w="109px">
<FormControl.Label ml="12px">
<Text bold>Número</Text>
</FormControl.Label>
<TextInput value={numero} onChangeText={handleChangeNumero} />
</Box>
</Box>
<Box flexDirection="row" mt="16px">
<Box w="208px" mr="34px">
<FormControl.Label ml="12px">
<Text bold>Bairro</Text>
</FormControl.Label>
<TextInput value={bairro} onChangeText={handleChangeBairro} />
</Box>
<Box w="109px">
<FormControl.Label ml="12px">
<Text bold>UF</Text>
</FormControl.Label>
<TextInput value={uf} onChangeText={handleChangeUf} />
</Box>
</Box>
<Box mt="50px">
<PrimaryButton onPress={updateUser}>salvar</PrimaryButton>
</Box>
</Center>
</SafeAreaView>
);
};