source: reactapp/src/Pages/UserDashboard.js@ a5aba17

main
Last change on this file since a5aba17 was af801e3, checked in by viktor <viktor@…>, 2 years ago

finished edit/delete/displace opinion/thread from report (react); todo reporting user/opinion/thread interface, public user pages and messaging (springboot)

  • Property mode set to 100644
File size: 30.3 KB
Line 
1/* eslint-disable no-unused-vars */
2// noinspection JSUnresolvedVariable,ES6ConvertVarToLetConst,JSUnresolvedFunction,SpellCheckingInspection,JSUnusedLocalSymbols
3
4import React, { useEffect, useState, useContext } from "react";
5import {
6 OpinionCard,
7 OpinionCardContent,
8 OpinionCardContentTime,
9} from "../Components/Styled/OpinionCard.style";
10import {
11 UserDetailsCard,
12 UserDetailsCardContent,
13} from "../Components/Styled/UserDetails.style";
14import { dateConverter } from "../Util/dateConverter";
15import axios from "../api/axios";
16import JSOG from "jsog";
17import AuthApi from "../api/AuthApi";
18import {EntityLi, EntityTypeSelector, EntityUl} from "../Components/Styled/EntityList.style";
19import {
20 AddOpinionButton,
21 Modal,
22 ModalBody,
23 ModalClose,
24 ModalContent, ModalFooter,
25 ModalHeader, ModalTextarea,
26 ModalInput
27} from "../Components/Styled/Modal.style";
28import LoadingSpinner from "../Components/Styled/LoadingSpinner.style";
29
30function UserDashboard() {
31 const { auth, setAuth } = useContext(AuthApi);
32
33 const [user, setUser] = useState(null);
34 const [loadedUser, setLoadedUser] = useState(false);
35 const [fetchError, setFetchError] = useState(false);
36
37 const [postReports, setPostReports] = useState(null);
38 const [loadedPostReports, setLoadedPostReports] = useState(false);
39
40 const [reportModalDisplay, setReportModalDisplay] = useState("none");
41 const [reportForModal, setReportForModal] = useState(null);
42
43 const [actionType, setActionType] = useState(0);
44
45 const [newPostContent, setNewPostContent] = useState("");
46 const [newOpinionTargetProfessorId, setNewOpinionTargetProfessorId] = useState("");
47 const [newOpinionTargetProfessor, setNewOpinionTargetProfessor] = useState(null);
48 const [loadedNewProfessor,setLoadedNewProfessor] = useState(false);
49 const [newParentPostId, setNewParentPostId] = useState("-1");
50
51 const [newThreadTitle, setNewThreadTitle] = useState("");
52 const [newParentThreadId,setNewParentThreadId] = useState("-1");
53 const [newTargetSubjectId, setNewTargetSubjectId] = useState("");
54 const [newTargetSubject, setNewTargetSubject] = useState(null);
55 const [loadedNewSubject, setLoadedNewSubject] = useState(null);
56
57 const [markResolved, setMarkResolved] = useState(false);
58
59 const [errMsg, setErrMsg] = useState("");
60
61 const handleModalCloseClick = () => {
62 setReportForModal(null);
63 setReportModalDisplay("none");
64 document.body.style.overflowY = "auto";
65 };
66
67 const handleViewReportButtonClick = (e,report) => {
68 e.preventDefault();
69 setReportForModal(report);
70 }
71
72 useEffect(() => {
73 if(reportForModal!==null) {
74 if (reportForModal.post !== null) {
75 setNewPostContent(reportForModal.post.content);
76 if(reportForModal.post.title !== null) setNewThreadTitle(reportForModal.post.title);
77 if(reportForModal.post.targetProfessor !== undefined) setNewOpinionTargetProfessorId(reportForModal.post.targetProfessor.professorId); //prvicnoto
78 if(reportForModal.post.targetProfessor === undefined) setNewTargetSubjectId(reportForModal.post.targetSubject.subjectId); //prvicnoto
79 }
80 setReportModalDisplay("block");
81 document.body.style.overflowY = "hidden";
82 }
83 }, [reportForModal]);
84
85 const[loadingProf, setLoadingProf] = useState(false);
86
87 const handleNewTargetProfessorChange = async (e) => {
88 setLoadingProf(true);
89 e.preventDefault();
90 if (newOpinionTargetProfessorId!=="") {
91 try {
92 const response = await axios.get(`http://192.168.0.29:8080/public/professor/${newOpinionTargetProfessorId}`, {withCredentials: true});
93 let cyclicGraph = await response.data;
94 var jsogStructure = JSOG.encode(cyclicGraph);
95 cyclicGraph = JSOG.decode(jsogStructure);
96 setNewOpinionTargetProfessor(cyclicGraph);
97 setLoadedNewProfessor(true);
98 setLoadingProf(false);
99 } catch (error) {
100 setFetchError(true);
101 }
102 }
103 }
104
105 const[loadingSubj, setLoadingSubj] = useState(false);
106
107 const handleNewTargetSubjectChange = async (e) => {
108 e.preventDefault();
109 setLoadingSubj(true);
110 if (newTargetSubjectId!=="") {
111 try {
112 const response = await axios.get(`http://192.168.0.29:8080/public/subject/${newTargetSubjectId}`, {withCredentials: true});
113 let cyclicGraph = await response.data;
114 var jsogStructure = JSOG.encode(cyclicGraph);
115 cyclicGraph = JSOG.decode(jsogStructure);
116 setNewTargetSubject(cyclicGraph);
117 setLoadedNewSubject(true);
118 setLoadingSubj(false);
119 } catch (error) {
120 setFetchError(true);
121 }
122 }
123 }
124
125 useEffect(() => {
126 const url1 = `http://192.168.0.29:8080/secure/currentUser`;
127 const url2 = `http://192.168.0.29:8080/secure/getAllPostReports`;
128
129 const fetchUser = async () => {
130 try {
131 if(!loadedUser) {
132 const response = await axios.get(url1, {withCredentials: true});
133 let cyclicGraph = await response.data;
134 var jsogStructure = JSOG.encode(cyclicGraph);
135 cyclicGraph = JSOG.decode(jsogStructure);
136 setUser(cyclicGraph);
137 setLoadedUser(true);
138 }
139 if(user.userRole==='MODERATOR')fetchPostReports();
140 } catch (error) {
141 setFetchError(true);
142 }
143 };
144
145 const fetchPostReports = async () => {
146 try {
147 const response = await axios.get(url2, {withCredentials: true});
148 var cyclicGraph = await response.data;
149 var jsogStructure = JSOG.encode(cyclicGraph);
150 cyclicGraph = JSOG.decode(jsogStructure);
151 setPostReports(cyclicGraph);
152 setLoadedPostReports(true);
153 } catch (error) {
154 setFetchError(true);
155 }
156 };
157
158 if (auth) fetchUser();
159
160 }, [user]);
161
162 // useEffect(() => {
163 // const timer = setTimeout(() => {
164 // if (user === null) window.location.reload(); <---- :-)
165 // }, 3000);
166 // return () => clearTimeout(timer);
167 // }, []);
168
169 function findParentThread(post) {
170 if (post.parent === null) return post;
171 return findParentThread(post.parent);
172 }
173
174 const handleEdit = async (e) => {
175 e.preventDefault();
176 try {
177 if(reportForModal.post !== null && reportForModal.post.targetProfessor !== undefined) {
178 await axios(`http://192.168.0.29:8080/secure/updateOpinion/${reportForModal.post.postId}`,
179 {
180 method: "put",
181 data: {
182 newContent: newPostContent,
183 newTargetProfessorId: reportForModal.post.targetProfessor.professorId,
184 newParentPostId: reportForModal.post.parent !== null ? reportForModal.post.parent.postId : "-1"
185 },
186 withCredentials: true,
187 })
188 } else if(reportForModal.post !== null && reportForModal.post.targetProfessor === undefined) {
189 await axios(`http://192.168.0.29:8080/secure/updateThread/${reportForModal.post.postId}`,
190 {
191 method: "put",
192 data: {
193 newTitle: newThreadTitle,
194 newContent: newPostContent,
195 newTargetSubjectId: reportForModal.post.targetSubject.subjectId,
196 newParentThreadId: reportForModal.post.parent !== null ? reportForModal.post.parent.postId : "-1"
197 },
198 withCredentials: true,
199 })
200 }
201 await axios(`http://192.168.0.29:8080/secure/markReportResolved/${reportForModal.postReportId}/${markResolved ? `resolve` : `open`}`,{
202 method: "get",
203 withCredentials: true
204 })
205 } catch (error) {
206 setFetchError(true);
207 }
208 window.location.reload();
209 }
210
211 const handleRelocate = async (e) => {
212 e.preventDefault();
213 try {
214 if(reportForModal.post !== null && reportForModal.post.targetProfessor !== undefined) {
215 var response = await axios(`http://192.168.0.29:8080/secure/updateOpinion/${reportForModal.post.postId}`,
216 {
217 method: "put",
218 data: {
219 newContent: reportForModal.post.content,
220 newTargetProfessorId: newOpinionTargetProfessorId,
221 newParentPostId: newParentPostId==="Постави како самостојно мислење" ? "-1" : newParentPostId //:)
222 },
223 withCredentials: true,
224 })
225 } else if(reportForModal.post !== null && reportForModal.post.targetProfessor === undefined) {
226 var response = await axios(`http://192.168.0.29:8080/secure/updateThread/${reportForModal.post.postId}`,
227 {
228 method: "put",
229 data: {
230 newTitle: newThreadTitle,
231 newContent: reportForModal.post.content,
232 newTargetSubjectId: newTargetSubjectId,
233 newParentThreadId: newParentThreadId==="Постави како самостојно мислење (нова тема)" ? "-1" : newParentThreadId //:)
234 },
235 withCredentials: true,
236 })
237 }
238 await axios(`http://192.168.0.29:8080/secure/markReportResolved/${reportForModal.postReportId}/${markResolved ? `resolve` : `open`}`,{
239 method: "get",
240 withCredentials: true
241 })
242 } catch (error) {
243 setFetchError(true);
244 }
245 setErrMsg(response.data);
246 if (response.data==="") window.location.reload();
247 }
248
249 const handleDelete = async (e) => {
250 e.preventDefault();
251 try {
252 if(reportForModal.post !== null && reportForModal.post.targetProfessor !== undefined) {
253 await axios(`http://192.168.0.29:8080/secure/deleteOpinion/${reportForModal.post.postId}`,
254 {
255 method: "delete",
256 withCredentials: true,
257 })
258 window.location.reload();
259 } else if(reportForModal.post !== null && reportForModal.post.targetProfessor === undefined) {
260 await axios(`http://192.168.0.29:8080/secure/deleteThread/${reportForModal.post.postId}`,
261 {
262 method: "delete",
263 withCredentials: true,
264 })
265 }
266 } catch (error) {
267 setFetchError(true);
268 }
269 window.location.reload();
270 }
271
272 const handleMarkResolved = () => {
273 if (actionType !== 1) setMarkResolved(!markResolved);
274 }
275
276 return loadedUser ? (
277 <>
278 <h3>Кориснички податоци:</h3>
279 <UserDetailsCard>
280 {user.fullName && (
281 <UserDetailsCardContent>
282 <b>Име:</b> {user.fullName}{" "}
283 </UserDetailsCardContent>
284 )}
285 <UserDetailsCardContent>
286 <b>Корисничко име:</b> {user.username}{" "}
287 </UserDetailsCardContent>
288 <UserDetailsCardContent>
289 <b>E-mail:</b> {user.email}
290 </UserDetailsCardContent>
291 <UserDetailsCardContent>
292 <b>Карма:</b>{" "}
293 <span style={{ color: user.karma < 0 ? "indianred" : "green" }}>
294 {user.karma}
295 </span>
296 </UserDetailsCardContent>
297 </UserDetailsCard>
298 {loadedPostReports ? postReports.length > 0 ? (
299 <h3 style={{ marginBottom: "10px" }}>Пријави за мислења:</h3>
300 ) : (
301 <h3>Нема пријавени мислења</h3>
302 ) : loadedUser && user.userRole==='MODERATOR' ? <LoadingSpinner/> : ""}
303 <EntityUl style={{marginTop:"25px"}}>
304 {loadedPostReports && postReports.map((postReport) => {
305 return <EntityLi bgcolor="cornsilk" key={postReport.postReportId} style={{padding:"15px"}}>
306 <p style={{color: postReport.resolved ? "grey" : "black"}}><span style={{fontSize:"14px", fontStyle:"italic", fontWeight:"normal"}}>{dateConverter(
307 new Date(postReport.time).toString().slice(4, -43)
308 )}</span><br/>{postReport.description.substring(0,45 )}{postReport.description.length >= 45 ? ("...") : ("")} {postReport.resolved ? <span style={{fontStyle:"italic"}}>(разрешено)</span> : ""}
309 </p>
310 <AddOpinionButton onClick={(e)=>handleViewReportButtonClick(e,postReport)} style={{height:"30px", padding:"5px", fontSize:"14px", position:"absolute", top:"30%", right:"20px" }}>Разгледај</AddOpinionButton>
311 </EntityLi>;
312 })}
313 </EntityUl>
314 {user.authoredPosts.length > 0 ? (
315 <h3 style={{ marginBottom: "10px", marginTop:"30px" }}>Ваши мислења:</h3>
316 ) : (
317 <h3 style={{ marginBottom: "10px" }}>Немате објавени мислења</h3>
318 )}
319 {user.authoredPosts.map((post) => {
320 return (
321 <div key={post.postId}>
322 <OpinionCard>
323 <OpinionCardContent>
324 <p style={{ fontStyle: "italic", marginBottom: "10px" }}>
325 во дискусија за{" "}
326 {post.targetProfessor !== undefined ? (
327 <a href={"/professor/" + post.targetProfessor.professorId}>
328 {post.targetProfessor.professorName}
329 </a>
330 ) : (
331 <a
332 href={
333 post.parent === null
334 ? "/topic/" + post.postId
335 : "/topic/" + findParentThread(post).postId
336 }
337 >
338 {post.targetSubject.subjectName}
339 </a>
340 )}
341 </p>
342 <p style={{ marginBottom: "10px" }}>{post.content}</p>
343 <OpinionCardContentTime>
344 {dateConverter(
345 new Date(post.timePosted).toString().slice(4, -43)
346 )} <span style={{fontStyle:"normal",color:"blue"}}>#{post.postId}</span>
347 </OpinionCardContentTime>
348 </OpinionCardContent>
349 </OpinionCard>
350 </div>
351 );
352 })}
353 {reportForModal && (
354 <Modal display={reportModalDisplay}>
355 <ModalContent>
356 <ModalHeader>
357 <ModalClose onClick={handleModalCloseClick}>&times;</ModalClose>
358 <h3 style={{ marginTop: "5px" }}>
359 Преглед на пријава за мислење
360 </h3>
361 </ModalHeader>
362 <ModalBody>
363 <p style={{fontWeight:"bold",marginBottom:"15px"}}>Пријавил: <span style={{fontWeight:"normal"}}>{reportForModal.user !== null ? <a href={"/user/"+reportForModal.user.id}>{reportForModal.user.username}</a> : "(избришан корисник)"}</span></p>
364 <p style={{fontWeight:"bold",marginBottom:"15px"}}>Време на пријава: <span style={{fontWeight:"normal"}}>{dateConverter(
365 new Date(reportForModal.time).toString().slice(4, -43)
366 )}</span></p>
367 <p style={{fontWeight:"bold",marginBottom:"15px"}}>Образложение: </p> <p style={{marginBottom:"15px"}}>{reportForModal.description}</p>
368 <p style={{fontWeight:"bold", marginBottom:"15px"}}>Информации за пријавеното мислење:</p>
369 {reportForModal.post !== null ?
370 <OpinionCard>
371 <OpinionCardContent>
372 <p style={{fontStyle: "italic", marginBottom: "10px"}}>
373 во дискусија за{" "}
374 {reportForModal.post.targetProfessor !== undefined ? (
375 <a href={"/professor/" + reportForModal.post.targetProfessor.professorId}>
376 {reportForModal.post.targetProfessor.professorName}
377 </a>
378 ) : (
379 <a
380 href={
381 reportForModal.post.parent === null
382 ? "/topic/" + reportForModal.post.postId
383 : "/topic/" + findParentThread(reportForModal.post).postId
384 }
385 >
386 {reportForModal.post.targetSubject.subjectName}
387 </a>
388 )}
389 </p>
390 {reportForModal.post.title === null ?
391 <p style={{ fontStyle: "italic", marginBottom: "10px" }}>
392 <a href={"/user/" + reportForModal.post.author.id}>
393 {reportForModal.post.author.username}
394 </a>{" "}
395 напишал
396 </p> :
397 <p style={{ fontStyle: "italic", marginBottom: "10px" }}>
398 <a href={"/user/" + reportForModal.post.author.id}>
399 {reportForModal.post.author.username}
400 </a>{" "}
401 отворил тема со наслов <span style={{fontWeight:"bold"}}>{reportForModal.post.title}</span>
402 </p>
403 }
404 <p style={{marginBottom: "10px"}}>{reportForModal.post.content}</p>
405 <OpinionCardContentTime>
406 {dateConverter(
407 new Date(reportForModal.post.timePosted).toString().slice(4, -43)
408 )} <span style={{fontStyle:"normal",color:"blue"}}>#{reportForModal.post.postId}</span>
409 </OpinionCardContentTime>
410 </OpinionCardContent>
411 </OpinionCard>
412 : "Пријавеното мислење или неговиот автор се избришани"}
413
414 {reportForModal.post !== null &&
415 <div style={{ display: "flex" }}>
416 {actionType===0 ? <EntityTypeSelector
417 backgroundcolor="rgba(0, 102, 204, 1)"
418 color="white"
419 boxshadow="none"
420 boxshadowhover="none"
421 opacityhover="0.6"
422 cursor="auto"
423 >
424 Измени содржина или наслов
425 </EntityTypeSelector> : <EntityTypeSelector
426 boxshadow="2px 2px 5px #aaaaaa"
427 cursor="pointer"
428 boxshadowhover="2px 2px 10px #aaaaaa"
429 opacityhover="1"
430 onClick={() => setActionType(0)}
431 >
432 Измени содржина или наслов
433 </EntityTypeSelector>}
434 {actionType===1 ? <EntityTypeSelector
435 backgroundcolor="rgba(0, 102, 204, 1)"
436 color="white"
437 boxshadow="none"
438 boxshadowhover="none"
439 opacityhover="0.6"
440 cursor="auto"
441 >
442 Избриши
443 </EntityTypeSelector> : <EntityTypeSelector
444 boxshadow="2px 2px 5px #aaaaaa"
445 cursor="pointer"
446 boxshadowhover="2px 2px 10px #aaaaaa"
447 opacityhover="1"
448 onClick={() => {setActionType(1); setMarkResolved(true)}}
449 >
450 Избриши
451 </EntityTypeSelector>}
452 {actionType===2 ? <EntityTypeSelector
453 backgroundcolor="rgba(0, 102, 204, 1)"
454 color="white"
455 boxshadow="none"
456 boxshadowhover="none"
457 opacityhover="0.6"
458 cursor="auto"
459 >
460 Премести
461 </EntityTypeSelector> : <EntityTypeSelector
462 boxshadow="2px 2px 5px #aaaaaa"
463 cursor="pointer"
464 boxshadowhover="2px 2px 10px #aaaaaa"
465 opacityhover="1"
466 onClick={() => setActionType(2)}
467 >
468 Премести
469 </EntityTypeSelector>}
470 </div>}
471 {reportForModal.post !== null ?
472 actionType === 0 ?
473 (<form onSubmit={e => handleEdit(e)}>
474 {reportForModal.post.title !== null &&
475 <label>
476 <b>Нов наслов на тема:</b>
477 <ModalInput
478 value={newThreadTitle}
479 onChange={e => setNewThreadTitle(e.target.value)}
480 id="title"
481 spellCheck={false}
482 style={{marginTop:"10px"}}
483 />
484 </label>}
485 <label>
486 <b>Нова содржина:</b>
487 <ModalTextarea
488 value={newPostContent}
489 onChange={e => setNewPostContent(e.target.value)}
490 id="content"
491 rows="8"
492 cols="100"
493 spellCheck={false}
494 style={{marginTop:"10px"}}
495 />
496 </label>
497 <div style={{marginTop:"15px"}}>
498 <label>
499 <input
500 type="checkbox"
501 onChange={handleMarkResolved}
502 />
503 <span style={{marginLeft:"10px", fontWeight:"bold"}}>Означи како разрешено</span>
504 </label>
505 </div>
506 <ModalFooter type="submit">ПОТВРДИ</ModalFooter>
507 </form>)
508 : actionType === 1 ?
509 (<form onSubmit={e => handleDelete(e)}>
510 <p style={{color:"red", display:"flex", justifyContent:"space-around"}}>Избриши го мислењето? (оваа акција е иреверзибилна)</p>
511 <div style={{marginTop:"15px"}}>
512 <label>
513 <input
514 type="checkbox"
515 checked={markResolved}
516 onChange={handleMarkResolved}
517 />
518 <span style={{marginLeft:"10px", fontWeight:"bold"}}>Означи како разрешено</span>
519 </label>
520 </div>
521 <ModalFooter type="submit">ПОТВРДИ</ModalFooter>
522 </form>)
523 :
524 (reportForModal.post.targetProfessor !== undefined ?
525 (<form onSubmit={e => handleRelocate(e)}>
526 <p style={{color:"black"}}>Внеси <span style={{fontWeight:"bold"}}>ID</span> на секцијата за дискусија (за <span style={{fontWeight:"bold"}}>професор</span>)
527 во која треба да биде преместено мислењето:</p>
528 <div style={{marginTop:"15px"}}>
529 <label>
530 <ModalInput
531 value={newOpinionTargetProfessorId}
532 onChange={e => {e.preventDefault();setNewOpinionTargetProfessorId(e.target.value)}}
533 id="newOpinionTargetProfessorId"
534 spellCheck={false}
535 style={{marginTop:"10px", marginBottom:"10px", width:"90px"}}
536 />
537 <button onClick={async (e) => {await handleNewTargetProfessorChange(e);}} style={{marginBottom:"10px", padding:"5px", fontFamily: "Roboto Mono, monospace"}}>Зачувај</button>
538 {newOpinionTargetProfessor!==null && !loadingProf ? <p style={{color:"black", marginBottom:"20px", opacity:"50%"}}>Мислењето ќе се премести во секцијата за професорот со <span style={{fontWeight:"bold"}}>ID=
539 {newOpinionTargetProfessor.professorId}</span> (<span style={{fontWeight:"bold"}}>{newOpinionTargetProfessor.professorName}</span>)</p> : loadingProf ? <LoadingSpinner style={{marginBottom:"15px", marginTop:"15px"}}/> : null}
540 {newOpinionTargetProfessor && <p style={{color:"black", marginBottom:"10px"}}>Постави како дете на мислење со ID:</p>}
541 {newOpinionTargetProfessor &&
542 <select value={newParentPostId} onChange={e => setNewParentPostId(e.target.value)} style={{width:"280px", display:"block", padding:"5px",marginBottom:"5px", fontFamily: "Roboto Mono, monospace"}}>
543 <option value="-1">Постави како самостојно мислење</option>
544 {newOpinionTargetProfessor.relatedOpinions.filter((opinion)=>opinion.postId!==reportForModal.post.postId).map((opinion) => {
545 return <option key={opinion.postId} value={opinion.postId}>{opinion.postId}</option>})
546 }
547 </select>}
548 <br/>
549 <input
550 type="checkbox"
551 defaultChecked={reportForModal.resolved}
552 onChange={handleMarkResolved}
553 />
554 <span style={{marginLeft:"10px", fontWeight:"bold"}}>Означи како разрешено</span>
555 </label>
556 </div>
557 {errMsg!=="" && <p style={{color:"red", display:"flex", justifyContent:"space-around"}}>{errMsg}</p>}
558 <ModalFooter type="submit">ПОТВРДИ</ModalFooter>
559 </form>) :
560 //THREAD CASE
561 (<form onSubmit={e => handleRelocate(e)}>
562 <p style={{color:"black"}}>Внеси <span style={{fontWeight:"bold"}}>ID</span> на секцијата за дискусија (за <span style={{fontWeight:"bold"}}>предмет</span>)
563 во која треба да биде преместено мислењето:</p>
564 <div style={{marginTop:"15px"}}>
565 <label>
566 <ModalInput
567 value={newTargetSubjectId}
568 onChange={e => {e.preventDefault();setNewTargetSubjectId(e.target.value)}}
569 id="newTargetSubjectId"
570 spellCheck={false}
571 style={{marginTop:"10px", marginBottom:"10px", width:"90px"}}
572 />
573 <button onClick={async (e) => {await handleNewTargetSubjectChange(e);}} style={{marginBottom:"10px", padding:"5px", fontFamily: "Roboto Mono, monospace"}}>Зачувај</button>
574 {newTargetSubject!==null && !loadingSubj ? <p style={{color:"black", marginBottom:"20px", opacity:"50%"}}>Мислењето ќе се премести во секцијата за предметот со <span style={{fontWeight:"bold"}}>ID=
575 {newTargetSubject.subjectId}</span> (<span style={{fontWeight:"bold"}}>{newTargetSubject.subjectName}</span>)</p> : loadingSubj ? <LoadingSpinner style={{marginBottom:"15px", marginTop:"15px"}}/> : null}
576 {newTargetSubject && <p style={{color:"black", marginBottom:"10px"}}>Постави како дете на мислење со ID:</p>}
577 {newTargetSubject &&
578 <select value={newParentThreadId} onChange={e => setNewParentThreadId(e.target.value)} style={{width:"370px", display:"block", padding:"5px",marginBottom:"5px", fontFamily: "Roboto Mono, monospace"}}>
579 <option value="-1">Постави како самостојно мислење (нова тема)</option>
580 {newTargetSubject.threads.filter((thread)=>thread.postId!==reportForModal.post.postId).map((thread) => {
581 return <option key={thread.postId} value={thread.postId}>{thread.postId}</option>})
582 }
583 </select>}
584 {newParentThreadId==="-1" && loadedNewSubject &&
585 <>
586 <p style={{marginTop:"10px"}}>Наслов на нова тема:</p>
587 <ModalInput
588 value={newThreadTitle}
589 onChange={e => setNewThreadTitle(e.target.value)}
590 id="titleChangeRelocate"
591 spellCheck={false}
592 style={{marginTop:"10px"}}
593 />
594 </>}
595 <br/>
596 <input
597 type="checkbox"
598 defaultChecked={reportForModal.resolved}
599 onChange={handleMarkResolved}
600 />
601 <span style={{marginLeft:"10px", fontWeight:"bold"}}>Означи како разрешено</span>
602 </label>
603 </div>
604 {errMsg!=="" && <p style={{color:"red", display:"flex", justifyContent:"space-around"}}>{errMsg}</p>}
605 <ModalFooter type="submit">ПОТВРДИ</ModalFooter>
606 </form>))
607 : null
608 }
609 </ModalBody>
610 </ModalContent>
611 </Modal>
612 )}
613 </>
614 ) : (
615 <LoadingSpinner/>
616 );
617}
618
619export default UserDashboard;
Note: See TracBrowser for help on using the repository browser.