Skip to content

Commit b3cf068

Browse files
Adding a checkbox for the custom link
wip Quick changes Implement the custom link
1 parent 688ecd1 commit b3cf068

6 files changed

Lines changed: 46 additions & 9 deletions

File tree

client/src/app/core/conversation.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ import { ParticipationSpa } from "../../components/participation/ParticipationSp
1212
import type { Conversation, ParticipationComment } from "./dashboard";
1313

1414
const ConversationPage = () => {
15-
const params = useParams<{ conversationId: string }>();
16-
15+
const params = useParams<{ conversationId: string;}>();
16+
const conversationIdOrName = params.conversationId;
1717
// This controls max. time (in s) the user need to wait before they can see the new comment(s)
1818
// TODO: make it configurable (server level? conversation level?)
1919
const autoRefetchInterval = 15;
2020

2121
const friendlyId = useQuery({
22-
queryKey: ["conversation-id", params.conversationId || ""],
23-
queryFn: () => getConversationIdByFriendlyName(params.conversationId || ""),
22+
queryKey: ["conversation-id-name", conversationIdOrName || ""],
23+
queryFn: () => getConversationIdByFriendlyName(conversationIdOrName || ""),
2424
retry: false,
25-
enabled: !!params.conversationId,
25+
enabled: !!conversationIdOrName,
2626
});
2727

2828
const conversationId = useMemo(() => {
29-
return friendlyId.data || params.conversationId;
30-
}, [friendlyId.data, params.conversationId]);
29+
return friendlyId.data || conversationIdOrName;
30+
}, [friendlyId.data, conversationIdOrName]);
3131

3232
const conversation = useQuery<Conversation>({
3333
queryKey: ["current-conversation", conversationId],

client/src/app/core/dashboard.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export type Conversation = {
1111
date_created: string;
1212
is_active: boolean;
1313
display_unmoderated: boolean;
14+
user_friendly_link: string;
1415
show_charts?: boolean; // placeholder
1516
allow_votes?: boolean; // placeholder
1617
};

client/src/components/conversation/ConversationConfig.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,18 @@ export default function ConversationConfig({
3939
); // TODO: placeholder; change to correct value later
4040
// const [updated, setUpdated] = useState(0);
4141

42+
const [conversationFriendlyLink, setConversationFriendlyLink] = useState(
43+
editItem?.user_friendly_link ?? "",
44+
);
45+
4246
async function formSubmit(event: React.FormEvent<HTMLFormElement>) {
4347
event.preventDefault();
4448
const formData = new FormData(event.target as HTMLFormElement);
4549
const newConversationRequestBody = {
4650
display_unmoderated: formData.get("display-unmoderated") === "on",
4751
show_charts: formData.get("show-charts") === "on", // TODO: placeholder; change to correct value later
4852
allow_votes: formData.get("allow-votes") === "on", // TODO: placeholder; change to correct value later
53+
user_friendly_link: formData.get("user-friendly-link"), // TODO: placeholder; change to correct value later
4954
name: formData.get("name"),
5055
description: formData.get("description"),
5156
};
@@ -176,6 +181,18 @@ export default function ConversationConfig({
176181
></Input>
177182
Make Conversation Open
178183
</label>
184+
<label htmlFor="user-friendly-link" className="flex gap-2 p-2">
185+
Use Custom Link for Conversation
186+
<Input
187+
className="border-gray-500 border-2 justify-self-start aspect-square h-6"
188+
name="user-friendly-link"
189+
id="user-friendly-link"
190+
value={conversationFriendlyLink}
191+
onChange={(event) =>
192+
setConversationFriendlyLink(event.target.value)
193+
}
194+
></Input>
195+
</label>
179196
</fieldset>
180197

181198
<button

client/src/components/conversation/ManageConversation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default function ManageConversation({
2929
};
3030
return (
3131
<section className="w-[95%] max-w-4xl mx-auto">
32-
<BreadCrumb conversation={editIdItem.id} />
32+
<BreadCrumb conversation={editIdItem.name} />
3333
<div className="title flex justify-between">
3434
<h1 className="text-4xl font-bold my-4">
3535
Conversation: {editIdItem.name}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { Conversation, ModerationComment } from "../../app/core/dashboard";
2+
import { useOutletContext } from "react-router";
3+
4+
export default function ManageDistribution({
5+
}: {
6+
}) {
7+
const { conversation } = useOutletContext<{ conversation: Conversation }>();
8+
return (
9+
<div className="[95%] max-w-4xl mx-auto">
10+
<p>
11+
Friendly Link: {}
12+
<a className="underline" href={window.location.origin + "/conversation/" + conversation.user_friendly_link}>
13+
{window.location.origin + "/conversation/" + conversation.user_friendly_link}
14+
</a>
15+
</p>
16+
</div>
17+
);
18+
}

client/src/main.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import ConversationPage from "./app/core/conversation";
1010
import DashboardPage from "./app/core/dashboard";
1111
import { AuthProvider } from "./components/context/AuthProvider";
1212
import ManageComments from "./components/conversation/ManageComments";
13+
import ManageDistribution from "./components/conversation/ManageDistribution";
1314

1415
const queryClient = new QueryClient();
1516

@@ -45,7 +46,7 @@ const router = createBrowserRouter([
4546
},
4647
{
4748
path: "distribute",
48-
Component: () => <></>,
49+
Component: ManageDistribution,
4950
},
5051
{
5152
path: "moderate",

0 commit comments

Comments
 (0)