Skip to content

Commit

Permalink
add session templates, various ui/ux improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
xvvvyz committed Aug 27, 2024
1 parent 026d56c commit a6f2855
Show file tree
Hide file tree
Showing 99 changed files with 1,162 additions and 1,034 deletions.
4 changes: 1 addition & 3 deletions app/(pages)/(with-nav)/inputs/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import Empty from '@/_components/empty';
import FilterableInputs from '@/_components/filterable-inputs';
import listInputs from '@/_queries/list-inputs';
import InformationCircleIcon from '@heroicons/react/24/outline/ExclamationCircleIcon';
import InformationCircleIcon from '@heroicons/react/24/outline/InformationCircleIcon';
import { sortBy } from 'lodash';

export const metadata = { title: 'Inputs' };

const Page = async () => {
const { data: inputs } = await listInputs();

Expand Down
2 changes: 0 additions & 2 deletions app/(pages)/(with-nav)/notifications/[tab]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ interface PageProps {
};
}

export const metadata = { title: 'Notifications' };

const Page = async ({ params: { tab } }: PageProps) => {
if (!['archive', 'inbox'].includes(tab)) return null;

Expand Down
2 changes: 0 additions & 2 deletions app/(pages)/(with-nav)/subjects/(list)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import listSubjects, { ListSubjectsData } from '@/_queries/list-subjects';
import InformationCircleIcon from '@heroicons/react/24/outline/InformationCircleIcon';
import PlusIcon from '@heroicons/react/24/outline/PlusIcon';

export const metadata = { title: 'Subjects' };

const Page = async () => {
const [{ data: subjects }, user] = await Promise.all([
listSubjects(),
Expand Down
3 changes: 0 additions & 3 deletions app/(pages)/(with-nav)/subjects/[subjectId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import SubjectPage from '@/_components/subject-page';
import formatTitle from '@/_utilities/format-title';

interface PageProps {
params: { subjectId: string };
searchParams: { from?: string; limit?: string; to?: string };
}

export const metadata = { title: formatTitle(['Subjects', 'Events']) };

const Page = ({
params: { subjectId },
searchParams: { from, limit, to },
Expand Down
30 changes: 19 additions & 11 deletions app/(pages)/(with-nav)/templates/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,34 @@ const Layout = ({ children }: LayoutProps) => (
<DropdownMenu.Trigger>
<Button size="sm">
New&hellip;
<ChevronDownIcon className="-mr-0.5 w-5 stroke-2" />
<ChevronDownIcon className="-mr-1 w-5 stroke-2" />
</Button>
</DropdownMenu.Trigger>
<DropdownMenu.Portal>
<DropdownMenu.Content>
<DropdownMenu.Button href="/templates/event-types/create">
<PlusIcon className="w-5 text-fg-4" />
Event type template
<div>
Event type <span className="text-fg-4">template</span>
</div>
</DropdownMenu.Button>
<DropdownMenu.Button href="/templates/training-plans/create">
<PlusIcon className="w-5 text-fg-4" />
<div>
Training plan <span className="text-fg-4">template</span>
</div>
</DropdownMenu.Button>
<DropdownMenu.Button href="/templates/sessions/create">
<PlusIcon className="w-5 text-fg-4" />
<div>
Session <span className="text-fg-4">template</span>
</div>
</DropdownMenu.Button>
{/*<DropdownMenu.Button>*/}
{/* <PlusIcon className="w-5 text-fg-4" />*/}
{/* Training plan template*/}
{/*</DropdownMenu.Button>*/}
{/*<DropdownMenu.Button>*/}
{/* <PlusIcon className="w-5 text-fg-4" />*/}
{/* Session template*/}
{/*</DropdownMenu.Button>*/}
<DropdownMenu.Button href="/templates/modules/create">
<PlusIcon className="w-5 text-fg-4" />
Module template
<div>
Module <span className="text-fg-4">template</span>
</div>
</DropdownMenu.Button>
</DropdownMenu.Content>
</DropdownMenu.Portal>
Expand Down
6 changes: 2 additions & 4 deletions app/(pages)/(with-nav)/templates/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import Empty from '@/_components/empty';
import FilterableTemplates from '@/_components/filterable-templates';
import listTemplates from '@/_queries/list-templates';
import InformationCircleIcon from '@heroicons/react/24/outline/ExclamationCircleIcon';

export const metadata = { title: 'Templates' };
import InformationCircleIcon from '@heroicons/react/24/outline/InformationCircleIcon';

const Page = async () => {
const { data: templates } = await listTemplates();
Expand All @@ -14,7 +12,7 @@ const Page = async () => {
<InformationCircleIcon className="w-7" />
Templates define reusable content for
<br />
event types and session modules.
event types and training plans.
</Empty>
);
}
Expand Down
2 changes: 0 additions & 2 deletions app/(pages)/@modal/(layout)/account/(layout)/[tab]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ interface PageProps {
};
}

export const metadata = { title: 'Account' };

const Page = async ({ params: { tab } }: PageProps) => {
const user = await getCurrentUser();
if (!user || !['email', 'password', 'profile'].includes(tab)) return null;
Expand Down
3 changes: 0 additions & 3 deletions app/(pages)/@modal/(layout)/inputs/[inputId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ import * as Modal from '@/_components/modal';
import PageModalHeader from '@/_components/page-modal-header';
import getInput from '@/_queries/get-input';
import listSubjectsByTeamId from '@/_queries/list-subjects-by-team-id';
import formatTitle from '@/_utilities/format-title';

interface PageProps {
params: {
inputId: string;
};
}

export const metadata = { title: formatTitle(['Inputs', 'Edit']) };

const Page = async ({ params: { inputId } }: PageProps) => {
const [{ data: input }, { data: subjects }] = await Promise.all([
getInput(inputId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ import * as Modal from '@/_components/modal';
import PageModalHeader from '@/_components/page-modal-header';
import getInput from '@/_queries/get-input';
import listSubjectsByTeamId from '@/_queries/list-subjects-by-team-id';
import formatTitle from '@/_utilities/format-title';

interface PageProps {
params: {
inputId: string;
};
}

export const metadata = { title: formatTitle(['Inputs', 'New']) };

const Page = async ({ params: { inputId } }: PageProps) => {
const [{ data: subjects }, { data: input }] = await Promise.all([
listSubjectsByTeamId(),
Expand Down
3 changes: 0 additions & 3 deletions app/(pages)/@modal/(layout)/inputs/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import InputForm from '@/_components/input-form';
import * as Modal from '@/_components/modal';
import PageModalHeader from '@/_components/page-modal-header';
import listSubjectsByTeamId from '@/_queries/list-subjects-by-team-id';
import formatTitle from '@/_utilities/format-title';

export const metadata = { title: formatTitle(['Inputs', 'New']) };

const Page = async () => {
const { data: subjects } = await listSubjectsByTeamId();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import EventPage from '@/_components/event-page';
import formatTitle from '@/_utilities/format-title';

interface PageProps {
params: {
Expand All @@ -8,8 +7,6 @@ interface PageProps {
};
}

export const metadata = { title: formatTitle(['Subjects', 'Event']) };

const Page = async ({ params: { eventId, subjectId } }: PageProps) => (
<EventPage eventId={eventId} subjectId={subjectId} isPublic={true} />
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import InsightPage from '@/_components/insight-page';
import formatTitle from '@/_utilities/format-title';

interface PageProps {
params: { insightId: string; subjectId: string };
searchParams: { from?: string; to?: string };
}

export const metadata = {
title: formatTitle(['Subjects', 'Insight']),
};

const Page = async ({
params: { insightId, subjectId },
searchParams: { from, to },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import InsightsPage from '@/_components/insights-page';
import formatTitle from '@/_utilities/format-title';

interface PageProps {
params: { subjectId: string };
searchParams: { foo?: string; from?: string; to?: string };
}

export const metadata = { title: formatTitle(['Subjects', 'Insights']) };

const Page = async ({ params: { subjectId }, searchParams }: PageProps) => (
<InsightsPage isPublic searchParams={searchParams} subjectId={subjectId} />
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import SessionPage from '@/_components/session-page';
import formatTitle from '@/_utilities/format-title';

interface PageProps {
params: {
Expand All @@ -9,10 +8,6 @@ interface PageProps {
};
}

export const metadata = {
title: formatTitle(['Subjects', 'Training plans', 'Sessions']),
};

const Page = async ({
params: { missionId, sessionId, subjectId },
}: PageProps) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import SessionsPage from '@/_components/sessions-page';
import formatTitle from '@/_utilities/format-title';

interface PageProps {
params: {
Expand All @@ -8,8 +7,6 @@ interface PageProps {
};
}

export const metadata = { title: formatTitle(['Subjects', 'Training plans']) };

const Page = ({ params: { missionId, subjectId } }: PageProps) => (
<SessionsPage isPublic missionId={missionId} subjectId={subjectId} />
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ import * as Modal from '@/_components/modal';
import PageModalHeader from '@/_components/page-modal-header';
import SubjectForm from '@/_components/subject-form';
import getSubject from '@/_queries/get-subject';
import formatTitle from '@/_utilities/format-title';

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

export const metadata = { title: formatTitle(['Subjects', 'Edit']) };

const Page = async ({ params: { subjectId } }: PageProps) => {
const { data: subject } = await getSubject(subjectId);
if (!subject) return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import EventTypeForm from '@/_components/event-type-form';
import TemplateType from '@/_constants/enum-template-type';
import getEventTypeWithInputs from '@/_queries/get-event-type-with-inputs';
import getSubject from '@/_queries/get-subject';
import listInputsBySubjectId from '@/_queries/list-inputs-by-subject-id';
import listSubjectsByTeamId from '@/_queries/list-subjects-by-team-id';
import listTemplatesWithData from '@/_queries/list-templates-with-data';
import formatTitle from '@/_utilities/format-title';

interface PageProps {
params: {
Expand All @@ -13,10 +13,6 @@ interface PageProps {
};
}

export const metadata = {
title: formatTitle(['Subjects', 'Event types', 'Edit']),
};

const Page = async ({ params: { eventTypeId, subjectId } }: PageProps) => {
const [
{ data: subject },
Expand All @@ -29,7 +25,7 @@ const Page = async ({ params: { eventTypeId, subjectId } }: PageProps) => {
getEventTypeWithInputs(eventTypeId),
listInputsBySubjectId(subjectId),
listSubjectsByTeamId(),
listTemplatesWithData(),
listTemplatesWithData({ type: TemplateType.EventType }),
]);

if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import PageModalHeader from '@/_components/page-modal-header';
import getCurrentUser from '@/_queries/get-current-user';
import getEventTypeWithInputsAndOptions from '@/_queries/get-event-type-with-inputs-and-options';
import getSubject from '@/_queries/get-subject';
import formatTitle from '@/_utilities/format-title';

interface PageProps {
params: {
Expand All @@ -14,8 +13,6 @@ interface PageProps {
};
}

export const metadata = { title: formatTitle(['Subjects', 'Event']) };

const Page = async ({ params: { eventTypeId, subjectId } }: PageProps) => {
const [{ data: subject }, { data: eventType }, user] = await Promise.all([
getSubject(subjectId),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import EventTypeForm from '@/_components/event-type-form';
import TemplateType from '@/_constants/enum-template-type';
import getSubject from '@/_queries/get-subject';
import listInputsBySubjectId from '@/_queries/list-inputs-by-subject-id';
import listSubjectsByTeamId from '@/_queries/list-subjects-by-team-id';
import listTemplatesWithData from '@/_queries/list-templates-with-data';
import formatTitle from '@/_utilities/format-title';

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

export const metadata = {
title: formatTitle(['Subjects', 'Event types', 'New']),
};

const Page = async ({ params: { subjectId } }: PageProps) => {
const [
{ data: subject },
Expand All @@ -25,7 +21,7 @@ const Page = async ({ params: { subjectId } }: PageProps) => {
getSubject(subjectId),
listInputsBySubjectId(subjectId),
listSubjectsByTeamId(),
listTemplatesWithData(),
listTemplatesWithData({ type: TemplateType.EventType }),
]);

if (!subject || !availableInputs || !subjects || !availableTemplates) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import EventPage from '@/_components/event-page';
import formatTitle from '@/_utilities/format-title';

interface PageProps {
params: {
Expand All @@ -8,8 +7,6 @@ interface PageProps {
};
}

export const metadata = { title: formatTitle(['Subjects', 'Event']) };

const Page = async ({ params: { eventId, subjectId } }: PageProps) => (
<EventPage eventId={eventId} subjectId={subjectId} />
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import PageModalHeader from '@/_components/page-modal-header';
import Number from '@/_constants/enum-number';
import getInsight from '@/_queries/get-insight';
import listEvents from '@/_queries/list-events';
import formatTitle from '@/_utilities/format-title';

interface PageProps {
params: {
Expand All @@ -13,10 +12,6 @@ interface PageProps {
};
}

export const metadata = {
title: formatTitle(['Subjects', 'Insights', 'Edit']),
};

const Page = async ({ params: { insightId, subjectId } }: PageProps) => {
const [{ data: events }, { data: insight }] = await Promise.all([
listEvents(subjectId, { from: 0, to: Number.FourByteSignedIntMax - 1 }),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import InsightPage from '@/_components/insight-page';
import formatTitle from '@/_utilities/format-title';

interface PageProps {
params: { insightId: string; subjectId: string };
searchParams: { from?: string; to?: string };
}

export const metadata = {
title: formatTitle(['Subjects', 'Insight']),
};

const Page = async ({
params: { insightId, subjectId },
searchParams: { from, to },
Expand Down
Loading

0 comments on commit a6f2855

Please sign in to comment.