Skip to content

Commit

Permalink
fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
nickkdoesstuff committed Jan 3, 2023
1 parent 6f4891e commit e23a9b0
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 33 deletions.
4 changes: 2 additions & 2 deletions components/profile/activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const Activity: FC<Props> = ({ timeSpent, timesPlayed, data, quotas, sessionsAtt
const getQuotaPercentage = (quota: Quota) => {
switch (quota.type) {
case "mins": {
return (timesPlayed / quota.value) * 100;
return (timeSpent / quota.value) * 100;
}
case "sessions_hosted": {
return (sessionsHosted / quota.value) * 100;
Expand All @@ -97,7 +97,7 @@ const Activity: FC<Props> = ({ timeSpent, timesPlayed, data, quotas, sessionsAtt
const getQuotaProgress = (quota: Quota) => {
switch (quota.type) {
case "mins": {
return `${timesPlayed} / ${quota.value} minutes`;
return `${timeSpent} / ${quota.value} minutes`;
}
case "sessions_hosted": {
return `${sessionsHosted} / ${quota.value} sessions hosted`;
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tovy",
"version": "2.2.0-beta1",
"version": "2.2.0-beta2",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
6 changes: 4 additions & 2 deletions pages/api/workspace/[id]/activity/reset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ export async function handler(
try {
await prisma.activitySession.deleteMany({
where: {
userId: req.session.userid
workspaceGroupId: Number(req.query.id as string )
}
});

await prisma.session.deleteMany({
where: {
ownerId: req.session.userid,
sessionType: {
workspaceGroupId: Number(req.query.id)
},
date: {
lte: new Date()
}
Expand Down
3 changes: 2 additions & 1 deletion pages/api/workspace/[id]/sessions/manage/[sid]/claim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export async function handler(
id: findSession.id
},
data: {
ownerId: BigInt(req.session.userid)
ownerId: BigInt(req.session.userid),
}
}
}
Expand Down Expand Up @@ -124,6 +124,7 @@ export async function handler(
date: dateTime,
sessionTypeId: schedule.sessionTypeId,
ownerId: req.session.userid,
startedAt: dateTime
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion pages/api/workspace/[id]/sessions/manage/[sid]/unclaim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ export async function handler(
id: findSession.id
},
data: {
ownerId: null
ownerId: null,
startedAt: null
}
})

Expand Down
4 changes: 2 additions & 2 deletions pages/workspace/[id]/activity/quotas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ const Notices: pageWithLayout<pageProps> = (props) => {
`/api/workspace/${id}/activity/quotas/new`,
{ value: Number(requirement), type, roles: selectedRoles, name }
).then(req => {
setQuotas([...quotas, req.data.notice])

});
toast.promise(
axiosPromise,
{
loading: "Creating your quota...",
success: () => {
setIsOpen(false);
router.reload()
return "Quota created!";
},
error: "Quota was not created due to an unknown error."
Expand Down
5 changes: 3 additions & 2 deletions pages/workspace/[id]/profile/[uid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const getServerSideProps = withPermissionCheckSsr(
async ({ query, req }) => {
const userTakingAction = await prisma.user.findFirst({
where: {
userid: BigInt(req.session.userid)
userid: BigInt(query.uid as string)
},
include: {
roles: {
Expand Down Expand Up @@ -171,7 +171,8 @@ export const getServerSideProps = withPermissionCheckSsr(
}
}
});




return {
props: {
Expand Down
2 changes: 1 addition & 1 deletion pages/workspace/[id]/sessions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const getServerSideProps = withPermissionCheckSsr(async ({ query }) => {
const sessions = await prisma.session.findMany({
where: {
startedAt: {
not: null
lte: new Date()
},
ended: null,
sessionType: {
Expand Down
39 changes: 20 additions & 19 deletions pages/workspace/[id]/views.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -661,13 +661,12 @@ const Views: pageWithLayout<pageProps> = ({ usersInGroup, ranks }) => {

<div className="pagePadding">

<div className="flex flex-row gap-2">
<Popover as="div" className="relative inline-block text-left pb-2">
<div className="w-full flex flex-col lg:flex-row lg:space-x-2 space-y-2 lg:space-y-0">
<Popover.Button as={Button} classoverride="ml-0 min-w-fit" >
<div className="flex flex-col md:flex-row gap-2">
<div className="flex flex-row gap-2">
<Popover as="div" className="relative inline-block text-left pb-2">
<Popover.Button as={Button} classoverride="ml-0" >
Rows
</Popover.Button>
</div>
<Popover.Panel className="absolute left-0 z-20 mt-2 w-80 origin-top-left rounded-xl bg-white dark:bg-gray-800 shadow-lg ring-1 ring-gray-300 focus-visible:outline-none p-3">
<div className="flex flex-col gap-1">
{table.getAllLeafColumns().map((column: any) => {
Expand All @@ -688,27 +687,29 @@ const Views: pageWithLayout<pageProps> = ({ usersInGroup, ranks }) => {
</Popover.Panel>
</Popover>
<Popover as="div" className="relative inline-block text-left pb-2">
<div className="w-full flex flex-col lg:flex-row lg:space-x-2 space-y-2 lg:space-y-0">
<Popover.Button as={Button} classoverride="ml-0" >
Filters
</Popover.Button>
{table.getSelectedRowModel().flatRows.length > 0 && (
<div className="grid grid-cols-1 gap-2 auto-cols-max md:grid-cols-5">
<Button classoverride="bg-green-500 hover:bg-green-500/50 ml-0" onPress={() => { setType("promotion"); setIsOpen(true) }}>Mass promote {table.getSelectedRowModel().flatRows.length} users</Button>
<Button classoverride="bg-orange-500 hover:bg-orange-500/50 ml-0" onPress={() => { setType("warning"); setIsOpen(true) }}>Mass warn {table.getSelectedRowModel().flatRows.length} users</Button>
<Button classoverride="bg-gray-800 hover:bg-gray-800/50 ml-0" onPress={() => { setType("suspension"); setIsOpen(true) }}>Mass suspend {table.getSelectedRowModel().flatRows.length} users</Button>
<Button classoverride="bg-red-500 hover:bg-red-500/50 ml-0" onPress={() => { setType("fire"); setIsOpen(true) }}>Mass fire {table.getSelectedRowModel().flatRows.length} users</Button>
<Button classoverride="bg-emerald-500 hover:bg-emerald-500/50 ml-0" onPress={() => { setType("add"); setIsOpen(true) }}>Add minutes to {table.getSelectedRowModel().flatRows.length} users</Button>
</div>
)}
</div>

<Popover.Button as={Button} classoverride="ml-0" >
Filters
</Popover.Button>

<Popover.Panel className="absolute left-0 z-20 mt-2 w-80 origin-top-left rounded-xl bg-white dark:bg-gray-800 shadow-lg ring-1 ring-gray-300 focus-visible:outline-none p-3">
<Button onClick={newfilter}> Add filter </Button>
{colFilters.map((filter) => (
<div className="p-3 outline outline-gray-300 rounded-md mt-4 outline-1" key={filter.id}> <Filter ranks={ranks} updateFilter={(col, op, value) => updateFilter(filter.id, col, op, value)} deleteFilter={() => removeFilter(filter.id)} data={filter} /> </div>
))}
</Popover.Panel>
</Popover>
</div>

{table.getSelectedRowModel().flatRows.length > 0 && (
<div className="flex flex-row flex-wrap gap-2 mb-2">
<Button classoverride="bg-green-500 hover:bg-green-500/50 ml-0" onPress={() => { setType("promotion"); setIsOpen(true) }}>Mass promote {table.getSelectedRowModel().flatRows.length} users</Button>
<Button classoverride="bg-orange-500 hover:bg-orange-500/50 ml-0" onPress={() => { setType("warning"); setIsOpen(true) }}>Mass warn {table.getSelectedRowModel().flatRows.length} users</Button>
<Button classoverride="bg-gray-800 hover:bg-gray-800/50 ml-0" onPress={() => { setType("suspension"); setIsOpen(true) }}>Mass suspend {table.getSelectedRowModel().flatRows.length} users</Button>
<Button classoverride="bg-red-500 hover:bg-red-500/50 ml-0" onPress={() => { setType("fire"); setIsOpen(true) }}>Mass fire {table.getSelectedRowModel().flatRows.length} users</Button>
<Button classoverride="bg-emerald-500 hover:bg-emerald-500/50 ml-0" onPress={() => { setType("add"); setIsOpen(true) }}>Add minutes to {table.getSelectedRowModel().flatRows.length} users</Button>
</div>
)}
{table.getSelectedRowModel().flatRows.length == 0 && (
<div className="relative inline-block w-full pb-2">
<input type="text" value={searchQuery} onChange={(e:any) => { updateSearchQuery(e.target.value) }} className="bg-white border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full h-full" placeholder="Search Username" />
Expand Down

0 comments on commit e23a9b0

Please sign in to comment.