-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from AndrewCK24/11-state-use-swr
refactor(api): 重構接受邀請功能, 整合更換隊伍與接受邀請功能至 /api/users/teams
- Loading branch information
Showing
14 changed files
with
320 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { FiInfo, FiUsers } from "react-icons/fi"; | ||
import { | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableHead, | ||
TableHeader, | ||
TableRow, | ||
} from "@/components/ui/table"; | ||
|
||
const TeamInfoTable = ({ team, className }) => { | ||
const contents = [ | ||
{ key: "簡稱", value: team.nickname, icon: <FiInfo /> }, | ||
{ key: "人數", value: team.members.length, icon: <FiUsers /> }, | ||
]; | ||
|
||
return ( | ||
<Table className={className}> | ||
<TableHeader className="text-lg"> | ||
<TableRow> | ||
<TableHead colSpan={3}>隊伍資訊</TableHead> | ||
</TableRow> | ||
</TableHeader> | ||
<TableBody className="text-xl"> | ||
{contents.map(({ key, value, icon }) => ( | ||
<TableRow key={key}> | ||
<TableCell className="w-6 [&>svg]:w-6 [&>svg]:h-6"> | ||
{icon} | ||
</TableCell> | ||
<TableCell className="text-nowrap text-muted-foreground"> | ||
{key} | ||
</TableCell> | ||
<TableCell className="w-full font-medium">{value}</TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
); | ||
}; | ||
|
||
export default TeamInfoTable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,8 @@ | ||
import { Card } from "@/components/ui/card"; | ||
import TeamInfo from "../../TeamInfo"; | ||
|
||
const getTeamData = async (teamId) => { | ||
const response = await fetch(process.env.URL + `/api/teams/${teamId}`); | ||
const { teamData, membersData } = await response.json(); | ||
return { teamData, membersData }; | ||
}; | ||
|
||
const TeamInfoPage = async ({ params }) => { | ||
const { id: teamId } = params; | ||
const { teamData, membersData } = await getTeamData(teamId); | ||
return ( | ||
<Card className="w-full"> | ||
<TeamInfo teamData={teamData} membersData={membersData} /> | ||
</Card> | ||
); | ||
return <TeamInfo teamId={teamId} className="w-full" />; | ||
}; | ||
|
||
export default TeamInfoPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.
4e9c5b1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
v-stats – ./
v-stats-andrewck24s-projects.vercel.app
v-stats-git-master-andrewck24s-projects.vercel.app
v-stats-beta.vercel.app