Skip to content

Commit

Permalink
missions -> training plans
Browse files Browse the repository at this point in the history
  • Loading branch information
xvvvyz committed Sep 3, 2024
1 parent 3c7d6aa commit 90ee87a
Show file tree
Hide file tree
Showing 46 changed files with 636 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ import SessionPage from '@/_components/session-page';

interface PageProps {
params: {
missionId: string;
trainingPlanId: string;
sessionId: string;
subjectId: string;
};
}

const Page = async ({
params: { missionId, sessionId, subjectId },
params: { sessionId, subjectId, trainingPlanId },
}: PageProps) => (
<SessionPage
isPublic
missionId={missionId}
sessionId={sessionId}
subjectId={subjectId}
trainingPlanId={trainingPlanId}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ import SessionsPage from '@/_components/sessions-page';

interface PageProps {
params: {
missionId: string;
subjectId: string;
trainingPlanId: string;
};
}

const Page = ({ params: { missionId, subjectId } }: PageProps) => (
<SessionsPage isPublic missionId={missionId} subjectId={subjectId} />
const Page = ({ params: { subjectId, trainingPlanId } }: PageProps) => (
<SessionsPage
isPublic
subjectId={subjectId}
trainingPlanId={trainingPlanId}
/>
);

export default Page;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ import getTrainingPlan from '@/_queries/get-training-plan';

interface PageProps {
params: {
missionId: string;
subjectId: string;
trainingPlanId: string;
};
}

const Page = async ({ params: { missionId, subjectId } }: PageProps) => {
const Page = async ({ params: { subjectId, trainingPlanId } }: PageProps) => {
const [{ data: subject }, { data: mission }] = await Promise.all([
getSubject(subjectId),
getTrainingPlan(missionId),
getTrainingPlan(trainingPlanId),
]);

if (!subject || !mission) return null;

return (
<Modal.Content>
<PageModalHeader title="Edit training plan name" />
<TrainingPlanForm mission={mission} subjectId={subjectId} />
<TrainingPlanForm trainingPlan={mission} subjectId={subjectId} />
</Modal.Content>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,44 @@ import listTemplatesWithData from '@/_queries/list-templates-with-data';

interface PageProps {
params: {
missionId: string;
order: string;
sessionId: string;
subjectId: string;
trainingPlanId: string;
};
}

const Page = async ({
params: { missionId, sessionId, subjectId },
params: { sessionId, subjectId, trainingPlanId },
}: PageProps) => {
const [
{ data: availableInputs },
{ data: availableModuleTemplates },
{ data: availableSessionTemplates },
{ data: mission },
{ data: session },
{ data: subject },
{ data: subjects },
{ data: trainingPlan },
user,
] = await Promise.all([
listInputsBySubjectId(subjectId),
listTemplatesWithData({ type: TemplateType.Module }),
listTemplatesWithData({ type: TemplateType.Session }),
getTrainingPlanWithSessions(missionId, { draft: true }),
getSession(sessionId),
getSubject(subjectId),
listSubjectsByTeamId(),
getTrainingPlanWithSessions(trainingPlanId, { draft: true }),
getCurrentUser(),
]);

if (
!availableInputs ||
!availableModuleTemplates ||
!availableSessionTemplates ||
!mission ||
!session ||
!subject ||
!subjects ||
!trainingPlan ||
!user ||
subject.team_id !== user.id
) {
Expand All @@ -59,10 +59,10 @@ const Page = async ({
availableInputs={availableInputs}
availableModuleTemplates={availableModuleTemplates}
availableSessionTemplates={availableSessionTemplates}
mission={mission}
session={session}
subjectId={subjectId}
subjects={subjects}
trainingPlan={trainingPlan}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import SessionPage from '@/_components/session-page';

interface PageProps {
params: {
missionId: string;
sessionId: string;
subjectId: string;
trainingPlanId: string;
};
}

const Page = async ({
params: { missionId, sessionId, subjectId },
params: { sessionId, subjectId, trainingPlanId },
}: PageProps) => (
<SessionPage
missionId={missionId}
sessionId={sessionId}
subjectId={subjectId}
trainingPlanId={trainingPlanId}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,44 @@ import listTemplatesWithData from '@/_queries/list-templates-with-data';

interface PageProps {
params: {
missionId: string;
order: string;
sessionId: string;
subjectId: string;
trainingPlanId: string;
};
}

const Page = async ({
params: { missionId, order, sessionId, subjectId },
params: { order, sessionId, subjectId, trainingPlanId },
}: PageProps) => {
const [
{ data: availableInputs },
{ data: availableModuleTemplates },
{ data: availableSessionTemplates },
{ data: mission },
{ data: session },
{ data: subject },
{ data: subjects },
{ data: trainingPlan },
user,
] = await Promise.all([
listInputsBySubjectId(subjectId),
listTemplatesWithData({ type: TemplateType.Module }),
listTemplatesWithData({ type: TemplateType.Session }),
getTrainingPlanWithSessions(missionId, { draft: true }),
getSession(sessionId),
getSubject(subjectId),
listSubjectsByTeamId(),
getTrainingPlanWithSessions(trainingPlanId, { draft: true }),
getCurrentUser(),
]);

if (
!availableInputs ||
!availableModuleTemplates ||
!availableSessionTemplates ||
!mission ||
!session ||
!subject ||
!subjects ||
!trainingPlan ||
!user ||
subject.team_id !== user.id
) {
Expand All @@ -60,11 +60,11 @@ const Page = async ({
availableModuleTemplates={availableModuleTemplates}
availableSessionTemplates={availableSessionTemplates}
isDuplicate
mission={mission}
order={order}
session={session}
subjectId={subjectId}
subjects={subjects}
trainingPlan={trainingPlan}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,40 @@ import listTemplatesWithData from '@/_queries/list-templates-with-data';

interface PageProps {
params: {
missionId: string;
order: string;
subjectId: string;
trainingPlanId: string;
};
}

const Page = async ({ params: { missionId, order, subjectId } }: PageProps) => {
const Page = async ({
params: { order, subjectId, trainingPlanId },
}: PageProps) => {
const [
{ data: availableInputs },
{ data: availableModuleTemplates },
{ data: availableSessionTemplates },
{ data: mission },
{ data: subject },
{ data: subjects },
{ data: trainingPlan },
user,
] = await Promise.all([
listInputsBySubjectId(subjectId),
listTemplatesWithData({ type: TemplateType.Module }),
listTemplatesWithData({ type: TemplateType.Session }),
getTrainingPlanWithSessions(missionId, { draft: true }),
getSubject(subjectId),
listSubjectsByTeamId(),
getTrainingPlanWithSessions(trainingPlanId, { draft: true }),
getCurrentUser(),
]);

if (
!subject ||
!mission ||
!subjects ||
!availableInputs ||
!availableModuleTemplates ||
!availableSessionTemplates ||
!subject ||
!subjects ||
!trainingPlan ||
!user ||
subject.team_id !== user.id
) {
Expand All @@ -52,10 +54,10 @@ const Page = async ({ params: { missionId, order, subjectId } }: PageProps) => {
availableInputs={availableInputs}
availableModuleTemplates={availableModuleTemplates}
availableSessionTemplates={availableSessionTemplates}
mission={mission}
order={order}
subjectId={subjectId}
subjects={subjects}
trainingPlan={trainingPlan}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import SessionsPage from '@/_components/sessions-page';

interface PageProps {
params: {
subjectId: string;
trainingPlanId: string;
};
}

const Page = ({ params: { subjectId, trainingPlanId } }: PageProps) => (
<SessionsPage subjectId={subjectId} trainingPlanId={trainingPlanId} />
);

export default Page;
2 changes: 1 addition & 1 deletion app/_components/event-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const EventPage = async ({ eventId, isPublic, subjectId }: EventPageProps) => {
{event.type.session && (
<Button
className="pt-4"
href={`/${shareOrSubjects}/${subjectId}/training-plans/${event.type.session.mission?.id}/sessions/${event.type.session.id}`}
href={`/${shareOrSubjects}/${subjectId}/training-plans/${event.type.session.training_plan?.id}/sessions/${event.type.session.id}`}
scroll={false}
variant="link"
>
Expand Down
6 changes: 3 additions & 3 deletions app/_components/module-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface ModuleCardProps {
isPreviousModulePending?: boolean;
isPublic?: boolean;
isTeamMember?: boolean;
mission: NonNullable<GetTrainingPlanWithSessionsData>;
trainingPlan: NonNullable<GetTrainingPlanWithSessionsData>;
subjectId: string;
user?: User | null;
}
Expand All @@ -39,7 +39,7 @@ const ModuleCard = ({
isPreviousModulePending,
isPublic,
isTeamMember,
mission,
trainingPlan,
subjectId,
user,
}: ModuleCardProps) => {
Expand Down Expand Up @@ -109,7 +109,7 @@ const ModuleCard = ({
event={event}
eventType={eventType}
isArchived={isArchived}
isMission={!!mission}
isMission={!!trainingPlan}
isPreviousModulePending={isPreviousModulePending}
isPublic={isPublic}
subjectId={subjectId}
Expand Down
2 changes: 1 addition & 1 deletion app/_components/notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const Notifications = ({ notifications }: NotificationsProps) => {
? 'completed a'
: 'recorded')}{' '}
<span className="text-fg-2">
{sourceEvent?.type?.session?.mission?.name ??
{sourceEvent?.type?.session?.training_plan?.name ??
sourceEvent?.type?.name}
</span>
{sourceEvent?.type?.session && (
Expand Down
Loading

0 comments on commit 90ee87a

Please sign in to comment.