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

chore: clean warnings and improve error handling #265

Merged
merged 7 commits into from
Feb 1, 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
7 changes: 4 additions & 3 deletions app/(static)/investors/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ const data = {
description:
"Find over 10,000 investors based on stage, sector, or location. Powered by Papermark.",
title: "Investor Search | Papermark",
url: "https://www.papermark.io/investors",
url: "/investors",
};

export const metadata: Metadata = {
metadataBase: new URL("https://www.papermark.io"),
title: data.title,
description: data.description,
openGraph: {
Expand All @@ -18,7 +19,7 @@ export const metadata: Metadata = {
siteName: "Papermark",
images: [
{
url: "https://www.papermark.io/_static/investor-meta.png",
url: "/_static/investor-meta.png",
width: 800,
height: 600,
},
Expand All @@ -31,7 +32,7 @@ export const metadata: Metadata = {
title: data.title,
description: data.description,
creator: "@papermarkio",
images: ["https://www.papermark.io/_static/investor-meta.png"],
images: ["/_static/investor-meta.png"],
},
};

Expand Down
7 changes: 4 additions & 3 deletions app/(static)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ const data = {
description:
"Papermark is an open-source document infrastructure for sharing and collaboration. Free alternative to Docsend with custom domain. Manage secure document sharing with real-time analytics.",
title: "Papermark | The Open Source DocSend Alternative",
url: "https://www.papermark.io",
url: "/",
};

export const metadata: Metadata = {
metadataBase: new URL("https://www.papermark.io"),
title: data.title,
description: data.description,
openGraph: {
Expand All @@ -19,7 +20,7 @@ export const metadata: Metadata = {
siteName: "Papermark",
images: [
{
url: "https://www.papermark.io/_static/meta-image.png",
url: "/_static/meta-image.png",
width: 800,
height: 600,
},
Expand All @@ -32,7 +33,7 @@ export const metadata: Metadata = {
title: data.title,
description: data.description,
creator: "@papermarkio",
images: ["https://www.papermark.io/_static/meta-image.png"],
images: ["/_static/meta-image.png"],
},
};

Expand Down
7 changes: 4 additions & 3 deletions app/(static)/open-source-investors/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ const data = {
description:
"List of 100 open-source investors. Open-source VC, open-source angel investors. Share pitchdecks with your investors using Papermark, an open-source document infrastructure.",
title: "Open Source Investors | Papermark",
url: "https://www.papermark.io",
url: "/open-source-investors",
};

export const metadata: Metadata = {
metadataBase: new URL("https://www.papermark.io"),
title: data.title,
description: data.description,
openGraph: {
Expand All @@ -20,7 +21,7 @@ export const metadata: Metadata = {
siteName: "Papermark",
images: [
{
url: "https://www.papermark.io/_static/meta-image.png",
url: "/_static/meta-image.png",
width: 800,
height: 600,
},
Expand All @@ -33,7 +34,7 @@ export const metadata: Metadata = {
title: data.title,
description: data.description,
creator: "@papermarkio",
images: ["https://www.papermark.io/_static/meta-image.png"],
images: ["/_static/meta-image.png"],
},
};

Expand Down
7 changes: 4 additions & 3 deletions app/(static)/oss-friends/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ const data = {
description:
"Meet our fellow open source projects. Papermark is an open-source document infrastructure for sharing and collaboration.",
title: "Open Source Friends | Papermark",
url: "https://www.papermark.io",
url: "/oss-friends",
};

export const metadata: Metadata = {
metadataBase: new URL("https://www.papermark.io"),
title: data.title,
description: data.description,
openGraph: {
Expand All @@ -19,7 +20,7 @@ export const metadata: Metadata = {
siteName: "Papermark",
images: [
{
url: "https://www.papermark.io/_static/meta-image.png",
url: "/_static/meta-image.png",
width: 800,
height: 600,
},
Expand All @@ -32,7 +33,7 @@ export const metadata: Metadata = {
title: data.title,
description: data.description,
creator: "@papermarkio",
images: ["https://www.papermark.io/_static/meta-image.png"],
images: ["/_static/meta-image.png"],
},
};

Expand Down
12 changes: 6 additions & 6 deletions components/shared/icons/papermark-sparkle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export default function PapermarkSparkle({
d="M31 12L29.7253 18.1359C29.6601 18.45 29.5492 18.7354 29.4016 18.9691C29.2539 19.2029 29.0737 19.3785 28.8753 19.4818L25 21.5L28.8753 23.5182C29.0737 23.6215 29.2539 23.7971 29.4016 24.0309C29.5492 24.2646 29.6601 24.55 29.7253 24.8641L31 31L32.2747 24.8641C32.3399 24.55 32.4508 24.2646 32.5984 24.0309C32.7461 23.7971 32.9263 23.6215 33.1247 23.5182L37 21.5L33.1247 19.4818C32.9263 19.3785 32.7461 19.2029 32.5984 18.9691C32.4508 18.7354 32.3399 18.45 32.2747 18.1359L31 12Z"
fill="currentColor"
stroke="currentColor"
stroke-linecap="round"
stroke-linejoin="round"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M7.89631 31V9.18182H16.5043C18.1591 9.18182 19.5689 9.49787 20.7337 10.13C21.8984 10.755 22.7862 11.625 23.397 12.7401C24.0149 13.848 24.3239 15.1264 24.3239 16.5753C24.3239 18.0241 24.0114 19.3026 23.3864 20.4105C22.7614 21.5185 21.8558 22.3814 20.6697 22.9993C19.4908 23.6172 18.0632 23.9261 16.3871 23.9261H10.9006V20.2294H15.6413C16.5291 20.2294 17.2607 20.0767 17.8359 19.7713C18.4183 19.4588 18.8516 19.0291 19.1357 18.4822C19.4268 17.9283 19.5724 17.2926 19.5724 16.5753C19.5724 15.8509 19.4268 15.2187 19.1357 14.679C18.8516 14.1321 18.4183 13.7095 17.8359 13.4112C17.2536 13.1058 16.5149 12.9531 15.62 12.9531H12.5092V31H7.89631Z"
Expand All @@ -31,15 +31,15 @@ export default function PapermarkSparkle({
d="M26.5 5L25.9689 6.93767C25.9417 7.03684 25.8955 7.12696 25.834 7.20078C25.7725 7.2746 25.6974 7.33005 25.6147 7.36267L24 8L25.6147 8.63733C25.6974 8.66995 25.7725 8.7254 25.834 8.79922C25.8955 8.87304 25.9417 8.96316 25.9689 9.06233L26.5 11L27.0311 9.06233C27.0583 8.96316 27.1045 8.87304 27.166 8.79922C27.2275 8.7254 27.3026 8.66995 27.3853 8.63733L29 8L27.3853 7.36267C27.3026 7.33005 27.2275 7.2746 27.166 7.20078C27.1045 7.12696 27.0583 7.03684 27.0311 6.93767L26.5 5Z"
fill="currentColor"
stroke="currentColor"
stroke-linecap="round"
stroke-linejoin="round"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M22.5 27L21.9689 28.9377C21.9417 29.0368 21.8955 29.127 21.834 29.2008C21.7725 29.2746 21.6974 29.33 21.6147 29.3627L20 30L21.6147 30.6373C21.6974 30.67 21.7725 30.7254 21.834 30.7992C21.8955 30.873 21.9417 30.9632 21.9689 31.0623L22.5 33L23.0311 31.0623C23.0583 30.9632 23.1045 30.873 23.166 30.7992C23.2275 30.7254 23.3026 30.67 23.3853 30.6373L25 30L23.3853 29.3627C23.3026 29.33 23.2275 29.2746 23.166 29.2008C23.1045 29.127 23.0583 29.0368 23.0311 28.9377L22.5 27Z"
fill="currentColor"
stroke="currentColor"
stroke-linecap="round"
stroke-linejoin="round"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
);
Expand Down
2 changes: 1 addition & 1 deletion components/web/testimonials.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const testimonials = [
name: "Lukas Lunzmann",
handle: "lucaslunzmann",
imageUrl:
"https://pbs.twimg.com/profile_images/1589657534264213504/d0tljS03_400x400.jpg",
"https://pbs.twimg.com/profile_images/1738781878792921088/5kSW6ymD_400x400.jpg",
link: "https://twitter.com/lucaslunzmann/status/1673052992541523968",
},
},
Expand Down
3 changes: 2 additions & 1 deletion lib/swr/use-billing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export function usePlan() {
const teamInfo = useTeam();

const { data: plan, error } = useSWR<PlanResponse>(
`/api/teams/${teamInfo?.currentTeam?.id}/billing/plan`,
teamInfo?.currentTeam?.id &&
`/api/teams/${teamInfo?.currentTeam?.id}/billing/plan`,
fetcher,
{
dedupingInterval: 60000,
Expand Down
3 changes: 2 additions & 1 deletion lib/swr/use-brand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export function useBrand() {
const teamInfo = useTeam();

const { data: brand, error } = useSWR<Brand>(
`/api/teams/${teamInfo?.currentTeam?.id}/branding`,
teamInfo?.currentTeam?.id &&
`/api/teams/${teamInfo?.currentTeam?.id}/branding`,
fetcher,
{
dedupingInterval: 30000,
Expand Down
9 changes: 6 additions & 3 deletions lib/swr/use-document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export function useDocument() {
};

const { data: document, error } = useSWR<DocumentWithVersion>(
id &&
teamInfo?.currentTeam?.id &&
id &&
`/api/teams/${teamInfo?.currentTeam?.id}/documents/${encodeURIComponent(
id,
)}`,
Expand All @@ -41,7 +42,8 @@ export function useDocumentLinks() {
};

const { data: links, error } = useSWR<LinkWithViews[]>(
id &&
teamInfo?.currentTeam?.id &&
id &&
`/api/teams/${teamInfo?.currentTeam?.id}/documents/${encodeURIComponent(
id,
)}/links`,
Expand Down Expand Up @@ -78,7 +80,8 @@ export function useDocumentVisits() {
};

const { data: views, error } = useSWR<ViewWithDuration[]>(
id &&
teamInfo?.currentTeam?.id &&
id &&
`/api/teams/${teamInfo?.currentTeam?.id}/documents/${encodeURIComponent(
id,
)}/views`,
Expand Down
11 changes: 5 additions & 6 deletions lib/swr/use-documents.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { useRouter } from "next/router";
import useSWR from "swr";
import { fetcher } from "@/lib/utils";
import { DocumentWithLinksAndLinkCountAndViewCount } from "@/lib/types";
import { useTeam } from "@/context/team-context";

export default function useDocuments() {
const router = useRouter();
const teamInfo = useTeam();

const { data: documents, isValidating } = useSWR<
const { data: documents, error } = useSWR<
DocumentWithLinksAndLinkCountAndViewCount[]
>(
router.isReady && `/api/teams/${teamInfo?.currentTeam?.id}/documents`,
teamInfo?.currentTeam?.id &&
`/api/teams/${teamInfo?.currentTeam?.id}/documents`,
fetcher,
{
revalidateOnFocus: false,
Expand All @@ -21,7 +20,7 @@ export default function useDocuments() {

return {
documents,
loading: documents ? false : true,
isValidating,
loading: !documents && !error,
error,
};
}
8 changes: 4 additions & 4 deletions pages/api/teams/[teamId]/branding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ export default async function handle(
});

if (!brand) {
res.status(404).end("Brand not found");
res.status(200).json(null);
}

return res.status(200).json(brand);
res.status(200).json(brand);
} else if (req.method === "POST") {
// POST /api/teams/:teamId/branding
const { logo, brandColor, accentColor } = req.body as {
Expand Down Expand Up @@ -113,10 +113,10 @@ export default async function handle(
},
});

return res.status(200).json("Branding deleted");
res.status(204).end();
} else {
// We only allow GET and DELETE requests
res.setHeader("Allow", ["GET", "POST", "PUT"]);
res.setHeader("Allow", ["GET", "POST", "PUT", "DELETE"]);
return res.status(405).end(`Method ${req.method} Not Allowed`);
}
}
4 changes: 2 additions & 2 deletions pages/documents/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ export default function Documents() {
<Skeleton key={i} className="h-9 w-9" />
<div>
<Skeleton key={i} className="h-4 w-32" />
<Skeleton key={i} className="mt-2 h-3 w-12" />
<Skeleton key={i + 1} className="mt-2 h-3 w-12" />
</div>
<Skeleton
key={i}
key={i + 1}
className="h-5 w-20 absolute top-[50%] transform -translate-y-[50%] right-5"
/>
</li>
Expand Down
2 changes: 1 addition & 1 deletion pages/view/[linkId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const getStaticProps = async (context: GetStaticPropsContext) => {
},
brand, // pass brand to the client
},
revalidate: 10,
revalidate: brand ? 10 : false,
};
};

Expand Down