-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d28f8f2
commit f82746f
Showing
5 changed files
with
51 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import Row from 'react-bootstrap/Row'; | ||
import Col from 'react-bootstrap/Col'; | ||
import React, { useState, useEffect } from "react"; | ||
import ThoughtsList from './components/Thoughts/List'; | ||
|
||
import CrudDataRepository from '../repositories/crudDataRepository'; | ||
import CrudAdapter from '../adapters/crudAdapter'; | ||
import { useParams } from "react-router-dom"; | ||
|
||
const ThoughtsAssociations = () => { | ||
const { id } = useParams(); | ||
const [associatons, setAssociatons] = useState([]); | ||
const [thought, setThought] = useState(null); | ||
|
||
const apiAdapter = CrudAdapter(process.env.REACT_APP_BE_API_URL); | ||
const thoughtsRepository = CrudDataRepository(apiAdapter, 'api/thoughts'); | ||
const associatonsRepository = CrudDataRepository(apiAdapter, 'api/associations/'); | ||
|
||
useEffect(() => { | ||
const fetchAssociations = async () => { | ||
const data = await associatonsRepository.getItemById(id); | ||
setAssociatons(data); | ||
}; | ||
fetchAssociations(); | ||
|
||
const fetchThought = async () => { | ||
const data = await thoughtsRepository.getItemById(id); | ||
|
||
setThought(data.content.replace(/\n/g, "<br />")); | ||
}; | ||
fetchThought(); | ||
}, [id]); | ||
|
||
return <Row> | ||
<Col> | ||
<h4>Thought: </h4> | ||
<div dangerouslySetInnerHTML={{ __html: thought}} /> | ||
|
||
<hr/> | ||
<ThoughtsList items={associatons}/> | ||
</Col> | ||
</Row>; | ||
}; | ||
|
||
export default ThoughtsAssociations; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters