feat: ParticipateButton

This commit is contained in:
DIYgod
2023-07-15 00:45:45 +01:00
parent 4ffb3e6ebb
commit 768a4a1272
5 changed files with 47 additions and 15 deletions
@@ -3,6 +3,7 @@ import { Metadata } from "next"
import { Hydrate, dehydrate } from "@tanstack/react-query"
import { HomeFeed } from "~/components/home/HomeFeed"
import ParticipateButton from "~/components/home/ParticipateButton"
import { APP_NAME } from "~/lib/env"
import getQueryClient from "~/lib/query-client"
import { prefetchGetFeed } from "~/queries/home.server"
@@ -41,7 +42,13 @@ export default async function Tag({
return (
<Hydrate state={dehydratedState}>
<h2 className="text-3xl font-bold">Tag: {params.tag}</h2>
<div className="border rounded-xl px-5 py-6 mb-4 space-y-2 relative bg-zinc-50">
<div className="text-2xl flex items-center font-bold">
<i className="icon-[mingcute--tag-line] mr-1" />
{params.tag}
</div>
<ParticipateButton tag={params.tag} />
</div>
<HomeFeed type="tag" />
</Hydrate>
)
@@ -3,6 +3,7 @@ import { Metadata } from "next"
import { Hydrate, dehydrate } from "@tanstack/react-query"
import { HomeFeed } from "~/components/home/HomeFeed"
import ParticipateButton from "~/components/home/ParticipateButton"
import { APP_NAME } from "~/lib/env"
import { getTranslation } from "~/lib/i18n"
import getQueryClient from "~/lib/query-client"
@@ -49,7 +50,7 @@ export default async function Topic({
<Hydrate state={dehydratedState}>
<div className="border rounded-xl px-5 py-6 mb-4 space-y-2 relative bg-zinc-50">
<div className="text-2xl flex items-center font-bold">
<i className="icon-[mingcute--hashtag-fill]" />
<i className="icon-[mingcute--tag-line] mr-1" />
{info?.includeTags[0]}
</div>
<p className="text-zinc-600">{t(info?.description || "")}</p>
@@ -58,9 +59,7 @@ export default async function Topic({
{t("Topic Keywords")}: {info?.includeKeywords?.join(", ")}
</p>
) : null}
{/* <Button className="absolute right-5 top-4">
{t("Participate in Topic")}
</Button> */}
<ParticipateButton tag={params.topic} />
</div>
<HomeFeed type="topic" />
</Hydrate>
@@ -99,6 +99,7 @@ export default function SubdomainEditor() {
let pageId = searchParams?.get("id") as string | undefined
const isPost = searchParams?.get("type") === "post"
const defaultTag = searchParams?.get("tag")
const site = useGetSite(subdomain)
@@ -117,7 +118,9 @@ export default function SubdomainEditor() {
router.replace(
`/dashboard/${subdomain}/editor?id=!local-${randomId}&type=${searchParams?.get(
"type",
)}`,
)}${
searchParams?.get("tag") ? "&tag=" + searchParams?.get("tag") : ""
}`,
)
} else {
key = `draft-${site.data?.characterId}-${pageId}`
@@ -159,7 +162,10 @@ export default function SubdomainEditor() {
// reset editor state when page changes
useBeforeMounted(() => {
useEditorState.setState(initialEditorState)
useEditorState.setState({
...initialEditorState,
tags: defaultTag || "",
})
})
const values = useEditorState()
+6 -8
View File
@@ -2,7 +2,11 @@
import { usePathname, useRouter } from "next/navigation"
import { useAccountState, useConnectModal } from "@crossbell/connect-kit"
import {
useAccountState,
useConnectModal,
useConnectedAction,
} from "@crossbell/connect-kit"
import { Tabs } from "~/components/ui/Tabs"
import { useTranslation } from "~/lib/i18n/client"
@@ -32,13 +36,7 @@ export const HomeActivitiesTabs = () => {
},
{
text: "Following",
onClick: () => {
if (!currentCharacterId) {
connectModal.show()
} else {
router.push(`/following`)
}
},
onClick: useConnectedAction(() => router.push(`/following`)),
active: pathname === "/following",
},
{
+22
View File
@@ -0,0 +1,22 @@
"use client"
import { useAccountState, useConnectedAction } from "@crossbell/connect-kit"
import { Button } from "~/components/ui/Button"
import { useTranslation } from "~/lib/i18n/client"
export default function ParticipateButton({ tag }: { tag: string }) {
const { t } = useTranslation("index")
const handleClick = useConnectedAction(() => {
const handle =
useAccountState.getState().computed.account?.character?.handle
window.open(`/dashboard/${handle}/editor?type=post&tag=${tag}`)
})
return (
<Button className="absolute right-5 top-4" onClick={handleClick}>
{t("Participate in Topic")}
</Button>
)
}