1
This commit is contained in:
@@ -65,20 +65,22 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({ isActive = true }
|
||||
game_records: TennisMatch[]
|
||||
): { notEndGames: TennisMatch[]; finishedGames: TennisMatch[] } => {
|
||||
const now = new Date().getTime();
|
||||
return game_records.reduce(
|
||||
(result, cur) => {
|
||||
let { end_time } = cur;
|
||||
end_time = end_time.replace(/\s/, "T");
|
||||
new Date(end_time).getTime() > now
|
||||
? result.notEndGames.push(cur)
|
||||
: result.finishedGames.push(cur);
|
||||
return result;
|
||||
},
|
||||
{
|
||||
notEndGames: [] as TennisMatch[],
|
||||
finishedGames: [] as TennisMatch[],
|
||||
}
|
||||
);
|
||||
|
||||
// 使用for
|
||||
const notEndGames: TennisMatch[] = [];
|
||||
const finishedGames: TennisMatch[] = [];
|
||||
for (const game of game_records) {
|
||||
const { end_time } = game;
|
||||
const end_time_str = end_time.replace(/\s/, "T");
|
||||
new Date(end_time_str).getTime() > now
|
||||
? notEndGames.push(game)
|
||||
: finishedGames.push(game);
|
||||
}
|
||||
|
||||
console.log("notEndGames", notEndGames);
|
||||
|
||||
return { notEndGames, finishedGames };
|
||||
|
||||
},
|
||||
[]
|
||||
);
|
||||
@@ -95,6 +97,8 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({ isActive = true }
|
||||
} else {
|
||||
games_data = await UserService.get_participated_games(user_info.id);
|
||||
}
|
||||
|
||||
|
||||
const sorted_games = games_data.sort((a, b) => {
|
||||
return (
|
||||
new Date(a.original_start_time.replace(/\s/, "T")).getTime() -
|
||||
@@ -102,6 +106,8 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({ isActive = true }
|
||||
);
|
||||
});
|
||||
const { notEndGames, finishedGames } = classifyGameRecords(sorted_games);
|
||||
console.log("notEndGames", notEndGames);
|
||||
|
||||
set_game_records(notEndGames);
|
||||
setEndedGameRecords(finishedGames);
|
||||
} catch (error) {
|
||||
@@ -250,17 +256,15 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({ isActive = true }
|
||||
<View className={styles.gameTabsSection}>
|
||||
<View className={styles.tabContainer}>
|
||||
<View
|
||||
className={`${styles.tabItem} ${
|
||||
active_tab === "hosted" ? styles.active : ""
|
||||
}`}
|
||||
className={`${styles.tabItem} ${active_tab === "hosted" ? styles.active : ""
|
||||
}`}
|
||||
onClick={() => setActiveTab("hosted")}
|
||||
>
|
||||
<Text className={styles.tabText}>我主办的</Text>
|
||||
</View>
|
||||
<View
|
||||
className={`${styles.tabItem} ${
|
||||
active_tab === "participated" ? styles.active : ""
|
||||
}`}
|
||||
className={`${styles.tabItem} ${active_tab === "participated" ? styles.active : ""
|
||||
}`}
|
||||
onClick={() => setActiveTab("participated")}
|
||||
>
|
||||
<Text className={styles.tabText}>我参与的</Text>
|
||||
@@ -281,7 +285,7 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({ isActive = true }
|
||||
btnImg="ICON_ADD"
|
||||
reload={goPublish}
|
||||
isShowNoData={game_records.length === 0}
|
||||
loadMoreMatches={() => {}}
|
||||
loadMoreMatches={() => { }}
|
||||
collapse={true}
|
||||
style={{
|
||||
paddingBottom: ended_game_records.length ? 0 : "90px",
|
||||
@@ -308,7 +312,7 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({ isActive = true }
|
||||
error={null}
|
||||
errorImg="ICON_LIST_EMPTY_CARD"
|
||||
isShowNoData={ended_game_records.length === 0}
|
||||
loadMoreMatches={() => {}}
|
||||
loadMoreMatches={() => { }}
|
||||
collapse={true}
|
||||
style={{ paddingBottom: "90px", overflow: "hidden" }}
|
||||
listLoadErrorWrapperHeight="fit-content"
|
||||
|
||||
Reference in New Issue
Block a user