Skip to content

Commit

Permalink
Merge pull request #180 from wizelineacademy/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
pedroalonsoms authored Jun 3, 2024
2 parents 5044ff2 + 411e0b0 commit 2454faa
Show file tree
Hide file tree
Showing 72 changed files with 7,778 additions and 2,443 deletions.
1 change: 1 addition & 0 deletions .github/workflows/compile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
env:
AUTH_SECRET: ${{ secrets.AUTH_SECRET }}
POSTGRES_URL: ${{ secrets.POSTGRES_URL }}
OPENAI_KEY: ${{ secrets.OPENAI_KEY }}

jobs:
build:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
env:
AUTH_SECRET: ${{ secrets.AUTH_SECRET }}
POSTGRES_URL: ${{ secrets.POSTGRES_URL }}
OPENAI_KEY: ${{ secrets.OPENAI_KEY }}

jobs:
build:
Expand Down Expand Up @@ -45,6 +46,7 @@ jobs:
run: |
sst secret set AuthSecret ${{ secrets.AUTH_SECRET }} --stage=prod
sst secret set PostgresURL ${{ secrets.POSTGRES_URL }} --stage=prod
sst secret set OpenAIKey ${{ secrets.OPENAI_KEY }} --stage=prod
- name: Deploy to AWS with SST
run: |
Expand Down
4 changes: 3 additions & 1 deletion actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import { signIn } from "@/auth";
import { registerUser } from "./services/user";
import { DatabaseErrorType } from "./types/errorTypes";
import { DatabaseError } from "pg";
import { redirect } from "next/navigation";

export const loginAction = async (formData: FormData) => {
try {
await signIn("credentials", formData);
redirect("/profile");
} catch (error) {
if (error instanceof AuthError) {
switch (error.type) {
Expand All @@ -34,7 +36,7 @@ export const registerAction = async (formData: FormData) => {
const dbError = e as DatabaseError;

let errorType: DatabaseErrorType;
if (dbError.message === "Email already registered")
if (dbError.message === "Email already registered 23505")
errorType = "UniqueConstraintViolation";
else if (dbError.message === "Error registering the user")
errorType = "ConnectionError";
Expand Down
12 changes: 0 additions & 12 deletions app/(auth)/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,6 @@ const Login = () => {
<p className="mb-4 mt-6 text-center text-3xl font-semibold leading-normal text-black">
Log in to Feedback Flow
</p>
<button className=" group flex w-7/12 flex-row rounded-full border border-primary-light px-4 py-2 transition-all duration-200 hover:bg-primary-dark">
<i className="fi fi-brands-slack text-lg leading-[0px] text-primary-light group-hover:text-white" />
<p className="mx-auto text-sm font-medium text-black group-hover:text-white">
Continue with Slack
</p>
</button>
<button className=" group flex w-7/12 flex-row rounded-full border border-primary-light px-4 py-2 transition-all duration-200 hover:bg-primary-dark">
<i className="fi fi-brands-google text-lg leading-[0px] text-primary-light group-hover:text-white" />
<p className="mx-auto text-sm font-medium text-black group-hover:text-white">
Continue with Google
</p>
</button>
</div>
<div className="flex w-full flex-col items-center justify-center pb-6">
<form
Expand Down
65 changes: 25 additions & 40 deletions app/(base)/dashboard/[userId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,79 +1,64 @@
import React, { Suspense } from "react";
import React from "react";
import { getUserId, getUserManagedBy, getUserInfoById } from "@/services/user";
import UserProfile from "@/components/Dashboard/DashboardProfileLink";
import DashboardGaugeSection from "@/components/Dashboard/DashboardGaugeSection";
import DashboardRadarSection from "@/components/Dashboard/DashboardRadarSection";
import DashboardEmotionsSection from "@/components/Dashboard/DashboardEmotionsSection";
import DashboardSurveyCalendar from "@/components/Dashboard/DashboardSurveyCalendar";
import PCPSection from "@/components/Dashboard/DashboardPCPSection";
import Loader from "@/components/Loader";
import { getRulerGraphInfo } from "@/services/user-dashboard";
import DashboardPCPSection from "@/components/Dashboard/DashboardPCPSection";
import {
getCalendarInfo,
getOverallStatistics,
getPCPStatus,
getProductivityScore,
getRulerGraphInfo,
getSelfPerceptionScore,
getStressScore,
} from "@/services/user-dashboard";

const Dashboard = async ({ params }: { params: { userId: string } }) => {
const activeUserId = await getUserId();
const isManagedBy = await getUserManagedBy(activeUserId, params.userId);
const user = await getUserInfoById(params.userId);
const radarData = await getOverallStatistics(params.userId);

const radarData = [
{ statistic: "Communication", punctuation: 90 },
{ statistic: "Motivation", punctuation: 68 },
{ statistic: "Coworker Support", punctuation: 74 },
{ statistic: "Manager Support", punctuation: 85 },
{ statistic: "Punctuality", punctuation: 89 },
];

const productivityScore = await getProductivityScore(params.userId);
const selfPerceptionScore = await getSelfPerceptionScore(params.userId);
const stressScore = await getStressScore(params.userId);
const gaugeData = [
{
title: "Productivity Level",
percentage: 78,
percentage: productivityScore,
type: "half",
gradient: { start: "#988511", end: "#FEDE1C" },
},
{
title: "Self Perception Level",
percentage: 64,
percentage: selfPerceptionScore,
type: "half",
gradient: { start: "#295A95", end: "#4598FB" },
},
{
title: "Stress Level",
percentage: 56,
percentage: stressScore,
type: "half",
gradient: { start: "#881931", end: "#EE2B55" },
},
];

const PCPData = {
percentage: 63,
type: "full",
gradient: { start: "#4598FB", end: "#6640D5" },
};
const PCPData = await getPCPStatus(params.userId);

const emotionsData = await getRulerGraphInfo(params.userId);
getCalendarInfo(params.userId);

const completedSurveys = [
{ date: new Date(2024, 0, 5), color: "red" },
{ date: new Date(2024, 3, 5), color: "red" },
{ date: new Date(2024, 3, 5), color: "green" },
{ date: new Date(2024, 3, 5), color: "yellow" },
{ date: new Date(2024, 3, 16), color: "yellow" },
{ date: new Date(2024, 3, 23), color: "blue" },
{ date: new Date(2024, 4, 15), color: "blue" },
];

const completedSurveys = await getCalendarInfo(params.userId);
return (
<Suspense
fallback={
<div className="h-[80dvh] w-full">
<Loader />
</div>
}
>
<>
{isManagedBy && (
<UserProfile userId={params.userId} userName={user.name} />
)}

<div className="mt-2 flex justify-between">
<div className="mt-2 flex flex-row justify-between md:flex-row">
<div className="grid gap-7">
<DashboardGaugeSection gaugeData={gaugeData} />
<div className="flex justify-between">
Expand All @@ -83,10 +68,10 @@ const Dashboard = async ({ params }: { params: { userId: string } }) => {
</div>
<div className="mt-4 grid gap-7">
<DashboardSurveyCalendar completedSurveys={completedSurveys} />
<PCPSection PCPData={PCPData} />
<DashboardPCPSection PCPData={PCPData} />
</div>
</div>
</Suspense>
</>
);
};

Expand Down
11 changes: 11 additions & 0 deletions app/(base)/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Loader from "@/components/Loader";

const Loading = () => {
return (
<div className="h-[80dvh] w-full">
<Loader />
</div>
);
};

export default Loading;
Loading

0 comments on commit 2454faa

Please sign in to comment.