Skip to content

Commit 137e33e

Browse files
committed
added report abuse button, upgraded next to canary
1 parent 8d9d664 commit 137e33e

File tree

6 files changed

+165
-77
lines changed

6 files changed

+165
-77
lines changed

app/[domain]/layout.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import Image from "next/image";
22
import Link from "next/link";
33
import { ReactNode } from "react";
44
import prisma from "@/lib/prisma";
5-
import CTA from "./cta";
5+
import CTA from "@/components/cta";
6+
import ReportAbuse from "@/components/report-abuse";
67
import { notFound, redirect } from "next/navigation";
78
import { getSiteData } from "@/lib/fetchers";
89
import { fontMapper } from "@/styles/fonts";
@@ -125,8 +126,11 @@ export default async function SiteLayout({
125126

126127
<div className="mt-20">{children}</div>
127128

128-
{params.domain == `demo.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}` && (
129+
{params.domain == `demo.vercel.pub` ||
130+
params.domain == `platformize.co` ? (
129131
<CTA />
132+
) : (
133+
<ReportAbuse />
130134
)}
131135
</div>
132136
);
File renamed without changes.

components/report-abuse.tsx

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
"use client";
2+
3+
import clsx from "clsx";
4+
import { AlertTriangle } from "lucide-react";
5+
import { useParams } from "next/navigation";
6+
import { useState } from "react";
7+
import { experimental_useFormStatus as useFormStatus } from "react-dom";
8+
import LoadingDots from "./icons/loading-dots";
9+
import va from "@vercel/analytics";
10+
import { toast } from "sonner";
11+
12+
export default function ReportAbuse() {
13+
const [open, setOpen] = useState(false);
14+
const { domain, slug } = useParams() as { domain: string; slug?: string };
15+
const url = slug ? `https://${domain}/${slug}` : `https://${domain}`;
16+
17+
return (
18+
<div className="fixed bottom-5 right-5">
19+
<button
20+
className="rounded-full bg-black p-4 text-white shadow-lg transition-all hover:-translate-y-1 hover:shadow-2xl active:translate-y-0 active:shadow-sm"
21+
onClick={() => setOpen(!open)}
22+
>
23+
<AlertTriangle size={24} />
24+
</button>
25+
{open && (
26+
<form
27+
action={async (formData) => {
28+
const url = formData.get("url") as string;
29+
va.track("Reported Abuse", { url });
30+
// artificial 1s delay
31+
await new Promise((resolve) => setTimeout(resolve, 1000));
32+
setOpen(false);
33+
toast.success(
34+
"Successfully reported abuse – thank you for helping us keep the internet safe!",
35+
);
36+
}}
37+
className="absolute bottom-20 right-2 flex w-96 flex-col space-y-6 rounded-lg border border-stone-200 bg-white p-8 shadow-lg animate-in slide-in-from-bottom-5"
38+
>
39+
<div>
40+
<h2 className="font-cal text-xl leading-7 text-stone-900">
41+
Report Abuse
42+
</h2>
43+
<p className="mt-2 text-sm leading-6 text-stone-600">
44+
Found a site with abusive content? Let us know!
45+
</p>
46+
</div>
47+
48+
<div>
49+
<label
50+
htmlFor="domain"
51+
className="block text-sm font-medium leading-6 text-stone-900"
52+
>
53+
URL to report
54+
</label>
55+
<div className="mt-2">
56+
<input
57+
type="text"
58+
name="url"
59+
id="url"
60+
readOnly
61+
value={url}
62+
className="block w-full cursor-not-allowed rounded-md border border-stone-200 bg-stone-100 py-1.5 text-stone-900 shadow-sm ring-0 focus:outline-none sm:text-sm sm:leading-6"
63+
/>
64+
</div>
65+
</div>
66+
67+
<SubmitButton />
68+
</form>
69+
)}
70+
</div>
71+
);
72+
}
73+
74+
function SubmitButton() {
75+
const { pending } = useFormStatus();
76+
return (
77+
<button
78+
className={clsx(
79+
"h flex h-8 w-full items-center justify-center space-x-2 rounded-md border text-sm transition-all focus:outline-none sm:h-10",
80+
pending
81+
? "cursor-not-allowed border-stone-200 bg-stone-100 text-stone-400"
82+
: "border-black bg-black text-white hover:bg-white hover:text-black",
83+
)}
84+
disabled={pending}
85+
>
86+
{pending ? <LoadingDots color="#808080" /> : <p>Report Abuse</p>}
87+
</button>
88+
);
89+
}

lib/actions.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ export const updateSite = withSiteAuth(
159159
...(blurhash && { imageBlurhash: blurhash }),
160160
},
161161
});
162-
return url;
163162
} else {
164163
response = await prisma.site.update({
165164
where: {
@@ -328,7 +327,6 @@ export const updatePostMetadata = withPostAuth(
328327
imageBlurhash: blurhash,
329328
},
330329
});
331-
return url;
332330
} else {
333331
response = await prisma.post.update({
334332
where: {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"js-cookie": "^3.0.1",
4040
"lucide-react": "^0.244.0",
4141
"nanoid": "^4.0.2",
42-
"next": "https://files-qj8sttfe2-vtest314-ijjk-testing.vercel.app/next-v13.4.8-canary.13.tgz",
42+
"next": "13.4.8-canary.14",
4343
"next-auth": "4.22.1",
4444
"next-mdx-remote": "^4.4.1",
4545
"openai-edge": "^1.1.0",

pnpm-lock.yaml

Lines changed: 69 additions & 72 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)