Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.local
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
WEBAPP_URL = http://localhost:3000

CANNON_URL = https://cannon-staging-dev.sinfo.org/
CANNON_URL = https://cannon-staging-dev.sinfo.org

NEXTAUTH_SECRET = ZlnjlEkgh4hRX41tGPc3glhUMKJd8+HxGWqVe+l7jtA=

Expand Down
17 changes: 12 additions & 5 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
domains: ["static.sinfo.org", "sinfo.ams3.cdn.digitaloceanspaces.com", "sonaesierracms-v2.cdnpservers.net"]
}
}
images: {
domains: [
"static.sinfo.org",
"sinfo.ams3.cdn.digitaloceanspaces.com",
"sonaesierracms-v2.cdnpservers.net",
],
},
experimental: {
instrumentationHook: true,
},
};

module.exports = nextConfig
module.exports = nextConfig;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"autoprefixer": "10.4.15",
"eslint": "8.47.0",
"eslint-config-next": "^14.1.0",
"msw": "^2.6.5",
"next": "^14.1.0",
"next-auth": "^4.23.1",
"postcss": "8.4.28",
Expand Down
4 changes: 2 additions & 2 deletions src/app/(authenticated)/qr/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import convertToAppRole from "@/utils/utils";
export default async function QR() {
const session = await getServerSession(authOptions);

const user: User = await UserService.getMe(session!.cannonToken);
const user: User = await UserService.getMe(session?.cannonToken ?? "");
if (!user) return <UserSignOut />;

let company!: Company | null;
let company: Company | null = null;
if (user.role === "company") {
// assumes that cannon api only provides the company associated with the current edition
if (user.company.length == 0) {
Expand Down
11 changes: 11 additions & 0 deletions src/instrumentation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export async function register() {
if (
process.env.NEXT_RUNTIME == "nodejs" &&
process.env.NODE_ENV == "development"
) {
const { server } = await import("@/mocks/node");
server.listen({
onUnhandledRequest: "bypass",
});
}
}
6 changes: 6 additions & 0 deletions src/mocks/data/company.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const MOCK_COMPANY: Company = {
id: "mock_company_id",
name: "Cloudflare",
advertisementLvl: "max",
img: "https://static.sinfo.org/static%2F30-sinfo%2FcompanyLogos%2FCloudFlare-01.webp",
};
2 changes: 2 additions & 0 deletions src/mocks/data/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./user";
export * from "./company";
14 changes: 14 additions & 0 deletions src/mocks/data/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export const MOCK_USER: User = {
id: "mock_user_id",
name: "Bill Gates",
img: "https://media.licdn.com/dms/image/v2/D5603AQHv6LsdiUg1kw/profile-displayphoto-shrink_400_400/profile-displayphoto-shrink_400_400/0/1695167344576?e=1737590400&v=beta&t=U88-qdsyfBJ_2IjA08tPPNCpAAKXDQ9NbsI-rqoeiNo",
role: "user",
shareLinks: false,
company: [],
signatures: [],
linkShared: [],
bearer: [],
mail: "gatesybill@gmail.com",
registered: "2024-07-21T23:02:19.167Z",
updated: "2024-11-16T23:02:19.167Z",
};
21 changes: 21 additions & 0 deletions src/mocks/handlers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { http, HttpResponse } from "msw";
import { MOCK_USER, MOCK_COMPANY } from "./data";

const BACKEND_URL = process.env.CANNON_URL;

export const handlers = [
http.post(`${BACKEND_URL}/auth/*`, () => {
return HttpResponse.json({
token: "some_cannon_token",
});
}),
http.get(`${BACKEND_URL}/users/me`, () => {
return HttpResponse.json(MOCK_USER);
}),
http.put(`${BACKEND_URL}/users/me`, () => {
return new Response(null, { status: 200 });
}),
http.get(`${BACKEND_URL}/company/*`, () => {
return HttpResponse.json(MOCK_COMPANY);
}),
];
4 changes: 4 additions & 0 deletions src/mocks/node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { setupServer } from "msw/node";
import { handlers } from "./handlers";

export const server = setupServer(...handlers);
Loading