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

Feature/sprints pt5 #159

Merged
merged 19 commits into from
Jul 12, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ yarn-error.log*
# local env files
.env*.local
.env
.env.production

# vercel
.vercel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
getSprintCheckinIsStatus,
getVoyageProjectStatus,
} from "@/utils/getFormStatus";
import { getCurrentVoyageTeam } from "@/utils/getCurrentVoyageTeam";
import { ErrorType } from "@/utils/error";
import ErrorComponent from "@/components/Error";

Expand Down Expand Up @@ -45,6 +46,16 @@ export default async function EmptySprintWrapper({

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

const { currentTeam, projectSubmitted } = getCurrentVoyageTeam({
teamId,
user,
error: null,
});

if (currentTeam && projectSubmitted) {
redirect(`/my-voyage/${teamId}/sprints/`);
}

const { errorResponse, data } = await getCurrentVoyageData({
user,
error,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { redirect } from "next/navigation";

import VoyageSubmittedMessage from "./VoyageSubmittedMessage";

import {
type FetchSprintsProps,
type FetchSprintsResponse,
type SprintsResponse,
} from "@/myVoyage/sprints/sprintsService";

import VoyagePageBannerContainer from "@/components/banner/VoyagePageBannerContainer";
import Banner from "@/components/banner/Banner";

import { getAccessToken } from "@/utils/getCookie";
import { getUser } from "@/utils/getUser";
import { getCurrentSprint } from "@/utils/getCurrentSprint";
Expand All @@ -15,6 +20,7 @@ import { type AsyncActionResponse, handleAsync } from "@/utils/handleAsync";
import { type Sprint } from "@/store/features/sprint/sprintSlice";
import { getCurrentVoyageData } from "@/utils/getCurrentVoyageData";
import routePaths from "@/utils/routePaths";
import { getCurrentVoyageTeam } from "@/utils/getCurrentVoyageTeam";
import { ErrorType } from "@/utils/error";
import ErrorComponent from "@/components/Error";

Expand Down Expand Up @@ -49,6 +55,32 @@ export default async function RedirectToCurrentSprintWrapper({

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

const { currentTeam, projectSubmitted } = getCurrentVoyageTeam({
teamId,
user,
error: null,
});

if (currentTeam && projectSubmitted) {
return (
<div className="flex w-full flex-col gap-y-10">
<VoyagePageBannerContainer
title="Sprints"
description="A sprint agenda helps the team stay on track, communicate well, and improve. Basically, it's like speed dating for developers. Except we're not looking for a soulmate, we're just trying to get some quality work done."
>
<Banner
imageLight="/img/sprints_banner_light.png"
imageDark="/img/sprints_banner_dark.png"
alt="sprints_banner"
height="h-[200px]"
width="w-[276px]"
/>
</VoyagePageBannerContainer>
<VoyageSubmittedMessage />
</div>
);
}

const { errorResponse, data } = await getCurrentVoyageData({
user,
error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,6 @@ export default function SprintActions({

function renderSubmitVoyageButton() {
if (submitVoyageIsAllowed) {
return (
<Button
variant="secondary"
size="lg"
className="group"
disabled={false}
>
<RocketLaunchIcon className="h-[18px] w-[18px]" />
Submit Voyage
<ArrowRightIcon className="h-[18px] w-0 transition-all group-hover:w-[18px]" />
</Button>
);
} else {
if (voyageProjectIsSubmitted) {
return (
<Button
Expand All @@ -96,7 +83,7 @@ export default function SprintActions({
className="group"
disabled={true}
>
<RocketLaunchIcon className="h-[18px] w-[18px]" />
<SolidRocketLaunchIcon className="h-[18px] w-[18px]" />
Voyage Submitted
</Button>
);
Expand All @@ -106,13 +93,21 @@ export default function SprintActions({
variant="secondary"
size="lg"
className="group"
disabled={true}
disabled={false}
>
<SolidRocketLaunchIcon className="h-[18px] w-[18px]" />
<RocketLaunchIcon className="h-[18px] w-[18px]" />
Submit Voyage
<ArrowRightIcon className="h-[18px] w-0 transition-all group-hover:w-[18px]" />
</Button>
);
}
} else {
return (
<Button variant="secondary" size="lg" className="group" disabled={true}>
<SolidRocketLaunchIcon className="h-[18px] w-[18px]" />
{voyageProjectIsSubmitted ? "Voyage Submitted" : "Submit Voyage"}
</Button>
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
getSprintCheckinIsStatus,
getVoyageProjectStatus,
} from "@/utils/getFormStatus";
import { getCurrentVoyageTeam } from "@/utils/getCurrentVoyageTeam";
import { ErrorType } from "@/utils/error";
import ErrorComponent from "@/components/Error";

Expand Down Expand Up @@ -77,6 +78,18 @@ export default async function SprintWrapper({ params }: SprintWrapperProps) {

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

// Check if it's a current team and if a project's been submitted,
// redirect to /sprints page where a corresponding messsage is rendered
const { currentTeam, projectSubmitted } = getCurrentVoyageTeam({
teamId,
user,
error: null,
});

if (currentTeam && projectSubmitted) {
redirect(`/my-voyage/${teamId}/sprints/`);
}

const { errorResponse, data } = await getCurrentVoyageData({
user,
error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function Sections({
id: Forms.notes,
title: "notes",
icon: <DocumentTextIcon aria-hidden="true" />,
isAdded: notes !== undefined,
isAdded: notes !== null,
children: <Notes data={notes} />,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ export async function submitVoyageProjectForm({

const editSectionAsync = () =>
POST<SubmitVoyageFormBody, SubmitVoyageFormResponse>(
"api/v1/voyages/sprints/submit-project",
"api/v1/voyages/submit-project",
token,
"default",
{ voyageTeamId, responses },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const CheckboxGroupItem = React.forwardRef<
className="peer hidden"
/>
<span className="flex h-6 w-6 items-center justify-center rounded border border-neutral/40 bg-base-200 transition-all group-hover:bg-base-100 peer-checked:border-base-300 group-hover:peer-checked:border-neutral-content [&>*]:hidden [&>*]:text-base-300 peer-checked:[&>*]:block group-hover:peer-checked:[&>*]:text-neutral-content">
<CheckIcon className="hidden transition-all" />
<CheckIcon className="hidden h-full w-full transition-all" />
</span>
<span className="transition-all peer-checked:text-base-300">{label}</span>
</Label>
Expand Down
1 change: 1 addition & 0 deletions src/utils/getCurrentSprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export function getCurrentSprint(sprints: Sprint[]) {
end: sprint.endDate,
}),
);

return currentSprint;
}
3 changes: 3 additions & 0 deletions src/utils/getCurrentVoyageTeam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export function getCurrentVoyageTeam({
let err = "";
let currentTeam = false;
let voyageTeamMemberId: number = 0;
let projectSubmitted: boolean = false;

if (user) {
currentVoyageTeam = user.voyageTeamMembers.find(
Expand All @@ -32,6 +33,7 @@ export function getCurrentVoyageTeam({

if (currentVoyageTeam) {
voyageTeamMemberId = currentVoyageTeam.id;
projectSubmitted = currentVoyageTeam.voyageTeam.projectSubmitted;
}

if (teamId === currentVoyageTeam?.voyageTeamId) {
Expand All @@ -48,5 +50,6 @@ export function getCurrentVoyageTeam({
currentTeam,
isStarted,
voyageTeamMemberId,
projectSubmitted,
};
}
Loading