Skip to content

Commit

Permalink
Merge pull request #270 from chingu-x/dev
Browse files Browse the repository at this point in the history
1.0.0-alpha.6
  • Loading branch information
Dan-Y-Ko authored Sep 30, 2024
2 parents 13d2836 + 2169bc2 commit 0203908
Show file tree
Hide file tree
Showing 18 changed files with 167 additions and 74 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/).


## [1.0.0-alpha.6] - 2024-09-27

### Added
- Added po and sm forms for the weekly checkin for the appropriate teams https://github.com/chingu-x/chingu-dashboard/issues/216

### Changed
- Changed how we're accessing meeting data to match changes in backend https://github.com/chingu-x/chingu-dashboard/pull/269
- Updated dropdown menu in top nav https://github.com/chingu-x/chingu-dashboard/issues/261


### Fixed

## [1.0.0-alpha.5] - 2024-09-19

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export const getDashboardData = async (
.map((sprint) =>
fetchMeeting({
sprintNumber: sprint.number,
meetingId: sprint.teamMeetings[0]?.id,
meetingId: sprint.teamMeetings[0],
}),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import ErrorComponent from "@/components/Error";
function getMeeting(sprints: Sprint[], sprintNumber: number) {
const sprint = sprints.find((sprint) => sprint.number === sprintNumber);

if (sprint?.teamMeetings && sprint?.teamMeetings.length > 0)
return sprint.teamMeetings[0];
if (sprint?.teamMeetingsData && sprint?.teamMeetingsData.length > 0)
return sprint.teamMeetingsData[0];
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function ProgressStepper({

function handleClick(sprintNumber: number) {
const meetingId = sprints.find((sprint) => sprint.number === sprintNumber)!
.teamMeetings[0]?.id;
.teamMeetings[0];

if (meetingId) {
router.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export default async function RedirectToCurrentSprintWrapper({
const teamId = Number(params.teamId);

let currentSprintNumber: number;
let currentMeetingId: number;

const [user, error] = await getUser();

Expand Down Expand Up @@ -110,12 +109,12 @@ export default async function RedirectToCurrentSprintWrapper({
);
}
const { teamMeetings, number } = getCurrentSprint(res!.sprints) as Sprint;

currentSprintNumber = number;
currentMeetingId = teamMeetings[0]?.id;

if (currentMeetingId) {
if (teamMeetings.length !== 0) {
redirect(
`/my-voyage/${teamId}/sprints/${currentSprintNumber}/meeting/${currentMeetingId}`,
`/my-voyage/${teamId}/sprints/${currentSprintNumber}/meeting/${teamMeetings[0]}`,
);
} else {
redirect(`/my-voyage/${teamId}/sprints/${currentSprintNumber}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export default async function SprintWrapper({ params }: SprintWrapperProps) {

const correspondingMeetingId = voyageData.sprints.find(
(sprint) => sprint.number === sprintNumber,
)?.teamMeetings[0]?.id;
)?.teamMeetings[0];

if (meetingId === correspondingMeetingId) {
const [res, error] = await fetchMeeting({ sprintNumber, meetingId });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { CacheTag } from "@/utils/cacheTag";
import { type AsyncActionResponse, handleAsync } from "@/utils/handleAsync";
import { getCurrentVoyageData } from "@/utils/getCurrentVoyageData";
import routePaths from "@/utils/routePaths";
import { Forms } from "@/utils/form/formsEnums";
import { Forms, UserRole } from "@/utils/form/formsEnums";
import { type Question, type TeamMemberForCheckbox } from "@/utils/form/types";
import { getSprintCheckinIsStatus } from "@/utils/getFormStatus";
import { getCurrentSprint } from "@/utils/getCurrentSprint";
Expand Down Expand Up @@ -75,6 +75,11 @@ export default async function WeeklyCheckInWrapper({
let description = "";
let questions = [] as Question[];

let hasProductOwner = false;
let hasScrumMaster = false;
let isScrumMaster = false;
let isProductOwner = false;

const [user, error] = await getUser();

const { errorResponse, data } = await getCurrentVoyageData({
Expand Down Expand Up @@ -141,6 +146,25 @@ export default async function WeeklyCheckInWrapper({
}).voyageTeamMemberId;
}

// Check if a team has a product owner or a scrum muster and if a user is a team has a product owner or a scrum muster
hasScrumMaster = !!res.voyageTeamMembers.find(
(member) =>
member.voyageRole.name === UserRole.scrumMaster.toString(),
);

hasProductOwner = !!res.voyageTeamMembers.find(
(member) =>
member.voyageRole.name === UserRole.productOwner.toString(),
);

const currentUserRole = res.voyageTeamMembers.find(
(member) => member.id === voyageTeamMemberId,
)?.voyageRole.name;

isScrumMaster = currentUserRole === UserRole.scrumMaster.toString();

isProductOwner = currentUserRole === UserRole.productOwner.toString();

// Get all teamMembers except for the current user
if (voyageTeamMemberId) {
teamMembers = res.voyageTeamMembers
Expand All @@ -163,7 +187,7 @@ export default async function WeeklyCheckInWrapper({
);
}

// Fetch form
// Fetch general checkin form
const [formRes, formError] = await fetchFormQuestions({
formId: Forms.checkIn,
});
Expand All @@ -176,8 +200,49 @@ export default async function WeeklyCheckInWrapper({
/>
);
}

if (formRes && formRes?.description) description = formRes.description;
if (formRes && formRes?.questions) questions = formRes.questions;

// Fetch PO checkin questions (form)
if (hasProductOwner && !isProductOwner) {
const [POformRes, POformError] = await fetchFormQuestions({
formId: Forms.checkinPO,
});

if (POformError) {
return (
<ErrorComponent
errorType={ErrorType.FETCH_FORM_QUESTIONS}
message={POformError.message}
/>
);
}

if (POformRes && POformRes?.questions)
questions = [...questions, ...POformRes.questions];
}

// Fetch SM checkin questions (form)
if (hasScrumMaster && !isScrumMaster) {
const [SMformRes, SMformError] = await fetchFormQuestions({
formId: Forms.checkinSM,
});

if (SMformError) {
return (
<ErrorComponent
errorType={ErrorType.FETCH_FORM_QUESTIONS}
message={SMformError.message}
/>
);
}

if (SMformRes && SMformRes?.questions)
questions = [...questions, ...SMformRes.questions];
}

questions = questions.sort((a, b) => a.order - b.order);
}
} else {
redirect(routePaths.dashboardPage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,13 @@ export default function AgendaTopicForm() {

useEffect(() => {
if (sprintNumber && agendaId) {
const topic = sprints
.find((sprint) => sprint.number === sprintNumber)
?.teamMeetings[0].agendas?.find((topic) => topic.id === agendaId);
const sprint = sprints.find((sprint) => sprint.number === sprintNumber);

const topic =
sprint?.teamMeetingsData &&
sprint.teamMeetingsData[0].agendas?.find(
(topic) => topic.id === agendaId,
);

setTopicData(topic);
setEditMode(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ export default function MeetingForm() {
useEffect(() => {
if (params.meetingId) {
const meeting = sprints.find(
(sprint) => sprint.teamMeetings[0]?.id === +params.meetingId,
)?.teamMeetings[0];
(sprint) =>
sprint.teamMeetingsData &&
sprint.teamMeetingsData[0].id === +params.meetingId,
);

setMeetingData(meeting as Meeting);
setEditMode(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ export default function Notes() {
} = useSprint();

useEffect(() => {
setData(sprints[sprintNumber - 1].teamMeetings[0].notes);
const sprint = sprints[sprintNumber - 1];
if (sprint.teamMeetingsData && sprint.teamMeetingsData.length) {
setData(sprint.teamMeetingsData[0].notes);
}
}, [sprints, sprintNumber]);

const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ export default function Planning() {
} = useSprint();

useEffect(() => {
setData(
sprints[sprintNumber - 1].teamMeetings[0].formResponseMeeting?.find(
(form) => form.form.id === Number(Forms.planning),
),
);
const sprint = sprints[sprintNumber - 1];
if (sprint.teamMeetingsData && sprint.teamMeetingsData.length) {
setData(
sprint.teamMeetingsData[0].formResponseMeeting?.find(
(form) => form.form.id === Number(Forms.planning),
),
);
}
}, [sprints, sprintNumber]);

const goal = data?.responseGroup.responses.find(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,14 @@ export default function Review() {
} = useSprint();

useEffect(() => {
setData(
sprints[sprintNumber - 1].teamMeetings[0].formResponseMeeting?.find(
(form) => form.form.id === Number(Forms.review),
),
);
const sprint = sprints[sprintNumber - 1];
if (sprint.teamMeetingsData && sprint.teamMeetingsData.length) {
setData(
sprint.teamMeetingsData[0].formResponseMeeting?.find(
(form) => form.form.id === Number(Forms.review),
),
);
}
}, [sprints, sprintNumber]);

const what_right = data?.responseGroup.responses.find(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export interface SprintsResponse {
number: number;
startDate: string;
endDate: string;
teamMeetings: { id: number }[];
teamMeetings: number[];
}[];
}

Expand Down
50 changes: 33 additions & 17 deletions src/components/navbar/DropDown.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { ChevronDownIcon } from "@heroicons/react/24/outline";
import DropDownLink from "./DropDownLink";
import Link from "next/link";
import Button from "@/components/Button";
import { useAppDispatch, useUser } from "@/store/hooks";
import { clientSignOut } from "@/store/features/auth/authSlice";
Expand All @@ -14,12 +14,18 @@ export default function DropDown({ openState }: { openState?: boolean }) {
const activeVoyage = allVoyages?.find(
(item) => item.voyageTeam.voyage.status.name === "Active",
);
const currentVoyage =
activeVoyage?.voyageTeam.name ??
"Please join a voyage to see your status information.";

const currentVoyage = activeVoyage?.voyageTeam.name
? `Team - Tier ${activeVoyage.voyageTeam.name
.split("-")[1]
.split("tier")[1]
.toUpperCase()} ${activeVoyage.voyageTeam.name
.split("-")[0]
.toUpperCase()}`
: "Please join a voyage to see your status information.";
const closed = "hidden";
const open =
"absolute z-[1] w-44 p-4 [&>*]:mt-2 mt-6 shadow bg-base-100 right-0 border border-neutral rounded-2xl";
"absolute flex flex-col gap-5 z-[1] w-[250px] p-5 bottom-100 translate-y-[15%] shadow-md bg-base-200 right-0 border border-base-100 rounded-2xl";

async function handleClick() {
const [res, error] = await serverSignOut();
Expand All @@ -35,7 +41,7 @@ export default function DropDown({ openState }: { openState?: boolean }) {
}
}

const handleDropDownClick = (event: React.MouseEvent<HTMLUListElement>) => {
const handleDropDownClick = (event: React.MouseEvent<HTMLDivElement>) => {
event.stopPropagation();
};

Expand All @@ -47,35 +53,45 @@ export default function DropDown({ openState }: { openState?: boolean }) {
>
<ChevronDownIcon className="w-4 cursor-pointer text-base-300" />
</label>
<ul
<div
tabIndex={0}
className={openState ? open : closed}
onClick={handleDropDownClick}
>
<li className="rounded-lg bg-secondary-content p-2 text-xs [&>*]:m-1">
<p className="text-xs text-neutral">My Status:</p>
{currentVoyage ? (
<p className="border border-transparent font-semibold text-base-300">
<div className="rounded-lg bg-secondary-content p-2 text-xs [&>*]:m-1">
<p className="text-[10px] font-medium text-neutral-focus">
My Voyage:
</p>
{activeVoyage?.voyageTeam.name ? (
<p className="border border-transparent text-base font-medium text-base-300">
{currentVoyage}
</p>
) : (
<p className="border-transparent font-semibold text-base-300">
{currentVoyage}
</p>
)}
</li>
<DropDownLink title="Settings" href="/hello404" />
</div>
<Link href="/hello404">
<Button
type="button"
variant="link"
size="lg"
className="m-0 flex w-full justify-start p-2 hover:bg-base-100 hover:text-base-300"
>
Settings
</Button>
</Link>
<Button
title="signout"
type="button"
onClick={handleClick}
variant="link"
size={"lg"}
className="m-0 flex w-full justify-start p-2 hover:bg-neutral-content hover:text-base-300"
size="lg"
className="m-0 flex w-full justify-start p-2 hover:bg-base-100 hover:text-base-300"
>
Sign Out
</Button>
</ul>
</div>
</div>
);
}
19 changes: 0 additions & 19 deletions src/components/navbar/DropDownLink.tsx

This file was deleted.

Loading

0 comments on commit 0203908

Please sign in to comment.