-
Notifications
You must be signed in to change notification settings - Fork 26
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 #72 from Ashutoshbind15/main
Add map review for admins and some admin helpers
- Loading branch information
Showing
7 changed files
with
153 additions
and
9 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,55 @@ | ||
"use client"; | ||
|
||
import { Map } from "@/components/Map"; | ||
import { Button } from "@/components/ui/button"; | ||
import { | ||
Card, | ||
CardContent, | ||
CardFooter, | ||
CardHeader, | ||
CardTitle, | ||
} from "@/components/ui/card"; | ||
import { api } from "@/convex/_generated/api"; | ||
import { useMutation, useQuery } from "convex/react"; | ||
|
||
const Page = () => { | ||
const isAdmin = useQuery(api.users.isAdmin); | ||
const maps = useQuery(api.maps.getMaps, { isReviewed: false }); | ||
const adminApprovalMutation = useMutation(api.maps.approveMap); | ||
|
||
if (isAdmin == true) { | ||
return ( | ||
<div className="py-6"> | ||
<h1 className="text-center font-semibold mb-4">Review Maps</h1> | ||
<div className="flex items-center justify-around"> | ||
{maps?.map((map) => ( | ||
<Card key={map._id}> | ||
<CardHeader> | ||
<CardTitle> </CardTitle> | ||
</CardHeader> | ||
|
||
<CardContent> | ||
<Map map={map.grid} /> | ||
</CardContent> | ||
|
||
<CardFooter className="flex justify-center"> | ||
<Button | ||
variant="outline" | ||
onClick={async () => { | ||
await adminApprovalMutation({ mapId: map._id }); | ||
}} | ||
> | ||
Approve | ||
</Button> | ||
</CardFooter> | ||
</Card> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
return <div>Not an admin</div>; | ||
}; | ||
|
||
export default Page; |
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
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
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