diff --git a/src/components/common/TicketEditor/TicketEditor.tsx b/src/components/common/TicketEditor/TicketEditor.tsx index 8555c8b6..c74402ca 100644 --- a/src/components/common/TicketEditor/TicketEditor.tsx +++ b/src/components/common/TicketEditor/TicketEditor.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import { useStores } from 'store'; import { ActionButton, TicketButtonGroup } from '../../../people/widgetViews/workspace/style'; import { TicketContainer, TicketHeader, TicketTextArea } from '../../../pages/tickets/style'; @@ -23,6 +23,21 @@ const TicketEditor = ({ ticketData }: TicketEditorProps) => { const [description, setDescription] = useState(''); const { main } = useStores(); + useEffect(() => { + const fetchTicketDetails = async () => { + try { + const ticket = await main.getTicketDetails(ticketData.uuid); + if (ticket) { + setDescription(ticket.description || ''); + } + } catch (error) { + console.error('Error fetching ticket details:', error); + } + }; + + fetchTicketDetails(); + }, [ticketData.uuid, main]); + const handleUpdate = async () => { const updateTicketData = { uuid: ticketData.uuid, diff --git a/src/store/main.ts b/src/store/main.ts index 5fb95c6a..d6c8cbaf 100644 --- a/src/store/main.ts +++ b/src/store/main.ts @@ -3727,6 +3727,32 @@ export class MainStore { } } + async getTicketDetails(uuid: string): Promise { + try { + if (!uiStore.meInfo) return null; + const info = uiStore.meInfo; + + const response = await fetch(`${TribesURL}/bounties/ticket/${uuid}`, { + method: 'GET', + mode: 'cors', + headers: { + 'x-jwt': info.tribe_jwt, + 'Content-Type': 'application/json' + } + }); + + if (!response.ok) { + throw new Error('Failed to fetch ticket details'); + } + + const data = await response.json(); + return data; + } catch (error) { + console.error('Error fetching ticket details:', error); + return null; + } + } + async createConnectionCodes(users_number: number): Promise { try { if (!uiStore.meInfo) return 406;