diff --git a/components/profile/activity.tsx b/components/profile/activity.tsx index 5063d1b..65a417f 100644 --- a/components/profile/activity.tsx +++ b/components/profile/activity.tsx @@ -83,7 +83,7 @@ const Activity: FC = ({ 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; @@ -97,7 +97,7 @@ const Activity: FC = ({ 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`; diff --git a/package-lock.json b/package-lock.json index afc65f1..b1baf2b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tovy", - "version": "2.2.0-beta1", + "version": "2.2.0-beta2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "tovy", - "version": "2.2.0-beta1", + "version": "2.2.0-beta2", "dependencies": { "@headlessui/react": "^1.7.1", "@inovua/reactdatagrid-community": "^5.6.1", diff --git a/package.json b/package.json index 2de09ad..61d69ee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tovy", - "version": "2.2.0-beta1", + "version": "2.2.0-beta2", "private": true, "scripts": { "dev": "next dev", diff --git a/pages/api/workspace/[id]/activity/reset.ts b/pages/api/workspace/[id]/activity/reset.ts index 89ef23f..3c9f943 100644 --- a/pages/api/workspace/[id]/activity/reset.ts +++ b/pages/api/workspace/[id]/activity/reset.ts @@ -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() } diff --git a/pages/api/workspace/[id]/sessions/manage/[sid]/claim.ts b/pages/api/workspace/[id]/sessions/manage/[sid]/claim.ts index dbf44a9..ad07cc4 100644 --- a/pages/api/workspace/[id]/sessions/manage/[sid]/claim.ts +++ b/pages/api/workspace/[id]/sessions/manage/[sid]/claim.ts @@ -91,7 +91,7 @@ export async function handler( id: findSession.id }, data: { - ownerId: BigInt(req.session.userid) + ownerId: BigInt(req.session.userid), } } } @@ -124,6 +124,7 @@ export async function handler( date: dateTime, sessionTypeId: schedule.sessionTypeId, ownerId: req.session.userid, + startedAt: dateTime } } }, diff --git a/pages/api/workspace/[id]/sessions/manage/[sid]/unclaim.ts b/pages/api/workspace/[id]/sessions/manage/[sid]/unclaim.ts index b5cab27..ebf54f9 100644 --- a/pages/api/workspace/[id]/sessions/manage/[sid]/unclaim.ts +++ b/pages/api/workspace/[id]/sessions/manage/[sid]/unclaim.ts @@ -85,7 +85,8 @@ export async function handler( id: findSession.id }, data: { - ownerId: null + ownerId: null, + startedAt: null } }) diff --git a/pages/workspace/[id]/activity/quotas.tsx b/pages/workspace/[id]/activity/quotas.tsx index 96c9228..60a12a6 100644 --- a/pages/workspace/[id]/activity/quotas.tsx +++ b/pages/workspace/[id]/activity/quotas.tsx @@ -85,14 +85,14 @@ const Notices: pageWithLayout = (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." diff --git a/pages/workspace/[id]/profile/[uid].tsx b/pages/workspace/[id]/profile/[uid].tsx index b79aad0..73feb96 100644 --- a/pages/workspace/[id]/profile/[uid].tsx +++ b/pages/workspace/[id]/profile/[uid].tsx @@ -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: { @@ -171,7 +171,8 @@ export const getServerSideProps = withPermissionCheckSsr( } } }); - + + return { props: { diff --git a/pages/workspace/[id]/sessions.tsx b/pages/workspace/[id]/sessions.tsx index 7a974b6..1f7c223 100644 --- a/pages/workspace/[id]/sessions.tsx +++ b/pages/workspace/[id]/sessions.tsx @@ -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: { diff --git a/pages/workspace/[id]/views.tsx b/pages/workspace/[id]/views.tsx index 198b01f..7f99469 100644 --- a/pages/workspace/[id]/views.tsx +++ b/pages/workspace/[id]/views.tsx @@ -661,13 +661,12 @@ const Views: pageWithLayout = ({ usersInGroup, ranks }) => {
-
- -
- +
+
+ + Rows -
{table.getAllLeafColumns().map((column: any) => { @@ -688,20 +687,11 @@ const Views: pageWithLayout = ({ usersInGroup, ranks }) => { -
- - Filters - - {table.getSelectedRowModel().flatRows.length > 0 && ( -
- - - - - -
- )} -
+ + + Filters + + {colFilters.map((filter) => ( @@ -709,6 +699,17 @@ const Views: pageWithLayout = ({ usersInGroup, ranks }) => { ))}
+
+ + {table.getSelectedRowModel().flatRows.length > 0 && ( +
+ + + + + +
+ )} {table.getSelectedRowModel().flatRows.length == 0 && (
{ 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" />