From 076db605ace46ca52fd521ec66d09a0eb705e3f2 Mon Sep 17 00:00:00 2001 From: Supertiger Date: Wed, 22 Nov 2023 16:44:33 +0000 Subject: [PATCH] add MessageInputArea --- src/components/settings/TicketSettings.tsx | 54 ++++++++++++++++++---- 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/src/components/settings/TicketSettings.tsx b/src/components/settings/TicketSettings.tsx index bc40905f..fd70e0c2 100644 --- a/src/components/settings/TicketSettings.tsx +++ b/src/components/settings/TicketSettings.tsx @@ -1,4 +1,4 @@ -import { createEffect, createSignal, For, onMount, Show } from "solid-js"; +import { Accessor, createEffect, createSignal, For, onMount, Setter, Show } from "solid-js"; import Text from "@/components/ui/Text"; import { css, styled } from "solid-styled-components"; import { @@ -26,9 +26,12 @@ import { formatTimestamp } from "@/common/date"; import { useWindowProperties } from "@/common/useWindowProperties"; import { A, Route, Router, Routes, useParams } from "@solidjs/router"; import { Dynamic } from "solid-js/web"; -import { fetchMessages } from "@/chat-api/services/MessageService"; +import { fetchMessages, postMessage } from "@/chat-api/services/MessageService"; import Avatar from "../ui/Avatar"; import { Markup } from "../Markup"; +import RouterEndpoints from "@/common/RouterEndpoints"; +import Input from "../ui/input/Input"; +import Button from "../ui/Button"; const Container = styled("div")` display: flex; @@ -81,16 +84,44 @@ const TicketPage = () => { + ); }; -const MessageLogsContainer = styled(FlexColumn)` +const MessageInputArea = (props: { channelId: string, messages: RawMessage[], setMessages: Setter }) => { + const [value, setValue] = createSignal(""); - border-top: solid 1px rgba(255, 255, 255, 0.2); - padding-top: 12px; + const sendClick = async () => { + const formattedValue = value().trim(); + setValue(""); + if (!formattedValue) return; + const message = await postMessage({ + content: formattedValue, + channelId: props.channelId + }).catch(err => { + alert(err.message); + setValue(formattedValue); + }) + if (!message) return; + + props.setMessages([...props.messages, message]); + + } + + return ( + + +