Skip to content

Commit

Permalink
refactor(contest):change id to uuid and change user to users (#1629)
Browse files Browse the repository at this point in the history
* refactor(contest):change id to uuid and change user to users

* refactor(contest):change id to uuid and change use
r to users

* return String to string

---------

Co-authored-by: zou-y-t <[email protected]>
  • Loading branch information
zou-y-t and zou-y-t authored Mar 7, 2024
1 parent c042277 commit 2454f67
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 158 deletions.
16 changes: 7 additions & 9 deletions src/app/ContestSite/ArenaPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ const ArenaPage: React.FC<ContestProps> = ({ mode, user }) => {
//根据队长id查询队伍id
const { data: isleaderData } = graphql.useIsTeamLeaderSuspenseQuery({
variables: {
_id: user?.uuid!,
uuid: user?.uuid!,
contest_id: Contest_id,
},
});
//根据队员id查询队伍id
const { data: ismemberData } = graphql.useIsTeamMemberSuspenseQuery({
variables: {
uuid: user?.uuid!,
contest_uuid: Contest_id,
user_uuid: user?.uuid!,
contest_id: Contest_id,
},
});

Expand Down Expand Up @@ -133,7 +133,7 @@ const ArenaPage: React.FC<ContestProps> = ({ mode, user }) => {
scoreteamListData?.contest_team.filter((item) => {
return (
item.team_name?.indexOf(associatedValue) !== -1 ||
item.team_leader_id?.name?.indexOf(associatedValue) !== -1
item.team_leader_byuuid?.realname?.indexOf(associatedValue) !== -1
);
}),
);
Expand Down Expand Up @@ -191,16 +191,14 @@ const ArenaPage: React.FC<ContestProps> = ({ mode, user }) => {
},
{
title: "队长",
key: "team_leader_id",
render: (text, record) => record.team_leader_id?.name,
key: "team_leader_byuuid",
render: (text, record) => record.team_leader_byuuid?.realname,
},
{
title: "队员",
key: "team_member",
render: (text, record) =>
record.contest_team_members.map((i) => [
i.user_as_contest_team_member.name + " ",
]),
record.contest_team_members.map((i) => [i.user?.realname + " "]),
},
{
title: "队伍简介",
Expand Down
6 changes: 3 additions & 3 deletions src/app/ContestSite/CodePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ const CodePage: React.FC<ContestProps> = ({ mode, user }) => {

const { data: isleaderData } = graphql.useIsTeamLeaderSuspenseQuery({
variables: {
_id: user?.uuid!,
uuid: user?.uuid!,
contest_id: Contest_id,
},
});
const { data: ismemberData } = graphql.useIsTeamMemberSuspenseQuery({
variables: {
uuid: user?.uuid!,
contest_uuid: Contest_id,
user_uuid: user?.uuid!,
contest_id: Contest_id,
},
});

Expand Down
30 changes: 13 additions & 17 deletions src/app/ContestSite/JoinPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ const JoinPage: React.FC<ContestProps> = ({ mode, user }) => {
const { data: isleaderData, refetch: refetchisleader } =
graphql.useIsTeamLeaderSuspenseQuery({
variables: {
_id: user?.uuid!,
uuid: user?.uuid!,
contest_id: Contest_id,
},
});

const { data: ismemberData, refetch: refetchismember } =
graphql.useIsTeamMemberSuspenseQuery({
variables: {
uuid: user?.uuid!,
contest_uuid: Contest_id,
user_uuid: user?.uuid!,
contest_id: Contest_id,
},
});

Expand Down Expand Up @@ -118,17 +118,15 @@ const JoinPage: React.FC<ContestProps> = ({ mode, user }) => {
[
team.team_name,
team.team_intro,
team.team_leader_id?.name,
team.team_leader_id?.email || "null",
team.team_leader_id?.phone || "null",
team.team_leader_byuuid?.realname,
team.team_leader_byuuid?.email || "null",
team.team_leader_byuuid?.phone || "null",
].concat(
team.contest_team_members?.map(
(member) =>
`${member.user_as_contest_team_member?.name}/ ${
member.user_as_contest_team_member?._id
}/ ${
member.user_as_contest_team_member?.email || "null"
}/ ${member.user_as_contest_team_member?.phone || "null"}`,
`${member.user?.realname}/ ${member.user?.id}/ ${
member.user?.email || "null"
}/ ${member.user?.phone || "null"}`,
),
),
),
Expand All @@ -148,7 +146,7 @@ const JoinPage: React.FC<ContestProps> = ({ mode, user }) => {
try {
await insertteamMember({
variables: {
team_uuid: teamId,
team_id: teamId,
user_uuid: user?.uuid!,
},
});
Expand Down Expand Up @@ -188,16 +186,14 @@ const JoinPage: React.FC<ContestProps> = ({ mode, user }) => {
{
title: "队长",
key: "team_leader",
render: (text, record) => record.team_leader_id?.name,
render: (text, record) => record.team_leader_byuuid?.realname,
},
{
title: "队员",
key: "team_member",
render: (text, record, index) =>
record.contest_team_members.map((i) => [
i.user_as_contest_team_member.name + " ",
]),
//record.contest_team_members[0].user_as_contest_team_member.name,
record.contest_team_members.map((i) => [i.user?.realname + " "]),
//record.contest_team_members[0].user.name,
}, // TODO: 此处有误
{
title: "队伍简介",
Expand Down
6 changes: 3 additions & 3 deletions src/app/ContestSite/ListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const ListPage: React.FC<ContestProps> = ({ mode, user }) => {
} = graphql.useGetUser_IdSuspenseQuery({
variables: {
email: "",
name: "",
realname: "",
},
});

Expand Down Expand Up @@ -247,7 +247,7 @@ const ListPage: React.FC<ContestProps> = ({ mode, user }) => {
try {
const newUserData = await refetchUserId({
email: item.email,
name: item.name,
realname: item.name,
});
const user_uuid = newUserData.data.users[0]?.uuid;
if (user_uuid) {
Expand Down Expand Up @@ -291,7 +291,7 @@ const ListPage: React.FC<ContestProps> = ({ mode, user }) => {
try {
const newUserData = await refetchUserId({
email: item.email,
name: item.name,
realname: item.name,
});
const user_uuid = newUserData.data.users[0]?.uuid;
if (user_uuid) {
Expand Down
24 changes: 10 additions & 14 deletions src/app/ContestSite/ManagePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ const ManagePage: React.FC<ContestProps> = ({ mode, user }) => {
const { data: isleaderData, refetch: refetchLeader } =
graphql.useIsTeamLeaderSuspenseQuery({
variables: {
_id: user?.uuid!,
uuid: user?.uuid!,
contest_id: Contest_id,
},
});

const { data: ismemberData, refetch: refetchMember } =
graphql.useIsTeamMemberSuspenseQuery({
variables: {
uuid: user?.uuid!,
contest_uuid: Contest_id,
user_uuid: user?.uuid!,
contest_id: Contest_id,
},
});

Expand Down Expand Up @@ -119,9 +119,9 @@ const ManagePage: React.FC<ContestProps> = ({ mode, user }) => {

const team = {
...teamData?.contest_team[0],
leader_name: teamData?.contest_team[0]?.team_leader_id?.name,
leader_name: teamData?.contest_team[0]?.team_leader_byuuid?.realname,
};
const isLeader = user?.uuid === team.team_leader_id?._id;
const isLeader = user?.uuid === team.team_leader_byuuid?.uuid;

if (!user) {
return <Spin />;
Expand Down Expand Up @@ -207,12 +207,12 @@ const ManagePage: React.FC<ContestProps> = ({ mode, user }) => {
{
title: "姓名",
key: "name",
render: (text, record) => record.user_as_contest_team_member?.name,
render: (text, record) => record.user?.realname,
},
{
title: "学号",
key: "id",
render: (text, record) => record.user_as_contest_team_member?.id,
render: (text, record) => record.user?.id,
},
{
title: "管理",
Expand All @@ -222,9 +222,7 @@ const ManagePage: React.FC<ContestProps> = ({ mode, user }) => {
<Button
// disabled={isleaderData?.contest_team.length === 0}
onClick={async () => {
await deleteTeamMemberByLeader(
record.user_as_contest_team_member._id,
);
await deleteTeamMemberByLeader(record.user?.uuid);
await refetchMemberInfo();
}}
>
Expand Down Expand Up @@ -322,7 +320,7 @@ const ManagePage: React.FC<ContestProps> = ({ mode, user }) => {
<Text>{team.invited_code}</Text>
</Form.Item>
<Form.Item label="队长">
<Text>{team.team_leader_id?.name}</Text>
<Text>{team.team_leader_byuuid?.realname}</Text>
</Form.Item>
<Form.Item label="队员">
<Suspense fallback={<Loading />}>
Expand All @@ -332,9 +330,7 @@ const ManagePage: React.FC<ContestProps> = ({ mode, user }) => {
dataSource={
teamMemberData?.contest_team_member as graphql.GetMemberInfoQuery["contest_team_member"]
}
rowKey={(record) =>
record.user_as_contest_team_member._id
}
rowKey={(record) => record.user?.uuid}
/>
</Suspense>
</Form.Item>
Expand Down
Loading

0 comments on commit 2454f67

Please sign in to comment.