-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
98 additions
and
119 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
apps/web/src/app/c/[slug]/settings/channels/controller.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
"use client"; | ||
|
||
import { Button } from "@spek/ui"; | ||
import Link from "next/link"; | ||
import { useState } from "react"; | ||
|
||
import { CreateChannelModal } from "@/components/communitySettings/CreateChannelModal"; | ||
import { Header } from "@/components/communitySettings/Header"; | ||
import { useTypeSafeQuery } from "@/hooks/useTypeSafeQuery"; | ||
|
||
interface PageProps { | ||
slug: string; | ||
} | ||
|
||
const Page: React.FC<PageProps> = ({ slug }) => { | ||
const { data, isLoading } = useTypeSafeQuery( | ||
["getCommunity", slug], | ||
{ enabled: false }, | ||
[slug] | ||
); | ||
|
||
if (isLoading) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className="flex flex-col gap-4"> | ||
{data?.channels.map((channel) => ( | ||
<div | ||
key={channel.id} | ||
className="rounded-md border border-primary-700 px-4 py-1" | ||
> | ||
<Link href={`/c/${slug}/${channel.id}`} className="font-semibold"> | ||
{channel.name} | ||
</Link> | ||
<p className="text-primary-300">{channel.description}</p> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export const ChannelsSettingsController: React.FC<{ slug: string }> = ({ | ||
slug, | ||
}) => { | ||
const { data } = useTypeSafeQuery( | ||
["getCommunity", slug], | ||
{ enabled: false }, | ||
[slug] | ||
); | ||
|
||
const [openModal, setOpenModal] = useState(false); | ||
|
||
const handleOpenModal = () => { | ||
setOpenModal(!openModal); | ||
}; | ||
|
||
return ( | ||
<div className="flex flex-col gap-4"> | ||
<Header heading="Channels" communitySlug={slug} /> | ||
<div> | ||
<Button onClick={handleOpenModal}>Create channel</Button> | ||
</div> | ||
<Page slug={slug} /> | ||
<CreateChannelModal | ||
communityId={data?.community.id} | ||
onRequestClose={handleOpenModal} | ||
open={openModal} | ||
/> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
import { Icon } from "@spek/ui"; | ||
import { useRouter } from "next/navigation"; | ||
import Link from "next/link"; | ||
|
||
interface HeaderProps { | ||
heading: string; | ||
communitySlug: string; | ||
} | ||
|
||
export const Header: React.FC<HeaderProps> = ({ heading }) => { | ||
const router = useRouter(); | ||
|
||
export const Header: React.FC<HeaderProps> = ({ heading, communitySlug }) => { | ||
return ( | ||
<div className="flex justify-between py-3 items-center"> | ||
<h2>{heading}</h2> | ||
<div | ||
<Link | ||
className="h-10 w-10 hover:bg-primary-800 hover:ring-2 cursor-pointer transition-all border border-primary-800 ring-primary-400 flex justify-center items-center rounded-full" | ||
onClick={() => router.back()} | ||
href={`/c/${communitySlug}`} | ||
> | ||
<Icon name="plus" className="rotate-45" /> | ||
</div> | ||
</Link> | ||
</div> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters