Skip to content

Commit

Permalink
not found -> null
Browse files Browse the repository at this point in the history
  • Loading branch information
xvvvyz committed Mar 14, 2024
1 parent fcd7f6f commit d8a8f72
Show file tree
Hide file tree
Showing 23 changed files with 23 additions and 57 deletions.
3 changes: 1 addition & 2 deletions app/(pages)/(private)/@modal/(pages)/account/[tab]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import AccountEmailForm from '@/_components/account-email-form';
import AccountPasswordForm from '@/_components/account-password-form';
import AccountProfileForm from '@/_components/account-profile-form';
import getCurrentUserFromSession from '@/_queries/get-current-user-from-session';
import { notFound } from 'next/navigation';

interface PageProps {
params: {
Expand All @@ -16,7 +15,7 @@ export const generateMetadata = ({ params: { tab } }: PageProps) => {

const Page = async ({ params: { tab } }: PageProps) => {
const user = await getCurrentUserFromSession();
if (!user || !['email', 'password', 'profile'].includes(tab)) notFound();
if (!user || !['email', 'password', 'profile'].includes(tab)) return null;

switch (tab) {
case 'profile': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ 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';
import { notFound } from 'next/navigation';

interface PageProps {
params: {
Expand All @@ -22,7 +21,7 @@ const Page = async ({ params: { inputId } }: PageProps) => {
listSubjectsByTeamId(),
]);

if (!input || !subjects) notFound();
if (!input || !subjects) return null;

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ 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';
import { notFound } from 'next/navigation';

interface PageProps {
params: {
Expand All @@ -19,7 +18,7 @@ const Page = async ({ params: { inputId } }: PageProps) => {
getInput(inputId),
]);

if (!input || !subjects) notFound();
if (!input || !subjects) return null;

return (
<>
Expand Down
3 changes: 1 addition & 2 deletions app/(pages)/(private)/@modal/(pages)/inputs/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import InputForm from '@/_components/input-form';
import PageModalHeader from '@/_components/page-modal-header';
import listSubjectsByTeamId from '@/_queries/list-subjects-by-team-id';
import formatTitle from '@/_utilities/format-title';
import { notFound } from 'next/navigation';

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

const Page = async () => {
const { data: subjects } = await listSubjectsByTeamId();
if (!subjects) notFound();
if (!subjects) return null;

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ 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';
import { notFound } from 'next/navigation';

interface PageProps {
params: {
Expand All @@ -19,7 +18,7 @@ export const generateMetadata = async ({

const Page = async ({ params: { subjectId } }: PageProps) => {
const { data: subject } = await getSubject(subjectId);
if (!subject) notFound();
if (!subject) return null;

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ 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';
import { notFound } from 'next/navigation';

interface PageProps {
params: {
Expand Down Expand Up @@ -48,7 +47,7 @@ const Page = async ({ params: { eventTypeId, subjectId } }: PageProps) => {
!availableTemplates ||
!subjects
) {
notFound();
return null;
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import getCurrentUserFromSession from '@/_queries/get-current-user-from-session'
import getEventTypeWithInputsAndOptions from '@/_queries/get-event-type-with-inputs-and-options';
import getSubject from '@/_queries/get-subject';
import formatTitle from '@/_utilities/format-title';
import { notFound } from 'next/navigation';

interface PageProps {
params: {
Expand Down Expand Up @@ -32,7 +31,7 @@ const Page = async ({ params: { eventTypeId, subjectId } }: PageProps) => {
getEventTypeWithInputsAndOptions(eventTypeId),
]);

if (!subject || !eventType) notFound();
if (!subject || !eventType) return null;

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ 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';
import { notFound } from 'next/navigation';

interface PageProps {
params: {
Expand Down Expand Up @@ -34,7 +33,7 @@ const Page = async ({ params: { subjectId } }: PageProps) => {
]);

if (!subject || !availableInputs || !availableTemplates || !subjects) {
notFound();
return null;
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import getCurrentUserFromSession from '@/_queries/get-current-user-from-session'
import getEvent from '@/_queries/get-event';
import getSubject from '@/_queries/get-subject';
import formatTitle from '@/_utilities/format-title';
import { notFound } from 'next/navigation';

interface PageProps {
params: {
Expand Down Expand Up @@ -33,7 +32,7 @@ const Page = async ({ params: { eventId, subjectId } }: PageProps) => {
getEvent(eventId),
]);

if (!subject || !event || !event.type) notFound();
if (!subject || !event || !event.type) return null;

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import PageModalHeader from '@/_components/page-modal-header';
import getMission from '@/_queries/get-mission';
import getSubject from '@/_queries/get-subject';
import formatTitle from '@/_utilities/format-title';
import { notFound } from 'next/navigation';

interface PageProps {
params: {
Expand All @@ -29,7 +28,7 @@ const Page = async ({ params: { missionId, subjectId } }: PageProps) => {
getMission(missionId),
]);

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

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import listSubjectsByTeamId from '@/_queries/list-subjects-by-team-id';
import listTemplatesWithData from '@/_queries/list-templates-with-data';
import forceArray from '@/_utilities/force-array';
import formatTitle from '@/_utilities/format-title';
import { notFound } from 'next/navigation';

interface PageProps {
params: {
Expand Down Expand Up @@ -77,7 +76,7 @@ const Page = async ({
!subjects ||
!isTeamMember
) {
notFound();
return null;
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ 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';
import { notFound } from 'next/navigation';

interface PageProps {
params: {
Expand Down Expand Up @@ -71,7 +70,7 @@ const Page = async ({
!subjects ||
!isTeamMember
) {
notFound();
return null;
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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';
import { notFound } from 'next/navigation';

interface PageProps {
params: {
Expand Down Expand Up @@ -64,7 +63,7 @@ const Page = async ({ params: { missionId, order, subjectId } }: PageProps) => {
!availableTemplates ||
!isTeamMember
) {
notFound();
return null;
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import MissionForm from '@/_components/mission-form';
import PageModalHeader from '@/_components/page-modal-header';
import getSubject from '@/_queries/get-subject';
import formatTitle from '@/_utilities/format-title';
import { notFound } from 'next/navigation';

interface PageProps {
params: {
Expand All @@ -19,7 +18,7 @@ export const generateMetadata = async ({

const Page = async ({ params: { subjectId } }: PageProps) => {
const { data: subject } = await getSubject(subjectId);
if (!subject) notFound();
if (!subject) return null;

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import getTemplate from '@/_queries/get-template';
import listInputs from '@/_queries/list-inputs';
import listSubjectsByTeamId from '@/_queries/list-subjects-by-team-id';
import formatTitle from '@/_utilities/format-title';
import { notFound } from 'next/navigation';

interface PageProps {
params: {
Expand All @@ -27,7 +26,7 @@ const Page = async ({ params: { templateId } }: PageProps) => {
listSubjectsByTeamId(),
]);

if (!template || !availableInputs || !subjects) notFound();
if (!template || !availableInputs || !subjects) return null;

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import getEventTypeWithInputs from '@/_queries/get-event-type-with-inputs';
import listInputs from '@/_queries/list-inputs';
import listSubjectsByTeamId from '@/_queries/list-subjects-by-team-id';
import formatTitle from '@/_utilities/format-title';
import { notFound } from 'next/navigation';

interface PageProps {
params: {
Expand All @@ -22,7 +21,7 @@ const Page = async ({ params: { eventTypeId } }: PageProps) => {
listSubjectsByTeamId(),
]);

if (!eventType || !availableInputs || !subjects) notFound();
if (!eventType || !availableInputs || !subjects) return null;

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import TemplateForm from '@/_components/template-form';
import listInputs from '@/_queries/list-inputs';
import listSubjectsByTeamId from '@/_queries/list-subjects-by-team-id';
import formatTitle from '@/_utilities/format-title';
import { notFound } from 'next/navigation';

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

Expand All @@ -13,7 +12,7 @@ const Page = async () => {
listSubjectsByTeamId(),
]);

if (!availableInputs || !subjects) notFound();
if (!availableInputs || !subjects) return null;

return (
<>
Expand Down
3 changes: 1 addition & 2 deletions app/(pages)/(private)/notifications/[tab]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Notifications from '@/_components/notifications';
import listNotifications from '@/_queries/list-notifications';
import { notFound } from 'next/navigation';

interface PageProps {
params: {
Expand All @@ -13,7 +12,7 @@ export const generateMetadata = ({ params: { tab } }: PageProps) => {
};

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

const { data: notifications } = await listNotifications({
archived: tab === 'archive',
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 getPublicEvent from '@/_queries/get-public-event';
import getPublicSubject from '@/_queries/get-public-subject';
import formatTitle from '@/_utilities/format-title';
import { notFound } from 'next/navigation';

interface PageProps {
params: {
Expand All @@ -30,7 +29,7 @@ const Page = async ({ params: { eventId, subjectId } }: PageProps) => {
getPublicEvent(eventId),
]);

if (!subject || !event || !event?.type) notFound();
if (!subject || !event || !event?.type) return null;

return (
<>
Expand Down
12 changes: 0 additions & 12 deletions app/(pages)/not-found.tsx

This file was deleted.

3 changes: 1 addition & 2 deletions app/_components/session-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import getSessionWithDetails from '@/_queries/get-session-with-details';
import getSubject from '@/_queries/get-subject';
import firstIfArray from '@/_utilities/first-if-array';
import CalendarIcon from '@heroicons/react/24/outline/CalendarIcon';
import { notFound } from 'next/navigation';

interface SessionPageProps {
isPublic?: boolean;
Expand Down Expand Up @@ -42,7 +41,7 @@ const SessionPage = async ({
: getSessionWithDetails(sessionId),
]);

if (!subject || !mission || !session) notFound();
if (!subject || !mission || !session) return null;
const isTeamMember = subject.team_id === user?.id;

return (
Expand Down
5 changes: 2 additions & 3 deletions app/_components/sessions-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import ArrowLeftIcon from '@heroicons/react/24/outline/ArrowLeftIcon';
import ArrowRightIcon from '@heroicons/react/24/outline/ArrowRightIcon';
import InformationCircleIcon from '@heroicons/react/24/outline/InformationCircleIcon';
import PlusIcon from '@heroicons/react/24/outline/PlusIcon';
import { notFound } from 'next/navigation';
import { twMerge } from 'tailwind-merge';

interface SessionsPageProps {
Expand All @@ -33,14 +32,14 @@ const SessionsPage = async ({
? getPublicSubject(subjectId)
: getSubject(subjectId));

if (!subject) notFound();
if (!subject) return null;
const isTeamMember = subject.team_id === user?.id;

const { data: mission } = isPublic
? await getPublicMissionWithSessionsAndEvents(missionId)
: await getMissionWithSessionsAndEvents(missionId, { draft: isTeamMember });

if (!mission) notFound();
if (!mission) return null;

const { highestOrder, sessionsReversed } = mission.sessions.reduce(
(acc, session, i) => {
Expand Down
3 changes: 1 addition & 2 deletions app/_components/subject-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import getCurrentUserFromSession from '@/_queries/get-current-user-from-session'
import getPublicSubject from '@/_queries/get-public-subject';
import getSubject from '@/_queries/get-subject';
import ArrowLeftIcon from '@heroicons/react/24/outline/ArrowLeftIcon';
import { notFound } from 'next/navigation';

interface SubjectPageProps {
eventsTo?: string;
Expand All @@ -31,7 +30,7 @@ const SubjectPage = async ({
? getPublicSubject(subjectId)
: getSubject(subjectId));

if (!subject) notFound();
if (!subject) return null;
const isTeamMember = subject.team_id === user?.id;

return (
Expand Down

0 comments on commit d8a8f72

Please sign in to comment.