Skip to content

Commit 4b8c02b

Browse files
committed
Some little change
1 parent 6ba6eca commit 4b8c02b

8 files changed

Lines changed: 209 additions & 83 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import axios from "axios";
2+
import type toast from "react-hot-toast";
3+
import { useRecoilState } from "recoil";
4+
import SwitchComponenet from "@/components/switch";
5+
import { workspacestate } from "@/state";
6+
import { FC } from '@/types/settingsComponent'
7+
import { BadgeCheck } from "lucide-react";
8+
9+
type props = {
10+
triggerToast: typeof toast;
11+
}
12+
13+
const Guide: FC<props> = (props) => {
14+
const triggerToast = props.triggerToast;
15+
const [workspace, setWorkspace] = useRecoilState(workspacestate);
16+
17+
const updateColor = async () => {
18+
const res = await axios.patch(`/api/workspace/${workspace.groupId}/settings/general/workspace`, {
19+
enabled: !workspace.settings.guidesEnabled
20+
});
21+
if (res.status === 200) {
22+
const obj = JSON.parse(JSON.stringify(workspace), (key, value) => (typeof value === 'bigint' ? value.toString() : value));
23+
obj.settings.guidesEnabled = !workspace.settings.guidesEnabled;
24+
setWorkspace(obj);
25+
triggerToast.success("Updated documents!");
26+
} else {
27+
triggerToast.error("Failed to update documents.");
28+
}
29+
};
30+
31+
return (
32+
<div className="flex items-center justify-between px-5 py-4">
33+
<div className="flex items-center gap-3">
34+
<div className="p-2 bg-primary/10 rounded-lg">
35+
<BadgeCheck size={18} className="text-primary" />
36+
</div>
37+
<div>
38+
<p className="text-sm font-medium text-zinc-900 dark:text-white">Verified Workspace</p>
39+
<p className="text-xs text-zinc-500 dark:text-zinc-400">Showcase your verified workspace, if it is affiliated with Planetary Orbit.</p>
40+
</div>
41+
</div>
42+
<SwitchComponenet
43+
checked={workspace.settings?.guidesEnabled}
44+
onChange={updateColor}
45+
label=""
46+
classoverride="mt-0"
47+
/>
48+
</div>
49+
);
50+
};
51+
52+
Guide.title = "Documents";
53+
54+
export default Guide;

pages/api/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
2+
import type { NextApiRequest, NextApiResponse } from 'next'
3+
4+
type Data = {
5+
message: string
6+
}
7+
8+
export default function handler(
9+
_req: NextApiRequest,
10+
res: NextApiResponse<Data>
11+
) {
12+
res.status(200).json({ message: 'Hello from Orbit!' })
13+
}

pages/api/public/v1/workspace/[id]/sessions/upcoming.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
4545
.status(400)
4646
.json({ success: false, error: "startDate must be before endDate" });
4747

48-
const take = Math.min(Number(limit) || 50, 100);
48+
const take = Math.min(Number(limit) || 50, 10000);
4949
const skip = (Math.max(Number(page) || 1, 1) - 1) * take;
5050

5151
try {

pages/api/setupworkspace.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import prisma from "@/utils/database";
55
import * as noblox from "noblox.js";
66
import bcryptjs from "bcryptjs";
77
import { setRegistry } from "@/utils/registryManager";
8-
import { getRobloxUserId } from "@/utils/roblox";
8+
import { getRobloxUserId, isGroupAllied } from "@/utils/roblox";
99
import { createSession } from "@/utils/session";
1010

1111
type Data = {
@@ -67,6 +67,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
6767

6868
let groupName = `Group ${groupIdNumber}`;
6969
let groupLogo = '';
70+
let isVerified = false;
7071

7172
try {
7273
const [logo, group] = await Promise.all([
@@ -75,12 +76,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
7576
]);
7677
if (group) groupName = group.name;
7778
if (logo) groupLogo = logo;
79+
if (await isGroupAllied(groupIdNumber)){ isVerified = true };
7880
} catch (err) {
7981
console.error('Failed to fetch group info during workspace setup:', err);
8082
}
8183

8284
await prisma.workspace.create({
83-
data: { groupId: groupIdNumber, groupName, groupLogo, lastSynced: new Date() },
85+
data: { groupId: groupIdNumber, groupName, groupLogo, lastSynced: new Date(), isVerified, lastSyncedSuccessful: !!opencloudKey },
8486
}).catch((e) => { throw new Error("Failed to create workspace") });
8587

8688
await prisma.$transaction([
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- AlterTable
2+
ALTER TABLE "workspace" ADD COLUMN "isVerified" BOOLEAN DEFAULT false;

prisma/schema.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ model workspace {
1414
lastSyncedSuccessful Boolean? @default(false)
1515
customName String?
1616
memberCount Int?
17+
isVerified Boolean? @default(false)
1718
adjustments ActivityAdjustment[]
1819
activityHistory ActivityHistory[]
1920
activityResets ActivityReset[]

proxy.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ async function checkSetup(request: NextRequest): Promise<boolean> {
4949

5050
try {
5151
const url = internalUrl(request, "/api/admin/first-setup/config");
52-
console.log(`[Middleware] Checking setup at: ${url}`);
5352

5453
const res = await fetch(url, {
5554
cache: 'no-store',

0 commit comments

Comments
 (0)