Skip to content

Commit

Permalink
move insights to page modal
Browse files Browse the repository at this point in the history
  • Loading branch information
xvvvyz committed Jul 9, 2024
1 parent aad7f62 commit 7a30e17
Show file tree
Hide file tree
Showing 79 changed files with 549 additions and 693 deletions.
2 changes: 1 addition & 1 deletion app/(pages)/(with-nav)/inputs/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Layout = ({ children }: LayoutProps) => (
<div className="my-16 flex h-8 items-center justify-between gap-8 px-4">
<h1 className="text-2xl">Inputs</h1>
<Button href="/inputs/create" scroll={false} size="sm">
<PlusIcon className="w-5" />
<PlusIcon className="-ml-0.5 w-5" />
New input
</Button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/(pages)/(with-nav)/subjects/(list)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Layout = async ({ children }: LayoutProps) => (
<div className="my-16 flex h-8 items-center justify-between gap-8 px-4">
<h1 className="text-2xl">Subjects</h1>
<Button href="/subjects/create" scroll={false} size="sm">
<PlusIcon className="w-5" />
<PlusIcon className="-ml-0.5 w-5" />
New subject
</Button>
</div>
Expand Down
18 changes: 10 additions & 8 deletions app/(pages)/(with-nav)/subjects/(list)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,23 @@ const Page = async () => {
{!clientSubjects.length && !teamSubjects.length && (
<Empty className="mx-4">
<InformationCircleIcon className="w-7" />
Subjects can be dogs, cats, humans or
Add a subject to start collaboratively
<br />
anything else you want to track.
tracking and improving behavior.
</Empty>
)}
<SubjectList
clientSubjects={clientSubjects}
teamSubjects={teamSubjects}
/>
<CollapsibleArchive>
<SubjectList
clientSubjects={archivedClientSubjects}
teamSubjects={archivedTeamSubjects}
/>
</CollapsibleArchive>
{(!!archivedTeamSubjects.length || !!archivedClientSubjects.length) && (
<CollapsibleArchive>
<SubjectList
clientSubjects={archivedClientSubjects}
teamSubjects={archivedTeamSubjects}
/>
</CollapsibleArchive>
)}
</>
);
};
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import SubjectEventsPage from '@/_components/subject-events-page';
import SubjectPage from '@/_components/subject-page';
import formatTitle from '@/_utilities/format-title';

interface PageProps {
Expand All @@ -12,7 +12,7 @@ const Page = ({
params: { subjectId },
searchParams: { from, limit, to },
}: PageProps) => (
<SubjectEventsPage from={from} limit={limit} subjectId={subjectId} to={to} />
<SubjectPage from={from} limit={limit} subjectId={subjectId} to={to} />
);

export default Page;
2 changes: 1 addition & 1 deletion app/(pages)/(with-nav)/templates/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Layout = ({ children }: LayoutProps) => (
<div className="my-16 flex h-8 items-center justify-between gap-8 px-4">
<h1 className="text-2xl">Templates</h1>
<Button href="/templates/create" scroll={false} size="sm">
<PlusIcon className="w-5" />
<PlusIcon className="-ml-0.5 w-5" />
New template
</Button>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PageModalLoading from '@/_components/page-modal-loading';

const Loading = PageModalLoading;
const Loading = () => <PageModalLoading className="rounded bg-bg-3" />;

export default Loading;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import SubjectInsightsPage from '@/_components/subject-insights-page';
import InsightsPage from '@/_components/insights-page';
import formatTitle from '@/_utilities/format-title';

interface PageProps {
Expand All @@ -9,11 +9,7 @@ interface PageProps {
export const metadata = { title: formatTitle(['Subjects', 'Insights']) };

const Page = async ({ params: { subjectId }, searchParams }: PageProps) => (
<SubjectInsightsPage
isPublic
searchParams={searchParams}
subjectId={subjectId}
/>
<InsightsPage isPublic searchParams={searchParams} subjectId={subjectId} />
);

export default Page;
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const Page = async ({ params: { insightId, subjectId } }: PageProps) => {

return (
<>
<PageModalHeader title="New insight" />
<PageModalHeader title="Edit insight" />
<InsightForm events={events} insight={insight} subjectId={subjectId} />
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PageModalLoading from '@/_components/page-modal-loading';

const Loading = PageModalLoading;
const Loading = () => <PageModalLoading className="rounded bg-bg-3" />;

export default Loading;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import SubjectInsightsPage from '@/_components/subject-insights-page';
import InsightsPage from '@/_components/insights-page';
import formatTitle from '@/_utilities/format-title';

interface PageProps {
Expand All @@ -9,7 +9,7 @@ interface PageProps {
export const metadata = { title: formatTitle(['Subjects', 'Insights']) };

const Page = async ({ params: { subjectId }, searchParams }: PageProps) => (
<SubjectInsightsPage searchParams={searchParams} subjectId={subjectId} />
<InsightsPage searchParams={searchParams} subjectId={subjectId} />
);

export default Page;
2 changes: 1 addition & 1 deletion app/(pages)/@modal/(md)/account/[tab]/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Spinner from '@/_components/spinner';

const Loading = () => (
<div className="py-24">
<div className="pb-24 pt-16">
<Spinner className="mx-auto" />
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import MissionForm from '@/_components/mission-form';
import PageModalHeader from '@/_components/page-modal-header';
import getMission from '@/_queries/get-mission';
import TrainingPlanForm from '@/_components/training-plan-form';
import getSubject from '@/_queries/get-subject';
import getTrainingPlan from '@/_queries/get-training-plan';
import formatTitle from '@/_utilities/format-title';

interface PageProps {
Expand All @@ -18,15 +18,15 @@ export const metadata = {
const Page = async ({ params: { missionId, subjectId } }: PageProps) => {
const [{ data: subject }, { data: mission }] = await Promise.all([
getSubject(subjectId),
getMission(missionId),
getTrainingPlan(missionId),
]);

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

return (
<>
<PageModalHeader title={mission.name} />
<MissionForm mission={mission} subjectId={subjectId} />
<TrainingPlanForm mission={mission} subjectId={subjectId} />
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import PageModalHeader from '@/_components/page-modal-header';
import SessionForm from '@/_components/session-form';
import SessionLayout from '@/_components/session-layout';
import getCurrentUser from '@/_queries/get-current-user';
import getMissionWithSessions from '@/_queries/get-mission-with-sessions';
import getSession from '@/_queries/get-session';
import getSubject from '@/_queries/get-subject';
import getTrainingPlanWithSessions from '@/_queries/get-training-plan-with-sessions';
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';
Expand Down Expand Up @@ -37,7 +37,7 @@ const Page = async ({
user,
] = await Promise.all([
getSubject(subjectId),
getMissionWithSessions(missionId, { draft: true }),
getTrainingPlanWithSessions(missionId, { draft: true }),
getSession(sessionId),
listInputsBySubjectId(subjectId),
listTemplatesWithData(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import PageModalHeader from '@/_components/page-modal-header';
import SessionForm from '@/_components/session-form';
import SessionLayout from '@/_components/session-layout';
import getCurrentUser from '@/_queries/get-current-user';
import getMissionWithSessions from '@/_queries/get-mission-with-sessions';
import getSession from '@/_queries/get-session';
import getSubject from '@/_queries/get-subject';
import getTrainingPlanWithSessions from '@/_queries/get-training-plan-with-sessions';
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';
Expand Down Expand Up @@ -37,7 +37,7 @@ const Page = async ({
user,
] = await Promise.all([
getSubject(subjectId),
getMissionWithSessions(missionId, { draft: true }),
getTrainingPlanWithSessions(missionId, { draft: true }),
getSession(sessionId),
listInputsBySubjectId(subjectId),
listTemplatesWithData(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import PageModalHeader from '@/_components/page-modal-header';
import SessionForm from '@/_components/session-form';
import SessionLayout from '@/_components/session-layout';
import getCurrentUser from '@/_queries/get-current-user';
import getMissionWithSessions from '@/_queries/get-mission-with-sessions';
import getSubject from '@/_queries/get-subject';
import getTrainingPlanWithSessions from '@/_queries/get-training-plan-with-sessions';
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';
Expand Down Expand Up @@ -32,7 +32,7 @@ const Page = async ({ params: { missionId, order, subjectId } }: PageProps) => {
user,
] = await Promise.all([
getSubject(subjectId),
getMissionWithSessions(missionId, { draft: true }),
getTrainingPlanWithSessions(missionId, { draft: true }),
listSubjectsByTeamId(),
listInputsBySubjectId(subjectId),
listTemplatesWithData(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import MissionForm from '@/_components/mission-form';
import PageModalHeader from '@/_components/page-modal-header';
import TrainingPlanForm from '@/_components/training-plan-form';
import getSubject from '@/_queries/get-subject';
import formatTitle from '@/_utilities/format-title';

Expand All @@ -20,7 +20,7 @@ const Page = async ({ params: { subjectId } }: PageProps) => {
return (
<>
<PageModalHeader title="New training plan" />
<MissionForm subjectId={subjectId} />
<TrainingPlanForm subjectId={subjectId} />
</>
);
};
Expand Down
3 changes: 0 additions & 3 deletions app/(pages)/loading.tsx

This file was deleted.

This file was deleted.

This file was deleted.

9 changes: 0 additions & 9 deletions app/(pages)/share/[subjectId]/(subject-loading)/layout.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions app/(pages)/share/[subjectId]/(subject-loading)/loading.tsx

This file was deleted.

18 changes: 0 additions & 18 deletions app/(pages)/share/[subjectId]/events.csv/route.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion app/(pages)/share/[subjectId]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const Layout = async ({ children, params: { subjectId } }: LayoutProps) => {
</span>
<Button
className="text-sm"
href={`/subjects/${subjectId}/events`}
href={`/subjects/${subjectId}`}
variant="link"
>
View full profile
Expand Down
4 changes: 2 additions & 2 deletions app/(pages)/share/[subjectId]/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const Loading = () => null;
import SubjectLoading from '@/_components/subject-loading';

export default Loading;
export default SubjectLoading;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import SubjectEventsPage from '@/_components/subject-events-page';
import SubjectPage from '@/_components/subject-page';
import formatTitle from '@/_utilities/format-title';

interface PageProps {
Expand All @@ -12,7 +12,7 @@ const Page = async ({
params: { subjectId },
searchParams: { from, limit, to },
}: PageProps) => (
<SubjectEventsPage
<SubjectPage
from={from}
limit={limit}
isPublic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const Page = async ({ params: { shareCode, subjectId } }: PageProps) => {
});
}

redirect(`/subjects/${subjectId}/events`);
redirect(`/subjects/${subjectId}`);
};

export default Page;
2 changes: 1 addition & 1 deletion app/_components/alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const Alert = ({
<div className="fixed inset-0 z-20 bg-alpha-reverse-1 backdrop-blur-sm" />
<div className="fixed inset-0 z-30 overflow-y-auto p-4">
<div className="flex min-h-full items-center justify-center">
<DialogPanel className="w-full max-w-xs rounded border border-alpha-1 bg-bg-2 p-8 text-center drop-shadow">
<DialogPanel className="w-full max-w-xs rounded border border-alpha-1 bg-bg-2 p-8 text-center drop-shadow-2xl">
<DialogTitle className="text-2xl">{title}</DialogTitle>
{description && (
<Description className="mt-2 text-fg-4">
Expand Down
5 changes: 4 additions & 1 deletion app/_components/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(
{loading || (type === 'submit' && pending) ? (
<>
{variant !== 'link' && (
<Spinner color={spinnerColorSchemes[colorScheme]} />
<Spinner
className="-ml-0.5"
color={spinnerColorSchemes[colorScheme]}
/>
)}
{loadingText ?? children}
</>
Expand Down
Loading

0 comments on commit 7a30e17

Please sign in to comment.