Skip to content
Open
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
28 changes: 26 additions & 2 deletions apps/backend/src/bootstrap/loaders/passport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ const CACHE_PREFIX = "user-session:";

const ANONYMOUS_SESSION_TTL = 1000 * 60 * 60 * 12;
const AUTHENTICATED_SESSION_TTL = 1000 * 60 * 60 * 24 * 365;
const DEV_USER_EMAIL = "dev@berkeleytime.local";
const DEV_USER_GOOGLE_ID = "local-dev-user";
const DEV_USER_NAME = "Local Dev User";

export default async (app: Application, redis: RedisClientType) => {
// init
Expand Down Expand Up @@ -205,7 +208,28 @@ export default async (app: Application, redis: RedisClientType) => {
const DEV_LOGIN_ROUTE = "/dev/login";
const DEV_USERS_ROUTE = "/dev/users";

const getOrCreateDevUser = async (userId?: string) => {
if (userId) return await UserModel.findById(userId);

return await UserModel.findOneAndUpdate(
{ email: DEV_USER_EMAIL },
{
$set: {
lastSeenAt: new Date(),
name: DEV_USER_NAME,
staff: true,
},
$setOnInsert: {
email: DEV_USER_EMAIL,
googleId: DEV_USER_GOOGLE_ID,
},
},
{ new: true, upsert: true }
);
};

// GET /dev/login?userId=xxx&redirect_uri=/
// Omitting userId logs in as a deterministic local dev user.
app.get(DEV_LOGIN_ROUTE, async (req, res) => {
const { userId, redirect_uri: redirectURI } = req.query;

Expand All @@ -226,12 +250,12 @@ export default async (app: Application, redis: RedisClientType) => {
res.redirect(redirectWithDevAuthError(reason));
};

if (!userId || typeof userId !== "string") {
if (userId && typeof userId !== "string") {
failDevLogin("invalid_user_id");
return;
}

const user = await UserModel.findById(userId);
const user = await getOrCreateDevUser(userId);
if (!user) {
failDevLogin("user_not_found");
return;
Expand Down
7 changes: 2 additions & 5 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"dependencies": {
"@apollo/client": "4.0.7",
"@floating-ui/dom": "^1.7.4",
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/auto-instrumentations-web": "^0.44.0",
"@opentelemetry/context-zone": "^1.29.0",
Expand All @@ -21,20 +22,17 @@
"@opentelemetry/resources": "^1.29.0",
"@opentelemetry/sdk-trace-base": "^1.29.0",
"@opentelemetry/sdk-trace-web": "^1.29.0",
"@floating-ui/dom": "^1.7.4",
"@mapbox/mapbox-gl-directions": "^4.3.1",
"@repo/BtLL": "*",
"@repo/common": "*",
"@repo/shared": "*",
"@repo/theme": "*",
"@repo/BtLL": "*",
"@shopify/draggable": "^1.1.4",
"@tanstack/react-virtual": "^3.13.12",
"@types/suncalc": "^1.9.2",
"classnames": "^2.5.1",
"framer-motion": "^12.23.24",
"graphql": "^16.11.0",
"iconoir-react": "^7.11.0",
"mapbox-gl": "^3.15.0",
"maplibre-gl": "^5.13.0",
"moment": "^2.30.1",
"patch-package": "^8.0.1",
Expand All @@ -55,7 +53,6 @@
"@repo/gql-typedefs": "*",
"@repo/typescript-config": "*",
"@types/lodash": "^4.17.20",
"@types/mapbox-gl": "^3.4.1",
"@types/node": "^24.7.0",
"@types/react": "^19.2.1",
"@types/react-dom": "^19.2.0",
Expand Down
10 changes: 9 additions & 1 deletion apps/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const Schedule = lazy(() => import("@/app/Schedule"));
const Compare = lazy(() => import("@/app/Schedule/Comparison"));
const Manage = lazy(() => import("@/app/Schedule/Editor"));
const Schedules = lazy(() => import("@/app/Schedules"));
// const Map = lazy(() => import("@/app/Map"));
const Map = lazy(() => import("@/app/Map"));
const GradTrak = lazy(() => import("@/app/GradTrak"));
const GradTrakOnboarding = lazy(() => import("@/app/GradTrak/Onboarding"));
const GradTrakDashboard = lazy(() => import("@/app/GradTrak/Dashboard"));
Expand Down Expand Up @@ -190,6 +190,14 @@ const router = createBrowserRouter([
{
element: <Layout footer={false} scrollLock />,
children: [
{
element: (
<SuspenseBoundary key="map">
<Map />
</SuspenseBoundary>
),
path: "map",
},
{
element: (
<SuspenseBoundary key="profile">
Expand Down
120 changes: 76 additions & 44 deletions apps/frontend/src/app/Map/Map.module.scss
Original file line number Diff line number Diff line change
@@ -1,61 +1,93 @@
.root {
background-color: var(--background-color);
height: calc(100dvh - var(--header-height, 90px));
min-height: 520px;
position: relative;
flex-grow: 1;
display: flex;
flex-direction: column;
overflow: hidden;
}

.selector {
position: absolute;
top: 24px;
left: 50%;
transform: translateX(-50%);
z-index: 2;
padding: 10px 12px;
background-color: var(--foreground-color);
border: 1px solid var(--border-color);
border-radius: 8px;
box-shadow: 0 4px 16px rgba(15, 23, 42, 0.1);

.container {
flex-grow: 1;
label {
display: flex;
align-items: center;
gap: 10px;
}

.menu {
position: absolute;
bottom: 24px;
left: 24px;
z-index: 1;
padding: 12px;
span {
font-size: var(--text-12);
font-weight: var(--font-medium);
color: var(--paragraph-color);
}

select {
min-width: 220px;
max-width: min(360px, 60vw);
border: 1px solid var(--border-color);
background-color: var(--foreground-color);
border-radius: 8px;
display: flex;
gap: 8px;
border-radius: 6px;
background-color: var(--background-color);
color: var(--heading-color);
font: inherit;
font-size: var(--text-14);
padding: 6px 10px;
}
}

@media (max-width: 640px) {
.selector {
width: calc(100% - 32px);

.overlay {
width: 384px;
top: 0;
right: 0;
position: absolute;
background: linear-gradient(to left, var(--background-color), transparent);
height: 100%;
padding: 24px;
pointer-events: none;

.panel {
background-color: var(--foreground-color);
border-radius: 8px;
border: 1px solid var(--border-color);
pointer-events: all;
height: 100%;
label {
justify-content: space-between;
}

select {
min-width: 0;
max-width: 100%;
flex: 1;
}
}
}

.marker {
width: 24px;
height: 24px;
border-radius: 50%;
background-color: var(--blue-500);
.centered {
min-height: calc(100dvh - var(--header-height, 90px));
display: grid;
place-items: center;
color: white;
font-weight: var(--font-medium);
font-size: var(--text-14);
line-height: 1;
border: 1px solid var(--blue-600);
padding: 24px;
background-color: var(--background-color);
}

:global(.mapboxgl-control-container) {
display: none;
.message {
width: min(420px, 100%);
display: flex;
flex-direction: column;
align-items: center;
gap: 14px;
text-align: center;

> svg {
width: 32px;
height: 32px;
color: var(--blue-500);
}

h1 {
font-size: 2rem;
font-weight: var(--font-bold);
color: var(--heading-color);
}

p {
color: var(--paragraph-color);
line-height: 1.5;
}
}
Loading