What these field means? What’s their meaning?
One user(end real user) map many wallet?
If so, why after I change username, only one record changed correspondingly?
import Moralis from "moralis";
import MoralisType from "moralis";
import { useState } from "react";
import CustomContainer from "../CustomContainer";
import {
FormControl,
Box,
FormLabel,
Text,
Input,
Button,
} from "@chakra-ui/react";
import { useMoralis } from "react-moralis";
type ProfileProps = {
user: MoralisType.User<Moralis.Attributes> | null;
account: string | null;
};
export default function Profile({ user, account }: ProfileProps) {
const { isInitialized } = useMoralis();
const [input, setInput] = useState("");
const { setUserData, isUserUpdating } = useMoralis();
if (isInitialized) {
console.log("Profile.tsx => address : ", user?.get("ethAddress"), account);
}
return (
<>
<CustomContainer>
<Text>
<b> 😆 Username:</b>
{user && user.get("username")}
</Text>
<Text>
<b> 💰 Wallet:</b> {account}
</Text>
<form
onSubmit={(e) => {
console.log("input.trim() ======> ", input.trim());
e.preventDefault();
if (input.trim().length > 0) {
setUserData({
username: input,
}).then(() => setInput(""));
}
}}
>
<FormControl>
<FormLabel htmlFor="username">Set a new username</FormLabel>
<Input
id="username"
placeholder="ex. Jesse"
variant="filled"
value={input}
style={{ backgroundColor: "#edf2f7" }}
onChange={(e) => setInput(e.target.value)}
></Input>
<Button
type="submit"
mt="6"
disabled={isUserUpdating}
colorScheme="purple"
>
✅ Change Username
</Button>
</FormControl>
</form>
</CustomContainer>
</>
);
}