From 3dc36bb1fa3c459690f6f7a0ea832b7f2e90f1ca Mon Sep 17 00:00:00 2001 From: tisachi Date: Fri, 23 Oct 2026 22:36:12 +0200 Subject: [PATCH] App: kontakt z wlascicielami sirowni (podstrona /gyms/:id/contact + sekcja w komunikatorze + badge) i statystyki wlasciciela REAL (kafelek + podstrona /gyms/:id/stats); karty VIRTUAL czysto nawigacyjne, akcje dolacz/ocena/zarzadzaj przeniesione do menu detalu (grupa Zarzadzaj zwinieta na lg+) --- app/src/App.tsx | 4 + app/src/api/queries.ts | 79 +++++ app/src/api/types.ts | 83 +++++ app/src/components/Layout.tsx | 11 +- app/src/components/gyms/InviteGymModal.tsx | 91 +++++- app/src/i18n/locales/en/common.json | 4 +- app/src/i18n/locales/en/gyms.json | 51 ++- app/src/i18n/locales/en/messages.json | 1 + app/src/i18n/locales/pl/common.json | 6 +- app/src/i18n/locales/pl/gyms.json | 53 ++- app/src/i18n/locales/pl/messages.json | 1 + app/src/pages/gyms/GymContactPage.tsx | 358 +++++++++++++++++++++ app/src/pages/gyms/GymDetail.tsx | 252 +++++++++------ app/src/pages/gyms/GymStatsPage.tsx | 178 ++++++++++ app/src/pages/gyms/Gyms.tsx | 289 +---------------- app/src/pages/messages/Messages.tsx | 78 ++++- app/src/topbar/GroupButton.tsx | 41 ++- app/src/topbar/Topbar.tsx | 2 + app/src/topbar/types.ts | 7 + app/test/e2e/gym-contact.spec.ts | 100 ++++++ app/test/e2e/gym-stats.spec.ts | 53 +++ app/test/e2e/gyms.spec.ts | 3 +- app/test/e2e/mock-api.ts | 221 ++++++++++++- app/test/e2e/presence.spec.ts | 3 +- app/test/e2e/virtual-gyms.spec.ts | 127 ++++---- app/test/gym-contact.test.tsx | 238 ++++++++++++++ app/test/gym-detail.test.tsx | 86 ++++- app/test/gym-stats.test.tsx | 142 ++++++++ 28 files changed, 2099 insertions(+), 463 deletions(-) create mode 100644 app/src/pages/gyms/GymContactPage.tsx create mode 100644 app/src/pages/gyms/GymStatsPage.tsx create mode 100644 app/test/e2e/gym-contact.spec.ts create mode 100644 app/test/e2e/gym-stats.spec.ts create mode 100644 app/test/gym-contact.test.tsx create mode 100644 app/test/gym-stats.test.tsx diff --git a/app/src/App.tsx b/app/src/App.tsx index e13f54d..ee69dc3 100644 --- a/app/src/App.tsx +++ b/app/src/App.tsx @@ -20,6 +20,8 @@ import ProfileProgress from './pages/profile/ProfileProgress'; import ProfileClaims from './pages/profile/ProfileClaims'; import Gyms from './pages/gyms/Gyms'; import GymDetail from './pages/gyms/GymDetail'; +import GymContactPage from './pages/gyms/GymContactPage'; +import GymStatsPage from './pages/gyms/GymStatsPage'; import GymGalleryPage from './pages/gyms/GymGalleryPage'; import GymEquipmentPage from './pages/gyms/GymEquipmentPage'; import GymAnnouncementsPage from './pages/gyms/GymAnnouncementsPage'; @@ -75,6 +77,8 @@ export default function App() { } /> } /> } /> + } /> + } /> api(`/gyms/${gymId}/contact`), + enabled: !!gymId, + refetchInterval: 30_000, + }); +} + +/** Członek inicjuje/odpowiada we własnym wątku (upsert per [gymId,userId]). */ +export function sendGymContactMessage(gymId: string, body: string) { + return api<{ + conversation: { + id: string; + gymId: string; + userId: string; + createdAt: string; + updatedAt: string; + }; + }>(`/gyms/${encodeURIComponent(gymId)}/contact/messages`, { method: 'POST', body: { body } }); +} + +/** Skrzynka właściciela: wątki we wszystkich gymach, gdzie caller ma rolę OWNER. */ +export function useGymContactInbox() { + return useQuery({ + queryKey: ['gym-contact', 'inbox'], + queryFn: () => api<{ conversations: GymContactThreadListItem[] }>('/gym-contact/conversations'), + refetchInterval: 30_000, + }); +} + +/** Pojedynczy wątek (read-mark po stronie API). */ +export function useGymContactThread(conversationId: string) { + return useQuery({ + queryKey: ['gym-contact', 'thread', conversationId], + queryFn: () => + api(`/gym-contact/conversations/${encodeURIComponent(conversationId)}`), + enabled: !!conversationId, + refetchInterval: 30_000, + }); +} + +/** Odpowiedź uczestnika w wątku (właściciel/admin lub członek). */ +export function sendGymContactReply(conversationId: string, body: string) { + return api<{ message: GymContactMessage }>( + `/gym-contact/conversations/${encodeURIComponent(conversationId)}/messages`, + { method: 'POST', body: { body } }, + ); +} + +/** Usunięcie własnej wiadomości (twardy delete, tylko autor). */ +export function deleteGymContactMessage(messageId: string) { + return api(`/gym-contact/messages/${encodeURIComponent(messageId)}`, { method: 'DELETE' }); +} + +/** + * Statystyki właściciela (REAL): presence + członkowie + aktywność treningowa. + * `rangeDays`: 7/30/90, from liczony od teraz (jak mapa ciepła urządzeń). + */ +export function useGymStatsOverview(gymId: string | undefined, rangeDays: number) { + return useQuery({ + queryKey: ['gym-stats-overview', gymId, rangeDays], + queryFn: () => { + const from = new Date(Date.now() - rangeDays * 86_400_000).toISOString(); + return api( + `/gyms/${gymId}/stats/overview?from=${encodeURIComponent(from)}`, + ); + }, + enabled: !!gymId, + }); +} + // ---------- bytność (check-in, live occupancy) ---------- /** Aktywna bytność zalogowanego — podstawa przycisków „Idę ćwiczyć / Wychodzę / Wciąż tu jestem". */ export function useActivePresence(refetchIntervalMs?: number) { diff --git a/app/src/api/types.ts b/app/src/api/types.ts index 951835b..267d35d 100644 --- a/app/src/api/types.ts +++ b/app/src/api/types.ts @@ -158,6 +158,8 @@ export interface Gym { coverPhoto: string | null; /** Live „teraz: N" (aktywne bytności); null dla VIRTUAL (brak meldunków). */ currentOccupancy?: number | null; + /** Głos zalogowanego (publiczna VIRTUAL); null = nie głosował; brak dla REAL/prywatnych. */ + myVote?: 'UP' | 'DOWN' | null; } /** Odpowiedź detalu siłowni (GET /gyms/:id): siłownia + galeria + role zalogowanego. */ @@ -294,6 +296,87 @@ export interface GymException { availability: DayAvailability | null; } +// ---------- kontakt członek ↔ właściciele siłowni ---------- +export type GymContactRole = 'member' | 'owner' | 'admin'; + +export interface GymContactMessage { + id: string; + senderId: string; + senderName: string; + body: string; + createdAt: string; +} + +export interface GymContactConversationInfo { + id: string; + gymId: string; + gymName: string; + /** Autor wątku (członek, który go zainicjował). */ + userId: string; + memberName: string; + createdAt: string; + updatedAt: string; +} + +/** Widok członka: własny wątek (lazily null) + strumień + canReply. */ +export interface GymContactMemberView { + role: 'member'; + conversation: GymContactConversationInfo | null; + messages: GymContactMessage[]; + canReply: boolean; +} + +export interface GymContactThreadListItem { + id: string; + gymId: string; + gymName: string; + userId: string; + counterpartName: string; + lastMessageBody: string | null; + lastMessageAt: string | null; + unreadCount: number; +} + +/** Widok właściciela/admina siłowni: lista wątków tego gyma. */ +export interface GymContactManagerView { + role: 'owner' | 'admin'; + threads: GymContactThreadListItem[]; +} + +export type GymContactView = GymContactMemberView | GymContactManagerView; + +/** Pojedynczy wątek (GET /gym-contact/conversations/:id) — read-mark po stronie API. */ +export interface GymContactThread { + role: GymContactRole; + conversation: GymContactConversationInfo; + messages: GymContactMessage[]; + canReply: boolean; +} + +// ---------- statystyki właściciela (GET /gyms/:id/stats/overview, REAL) ---------- +export interface GymStatsOverview { + gym: { id: string; name: string; kind: GymKind; capacity: number | null }; + presence: { + visits: number; + visitsPerDay: number; + avgStayMinutes: number | null; + peak: number; + live: number; + heatmap: { day: number; hour: number; count: number }[]; + }; + members: { + total: number; + byRole: { OWNER: number; TRAINER: number; MEMBER: number }; + newInRange: number; + }; + activity: { + sessionsStarted: number; + sessionsCompleted: number; + sessionsAbandoned: number; + uniqueExercisers: number; + }; +} + export interface Exercise { id: string; slug: string; diff --git a/app/src/components/Layout.tsx b/app/src/components/Layout.tsx index 6546008..c549bf2 100644 --- a/app/src/components/Layout.tsx +++ b/app/src/components/Layout.tsx @@ -24,6 +24,7 @@ import { useActiveSession, useConversations, useFeedUnreadCount, + useGymContactInbox, useGymInvitations, useInvitations, useIsTrainer, @@ -200,14 +201,14 @@ export default function Layout() { const { data: invitations } = useInvitations(); const { data: gymInvitations } = useGymInvitations(); const { data: conversations } = useConversations(); + const { data: gymContactData } = useGymContactInbox(); // Liczba oczekujących zaproszeń: coaching (trener) + do prywatnych siłowni. const pendingInvitations = (invitations?.invitations ?? []).length + (gymInvitations?.invitations ?? []).length; - // Nieprzeczytane wiadomości w komunikatorze (suma per rozmowa). - const unreadMessages = (conversations?.conversations ?? []).reduce( - (n, c) => n + c.unreadCount, - 0, - ); + // Nieprzeczytane: komunikator coachingowy + wątki kontaktu z właścicielami siłowni. + const unreadMessages = + (conversations?.conversations ?? []).reduce((n, c) => n + c.unreadCount, 0) + + (gymContactData?.conversations ?? []).reduce((n, c) => n + c.unreadCount, 0); // Nieprzeczytane aktualności (powiadomienia osobiste + ogłoszenia siłowni). const { data: feedUnread } = useFeedUnreadCount(); const unreadFeed = feedUnread?.unreadCount ?? 0; diff --git a/app/src/components/gyms/InviteGymModal.tsx b/app/src/components/gyms/InviteGymModal.tsx index b52b5fb..85d44f9 100644 --- a/app/src/components/gyms/InviteGymModal.tsx +++ b/app/src/components/gyms/InviteGymModal.tsx @@ -1,8 +1,15 @@ import { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useQueryClient } from '@tanstack/react-query'; -import { sendGymInvitation, useGymInviteeSearch } from '../../api/queries'; -import { Button, ErrorText, Field, Input, Loading, Modal } from '../ui'; +import { + sendGymInvitation, + useGymInvitations, + useGymInviteeSearch, + withdrawGymInvitation, +} from '../../api/queries'; +import type { GymInvitation } from '../../api/types'; +import { Avatar } from '../Avatar'; +import { Button, ConfirmDialog, ErrorText, Field, Input, ListRow, Loading, Modal } from '../ui'; import { useToast } from '../toast'; /** Wyszukajka imię + nazwisko → „Zaproś” per user (właściciel prywatnej VIRTUAL). */ @@ -94,6 +101,86 @@ export default function InviteGymModal({ ); })} + + ); } + +/* Wysłane zaproszenia (dawna karta w treści detailu — przeniesiona do modala, + 1 kontrolka = 1 miejsce): lista + „Wycofaj” z potwierdzeniem. */ +function SentInvitationsList({ gymId }: { gymId: string }) { + const queryClient = useQueryClient(); + const { push } = useToast(); + const { t } = useTranslation('gyms'); + const { data } = useGymInvitations(); + const sent = (data?.invitations ?? []).filter( + (i) => i.direction === 'sent' && i.gym.id === gymId, + ); + const [toWithdraw, setToWithdraw] = useState(null); + const [busy, setBusy] = useState(false); + + const withdraw = async () => { + if (!toWithdraw) return; + setBusy(true); + try { + await withdrawGymInvitation(toWithdraw.id); + await queryClient.invalidateQueries({ queryKey: ['gym-invitations'] }); + push(t('invites.toastWithdrawn'), 'success'); + setToWithdraw(null); + } catch (e) { + push((e as Error).message, 'error'); + } finally { + setBusy(false); + } + }; + + if (sent.length === 0) return null; + const name = toWithdraw + ? [toWithdraw.user?.firstName, toWithdraw.user?.lastName].filter(Boolean).join(' ') || + toWithdraw.user?.email || + '—' + : ''; + + return ( +
+
+ {t('invite.sentTitle')} +
+
+ {sent.map((inv) => { + const invName = + [inv.user?.firstName, inv.user?.lastName].filter(Boolean).join(' ') || + inv.user?.email || + '—'; + return ( + + + {invName} + + } + actions={ + + } + /> + ); + })} +
+ setToWithdraw(null)} + onConfirm={() => void withdraw()} + title={t('invites.withdraw')} + description={t('invites.confirmWithdraw', { name })} + confirmLabel={t('invites.withdraw')} + danger + busy={busy} + /> +
+ ); +} diff --git a/app/src/i18n/locales/en/common.json b/app/src/i18n/locales/en/common.json index 50b2df2..01b18a9 100644 --- a/app/src/i18n/locales/en/common.json +++ b/app/src/i18n/locales/en/common.json @@ -95,7 +95,9 @@ "measurements_one": "{{count}} measurement", "measurements_other": "{{count}} measurements", "devices_one": "{{count}} device", - "devices_other": "{{count}} devices" + "devices_other": "{{count}} devices", + "members_one": "{{count}} member", + "members_other": "{{count}} members" }, "muscles": { "chest": "Chest", diff --git a/app/src/i18n/locales/en/gyms.json b/app/src/i18n/locales/en/gyms.json index d538cde..348800e 100644 --- a/app/src/i18n/locales/en/gyms.json +++ b/app/src/i18n/locales/en/gyms.json @@ -97,6 +97,7 @@ "groupEquipment": "Equipment", "groupAnnouncements": "Announcements", "groupInvites": "Invitations", + "groupStats": "Statistics", "actionInfo": "Information", "actionInvite": "Invite user", "actionWithdrawClaim": "Withdraw request", @@ -139,6 +140,7 @@ "desc": "A private gym is hidden — invite specific users.", "empty": "No invitations sent.", "withdraw": "Withdraw", + "confirmWithdraw": "Withdraw the invitation for {{name}}?", "toastWithdrawn": "Invitation withdrawn" }, "page": { @@ -253,9 +255,10 @@ "firstNamePh": "e.g. John", "lastNameLabel": "Last name", "lastNamePh": "e.g. Smith", - "empty": "No users with these details.", + "empty": "No users with the given details.", "submit": "Invite", - "busy": "Inviting…" + "busy": "Inviting…", + "sentTitle": "Sent invitations" }, "join": { "toastOk": "Joined gym: {{name}}", @@ -267,6 +270,50 @@ "submit": "Join", "busy": "Joining…" }, + "rating": { + "group": "Rating", + "recommend": "Recommend", + "notRecommend": "Do not recommend" + }, + "contact": { + "action": "Write to owners", + "pageTitle": "Contact", + "ownersTitle": "Owners — {{name}}", + "ownersAvatar": "Owners", + "threadsTitle": "Conversations — {{name}}", + "composerPlaceholder": "Write a message to the owners…", + "composerAria": "Message body", + "send": "Send", + "sending": "Sending…", + "counter": "{{n}}/{{max}}", + "emptyThread": "No messages yet — write the first one.", + "emptyThreadsTitle": "No conversations", + "emptyThreadsDesc": "Members of this gym have not written yet.", + "deleteAria": "Delete message", + "deleteTitle": "Delete message", + "deleteDesc": "This action cannot be undone." + }, + "stats": { + "title": "Statistics", + "visits": "Visits", + "visitsPerDay": "Visits / day", + "avgStay": "Avg. stay", + "minutes": "{{n}} min", + "peak": "Peak", + "live": "Now", + "members": "Members", + "newInRange": "New in range", + "sessionsCompleted": "Sessions completed", + "sessionsAbandoned": "Sessions abandoned", + "uniqueExercisers": "Exercising people", + "heatmapTitle": "Presence (day × hour)", + "heatmapEmpty": "No visits in this period.", + "cellTitle_one": "{{day}}, {{hour}}:00 — {{count}} visit", + "cellTitle_other": "{{day}}, {{hour}}:00 — {{count}} visits", + "rangeAria": "Statistics range", + "rangeDays_one": "{{count}} day", + "rangeDays_other": "{{count}} days" + }, "address": { "street": "Street and number", "streetPh": "e.g. Mokotowska 12A", diff --git a/app/src/i18n/locales/en/messages.json b/app/src/i18n/locales/en/messages.json index 3c8368f..dd85946 100644 --- a/app/src/i18n/locales/en/messages.json +++ b/app/src/i18n/locales/en/messages.json @@ -10,6 +10,7 @@ "roleTrainers": "Trainers", "youPrefix": "You: ", "noMessageRow": "No messages", + "gymOwnersSection": "Gym owners", "emptyTitle": "No conversations", "emptyDesc": "A conversation appears once you have an active relationship with a trainer.", "searchNoResults": "No results for the given query.", diff --git a/app/src/i18n/locales/pl/common.json b/app/src/i18n/locales/pl/common.json index f1bf639..a453c12 100644 --- a/app/src/i18n/locales/pl/common.json +++ b/app/src/i18n/locales/pl/common.json @@ -117,7 +117,11 @@ "devices_one": "{{count}} urządzenie", "devices_few": "{{count}} urządzenia", "devices_many": "{{count}} urządzeń", - "devices_other": "{{count}} urządzeń" + "devices_other": "{{count}} urządzeń", + "members_one": "{{count}} członek", + "members_few": "{{count}} członków", + "members_many": "{{count}} członków", + "members_other": "{{count}} członków" }, "muscles": { "chest": "Klatka", diff --git a/app/src/i18n/locales/pl/gyms.json b/app/src/i18n/locales/pl/gyms.json index c0c647c..2816ad3 100644 --- a/app/src/i18n/locales/pl/gyms.json +++ b/app/src/i18n/locales/pl/gyms.json @@ -101,6 +101,7 @@ "groupEquipment": "Urządzenia", "groupAnnouncements": "Ogłoszenia", "groupInvites": "Zaproszenia", + "groupStats": "Statystyki", "actionInfo": "Informacje", "actionInvite": "Zaproś usera", "actionWithdrawClaim": "Wycofaj wniosek", @@ -143,6 +144,7 @@ "desc": "Prywatna siłownia jest ukryta — zapraszaj określonych userów.", "empty": "Brak wysłanych zaproszeń.", "withdraw": "Wycofaj", + "confirmWithdraw": "Wycofać zaproszenie dla {{name}}?", "toastWithdrawn": "Zaproszenie wycofane" }, "page": { @@ -265,7 +267,8 @@ "lastNamePh": "np. Kowalski", "empty": "Brak użytkowników o podanych danych.", "submit": "Zaproś", - "busy": "Zapraszanie…" + "busy": "Zapraszanie…", + "sentTitle": "Wysłane zaproszenia" }, "join": { "toastOk": "Dołączono do siłowni: {{name}}", @@ -277,6 +280,54 @@ "submit": "Dołącz", "busy": "Dołączanie…" }, + "rating": { + "group": "Ocena", + "recommend": "Polecam", + "notRecommend": "Nie polecam" + }, + "contact": { + "action": "Napisz do właścicieli", + "pageTitle": "Kontakt", + "ownersTitle": "Właściciele — {{name}}", + "ownersAvatar": "Właściciele", + "threadsTitle": "Rozmowy — {{name}}", + "composerPlaceholder": "Napisz wiadomość do właścicieli…", + "composerAria": "Treść wiadomości", + "send": "Wyślij", + "sending": "Wysyłanie…", + "counter": "{{n}}/{{max}}", + "emptyThread": "Brak wiadomości — napisz pierwszą.", + "emptyThreadsTitle": "Brak rozmów", + "emptyThreadsDesc": "Członkowie tej siłowni jeszcze nie napisali.", + "deleteAria": "Usuń wiadomość", + "deleteTitle": "Usuń wiadomość", + "deleteDesc": "Tej operacji nie można cofnąć." + }, + "stats": { + "title": "Statystyki", + "visits": "Wizyty", + "visitsPerDay": "Wizyty / dzień", + "avgStay": "Śr. pobyt", + "minutes": "{{n}} min", + "peak": "Szczyt", + "live": "Teraz", + "members": "Członkowie", + "newInRange": "Nowi w okresie", + "sessionsCompleted": "Sesje ukończone", + "sessionsAbandoned": "Sesje porzucone", + "uniqueExercisers": "Ćwiczący", + "heatmapTitle": "Bytność (dzień × godzina)", + "heatmapEmpty": "Brak wizyt w tym okresie.", + "cellTitle_one": "{{day}}, {{hour}}:00 — {{count}} wizyta", + "cellTitle_few": "{{day}}, {{hour}}:00 — {{count}} wizyty", + "cellTitle_many": "{{day}}, {{hour}}:00 — {{count}} wizyt", + "cellTitle_other": "{{day}}, {{hour}}:00 — {{count}} wizyt", + "rangeAria": "Zakres statystyk", + "rangeDays_one": "{{count}} dzień", + "rangeDays_few": "{{count}} dni", + "rangeDays_many": "{{count}} dni", + "rangeDays_other": "{{count}} dni" + }, "address": { "street": "Ulica i numer", "streetPh": "np. Mokotowska 12A", diff --git a/app/src/i18n/locales/pl/messages.json b/app/src/i18n/locales/pl/messages.json index b5f6156..434259b 100644 --- a/app/src/i18n/locales/pl/messages.json +++ b/app/src/i18n/locales/pl/messages.json @@ -10,6 +10,7 @@ "roleTrainers": "Trenerzy", "youPrefix": "Ty: ", "noMessageRow": "Brak wiadomości", + "gymOwnersSection": "Właściciele siłowni", "emptyTitle": "Brak rozmów", "emptyDesc": "Rozmowa pojawi się po nawiązaniu aktywnej relacji z trenerem.", "searchNoResults": "Brak wyników dla podanego zapytania.", diff --git a/app/src/pages/gyms/GymContactPage.tsx b/app/src/pages/gyms/GymContactPage.tsx new file mode 100644 index 0000000..69004e1 --- /dev/null +++ b/app/src/pages/gyms/GymContactPage.tsx @@ -0,0 +1,358 @@ +import { Fragment, useRef, useState } from 'react'; +import { useParams, useSearchParams } from 'react-router-dom'; +import { useTranslation } from 'react-i18next'; +import { useQueryClient } from '@tanstack/react-query'; +import { MessageSquare, Send } from 'lucide-react'; +import { + deleteGymContactMessage, + sendGymContactMessage, + sendGymContactReply, + useGymContactThread, + useGymContactView, + useGymDetail, + useMe, +} from '../../api/queries'; +import type { GymContactMessage } from '../../api/types'; +import { fmtDate, fmtDateTime, timeAgo } from '../../lib/format'; +import { + BackButton, + Button, + Card, + ConfirmDialog, + EmptyState, + ErrorText, + PageHeader, + Skeleton, + Textarea, +} from '../../components/ui'; +import { Avatar } from '../../components/Avatar'; +import { useToast } from '../../components/toast'; +import { useTopbar } from '../../topbar'; + +const MAX_BODY = 1000; + +/* Bąbelek wiadomości kontaktowej (mine = prawo, other = lewo + etykieta nadawcy). */ +function Bubble({ + message, + mine, + onDelete, +}: { + message: GymContactMessage; + mine: boolean; + onDelete: (id: string) => void; +}) { + const { t } = useTranslation('gyms'); + return ( +
+ {!mine && } +
+ {!mine && ( +
+ {message.senderName} +
+ )} +
{message.body}
+
+ {mine && ( + + )} + {fmtDateTime(message.createdAt)} +
+
+
+ ); +} + +/* Komposer: textarea + licznik znaków + Wyślij (limit po stronie API: 1–1000). */ +function Composer({ onSend, busy }: { onSend: (body: string) => void; busy: boolean }) { + const { t } = useTranslation('gyms'); + const [body, setBody] = useState(''); + const send = () => { + const text = body.trim(); + if (!text) return; + onSend(text); + setBody(''); + }; + return ( + +