diff --git a/src/components/page/ticket/Comments.jsx b/src/components/page/ticket/TicketComment.jsx
similarity index 97%
rename from src/components/page/ticket/Comments.jsx
rename to src/components/page/ticket/TicketComment.jsx
index d08e3121..57cca210 100644
--- a/src/components/page/ticket/Comments.jsx
+++ b/src/components/page/ticket/TicketComment.jsx
@@ -2,12 +2,12 @@ import IconLoader from "../../IconLoader"
import FieldData from "../../../functions/FieldData"
import { useEffect, useState } from "react"
import { apiFetch } from "../../../hooks/apiFetch"
-import TicketCommentForm from "./Comment"
+import TicketCommentForm from "./TicketCommentForm"
import { secondsToTime } from "../../../layout/Ticket"
-const TicketComments = ({
+const TicketComment = ({
discussion = false,
comment_data = {},
metadata = null,
@@ -58,6 +58,7 @@ const TicketComments = ({
const comment_header_text_updated = (Updated )
const comment_header_text = (
+ metadata && comment_data &&
- {threads.results.map((comment, index) => (
+ { threads.results &&
+ threads.results.map((comment, index) => (
-
- {
+
+ const [comments, setComments] = useState(null)
+ const [ reload, setRelaod ] = useState(false)
+
+
+ useEffect(() => {
+
+ apiFetch(
+
+ comments_url,
+ (data) =>{
+
+ setComments(data)
+
+ },
+ )
+
+ }, [reload, comments_url])
+
+
+ return (
+ (comments && comment_metadata) &&
+
+
+ {comments.results.map((comment) => {
+
+ return (
+ comment_metadata &&
+ -
+
+
+ )
+ })}
+ {comment_metadata &&
+ -
+ {
+ setRelaod(reload ? false : true )
+ }}
+ />
+
+ }
+
+
+ );
+}
+
+export default TicketComments;
\ No newline at end of file
diff --git a/src/layout/Ticket.jsx b/src/layout/Ticket.jsx
index e4f9b246..f99f21b3 100644
--- a/src/layout/Ticket.jsx
+++ b/src/layout/Ticket.jsx
@@ -2,11 +2,11 @@ import { useEffect, useState } from "react";
import { Link, useLoaderData, useParams } from "react-router-dom";
import FieldData from "../functions/FieldData";
-import TicketComments from "../components/page/ticket/Comments";
import { apiFetch } from "../hooks/apiFetch";
-import TicketCommentForm from "../components/page/ticket/Comment";
import LinkedItems from "../components/page/ticket/LinkedItems";
import RelatedTickets from "../components/page/ticket/RelatedTickets";
+import TicketComments from "../components/page/ticket/TicketComments";
+import urlBuilder from "../hooks/urlBuilder";
@@ -37,7 +37,6 @@ const Ticket = ({
SetContentHeaderIcon('')
const [comments, setComments] = useState(null)
- const [ reload, setRelaod ] = useState(false)
const [comment_metadata, setCommentMetaData] = useState(null);
@@ -82,32 +81,21 @@ const Ticket = ({
useEffect(() => {
- apiFetch(
- params.module + '/ticket/' + params.model + '/' + params.pk + '/comments?page[size]=500',
- (data) =>{
-
- setComments(data)
-
- },
- )
-
- }, [params, reload])
-
-
- useEffect(() => {
+ if( page_data['_urls']['comments'] ) {
+ apiFetch(
+ page_data['_urls']['comments'],
+ (data) =>{
- apiFetch(
- params.module + '/ticket/' + params.model + '/' + params.pk + '/comments',
- (data) =>{
+ setCommentMetaData(data)
- setCommentMetaData(data)
+ },
+ 'OPTIONS'
+ )
+ }
- },
- 'OPTIONS'
- )
+ }, [page_data['_urls']['comments']])
- }, [params])
return (
metadata !== null &&
@@ -154,43 +142,28 @@ const Ticket = ({
+ { page_data['_urls']['related_tickets'] &&
+ />}
+ { page_data['_urls']['linked_items'] &&
-
-
-
- {(comments != null && comment_metadata != null) && comments.results.map((comment) => {
-
- return (
- -
-
-
- )
- })}
- {comment_metadata != null &&
- -
- {
- setRelaod(true)
- }}
- />
-
- }
-
-
+ />}
+
+ { (
+ comment_metadata
+ && page_data['_urls']['comments']
+ && page_data['id']
+
+ ) &&
+ }