优化ntrp和性别picker偶尔选不上值
This commit is contained in:
@@ -52,7 +52,7 @@ const PopupPicker = ({
|
||||
ntrpTested,
|
||||
}: PickerProps) => {
|
||||
const [defaultValue, setDefaultValue] = useState<(string | number)[]>([]);
|
||||
const [defaultOptions, setDefaultOptions] = useState<PickerOption[][]>([]);
|
||||
const [defaultOptions, setDefaultOptions] = useState<PickerOption[][]>([...options]);
|
||||
const [pickerCurrentValue, setPickerCurrentValue] =
|
||||
useState<(string | number)[]>(value);
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
useUserActions,
|
||||
useNicknameChangeStatus,
|
||||
useLastTestResult,
|
||||
useUserInfo,
|
||||
} from "@/store/userStore";
|
||||
import { UserInfoType } from "@/services/userService";
|
||||
import {
|
||||
@@ -73,7 +74,6 @@ const on_edit = () => {
|
||||
// 用户信息卡片组件
|
||||
const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
|
||||
editable = true,
|
||||
user_info,
|
||||
is_current_user,
|
||||
is_following = false,
|
||||
collapseProfile,
|
||||
@@ -84,6 +84,8 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
|
||||
set_user_info,
|
||||
onTab,
|
||||
}) => {
|
||||
|
||||
const user_info = useUserInfo();
|
||||
const nickname_change_status = useNicknameChangeStatus();
|
||||
const { setShowGuideBar } = useGlobalState();
|
||||
const { updateUserInfo, updateNickname, fetchLastTestResult } =
|
||||
@@ -122,11 +124,15 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
|
||||
useState(false);
|
||||
|
||||
// 表单状态
|
||||
const [form_data, set_form_data] = useState<Partial<UserInfoType>>({});
|
||||
const [form_data, set_form_data] = useState<Partial<UserInfoType>>({ ...user_info });
|
||||
|
||||
useDidShow(() => {
|
||||
// useDidShow(() => {
|
||||
// set_form_data({ ...user_info });
|
||||
// });
|
||||
|
||||
useEffect(() => {
|
||||
set_form_data({ ...user_info });
|
||||
});
|
||||
}, [user_info])
|
||||
|
||||
useEffect(() => {
|
||||
const visibles = [
|
||||
@@ -372,7 +378,6 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
|
||||
urls: [url],
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<View className="user_info_card">
|
||||
{/* 头像和基本信息 */}
|
||||
@@ -413,11 +418,11 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
|
||||
<View className="stats_section">
|
||||
<View
|
||||
className="stats_container"
|
||||
// style={{
|
||||
// marginBottom: `${
|
||||
// collapseProfile && setMarginBottom ? "16px" : "unset"
|
||||
// }`,
|
||||
// }}
|
||||
// style={{
|
||||
// marginBottom: `${
|
||||
// collapseProfile && setMarginBottom ? "16px" : "unset"
|
||||
// }`,
|
||||
// }}
|
||||
>
|
||||
<View
|
||||
className="stat_item clickable"
|
||||
@@ -650,16 +655,16 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
|
||||
<PopupPicker
|
||||
showHeader={true}
|
||||
title="选择性别"
|
||||
options={[
|
||||
options={
|
||||
[
|
||||
{ text: "男", value: "0" },
|
||||
{ text: "女", value: "1" },
|
||||
{ text: "保密", value: "2" },
|
||||
],
|
||||
]}
|
||||
]
|
||||
}
|
||||
visible={gender_picker_visible}
|
||||
setvisible={setGenderPickerVisible}
|
||||
value={form_data.gender === "" ? ["0"] : [form_data.gender]}
|
||||
value={!form_data.gender ? ["0"] : [form_data.gender]}
|
||||
onChange={handle_gender_change}
|
||||
/>
|
||||
)}
|
||||
@@ -868,9 +873,8 @@ export const GameTabs: React.FC<GameTabsProps> = ({
|
||||
<Text className="tab_text">{hosted_text}</Text>
|
||||
</View>
|
||||
<View
|
||||
className={`tab_item ${
|
||||
active_tab === "participated" ? "active" : ""
|
||||
}`}
|
||||
className={`tab_item ${active_tab === "participated" ? "active" : ""
|
||||
}`}
|
||||
onClick={() => on_tab_change("participated")}
|
||||
>
|
||||
<Text className="tab_text">{participated_text}</Text>
|
||||
|
||||
Reference in New Issue
Block a user