Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprint survey dynamically #161

Merged
merged 2 commits into from
May 27, 2024
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 components/BannerImagePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import { useState } from "react";
import NextImage from "next/image";
import Banner1 from "@/public/Banner1.svg";

Check failure on line 5 in components/BannerImagePanel.tsx

View workflow job for this annotation

GitHub Actions / build

Cannot find module '@/public/Banner1.svg' or its corresponding type declarations.
import Banner2 from "@/public/Banner2.svg";

Check failure on line 6 in components/BannerImagePanel.tsx

View workflow job for this annotation

GitHub Actions / build

Cannot find module '@/public/Banner2.svg' or its corresponding type declarations.
import Banner3 from "@/public/Banner3.svg";

Check failure on line 7 in components/BannerImagePanel.tsx

View workflow job for this annotation

GitHub Actions / build

Cannot find module '@/public/Banner3.svg' or its corresponding type declarations.
import Banner4 from "@/public/Banner4.svg";

Check failure on line 8 in components/BannerImagePanel.tsx

View workflow job for this annotation

GitHub Actions / build

Cannot find module '@/public/Banner4.svg' or its corresponding type declarations.

const images = [Banner1, Banner2, Banner3, Banner4];

Expand All @@ -17,7 +17,7 @@
};

return (
<div className="container mx-auto pb-2 pt-4">
<div className="mx-auto flex flex-col pb-2 pt-4">
<p className="mb-2 text-grayText">Select an Image</p>
<div className="flex space-x-4">
{images.map((src, index) => (
Expand Down
75 changes: 1 addition & 74 deletions services/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import { projectMember, user, userRoleEnum, project } from "@/db/schema";
import db from "@/db/drizzle";
import * as schema from "@/db/schema";
import { eq, not, and, or, asc, sql, ne, gt } from "drizzle-orm";
import { eq, not, and, or, asc, sql } from "drizzle-orm";
import { alias } from "drizzle-orm/pg-core";
import { auth } from "@/auth";
import bcrypt from "bcrypt";
import { DatabaseError } from "pg";
import { deprecate } from "util";

export async function getUserInfoById(id: string) {
const res = await db
Expand Down Expand Up @@ -180,42 +179,6 @@ export async function getCoWorkers(userId: string | null | undefined) {
return coworkers;
}

const coworker = alias(schema.user, "coworker");
const pmUser = alias(schema.projectMember, "pmUser");
const pmCoworker = alias(schema.projectMember, "pmCoworker");
export async function getCurrentCoworkers(userId: string | null | undefined) {
if (!userId || userId === undefined) {
const session = await auth();
userId = session?.user?.id;
if (!userId) {
throw new Error("You most be signed in");
}
}

const res = await db
.selectDistinct({
id: coworker.id,
name: coworker.name,
email: coworker.email,
jobTitle: coworker.jobTitle,
department: coworker.department,
photoUrl: coworker.photoUrl,
})
.from(pmUser)
.leftJoin(pmCoworker, eq(pmUser.projectId, pmCoworker.projectId))
.leftJoin(coworker, eq(pmCoworker.userId, coworker.id))
.leftJoin(project, eq(pmUser.projectId, project.id))
.where(
and(
eq(pmUser.userId, userId),
ne(pmUser.userId, pmCoworker.userId),
gt(project.endDate, sql`CURRENT_TIMESTAMP`),
),
);

return res;
}

export async function getProjectsProfile(userId: string | null | undefined) {
if (!userId || userId === undefined) {
const session = await auth();
Expand Down Expand Up @@ -247,42 +210,6 @@ export async function getProjectsProfile(userId: string | null | undefined) {
return res;
}

export async function getCurrentProjectsProfile(
userId: string | null | undefined,
) {
if (!userId || userId === undefined) {
const session = await auth();
userId = session?.user?.id;
if (!userId) {
throw new Error("You most be signed in");
}
}

const res = await db
.selectDistinctOn([schema.project.id], {
id: schema.project.id,
name: schema.project.name,
description: schema.project.description,
startDate: schema.project.startDate,
endDate: schema.project.endDate,
})
.from(schema.projectMember)
.innerJoin(
schema.project,
eq(schema.projectMember.projectId, schema.project.id),
)
.where(
and(
or(
eq(schema.projectMember.userId, userId),
eq(schema.project.managerId, userId),
),
gt(project.endDate, sql`CURRENT_TIMESTAMP`),
),
);
return res;
}

export async function getAllEmployees() {
const res = await db
.select({
Expand Down
Loading