diff --git a/api/controllers/links_shortener.js b/api/controllers/links_shortener.js
index eac7749..5e8c087 100644
--- a/api/controllers/links_shortener.js
+++ b/api/controllers/links_shortener.js
@@ -79,7 +79,8 @@ exports.postLink = async (req, res, next) => {
const shortcutLinkResult = `${shortLinkBaseURL}/${result.shortcut}`
return res.status(200).json({
resultHTML: `URL Raccourcie :
${shortcutLinkResult}`,
- result: shortcutLinkResult
+ result: shortcutLinkResult,
+ linkDatabase: result
})
} catch (error) {
console.log(error)
diff --git a/website/pages/functions/linkShortener.jsx b/website/pages/functions/linkShortener.jsx
index de5ccfa..79adc94 100644
--- a/website/pages/functions/linkShortener.jsx
+++ b/website/pages/functions/linkShortener.jsx
@@ -16,9 +16,9 @@ import 'notyf/notyf.min.css'
import '../../public/css/pages/FunctionComponent.css'
import '../../public/css/pages/admin.css'
-const CreateLink = () => {
+const CreateLink = ({ linksData, setLinksData }) => {
const { isAuth, user } = useContext(UserContext)
- const [inputState, setInputState] = useState({})
+ const [inputState, setInputState] = useState({ url: '', shortcutName: '' })
const [message, setMessage] = useState('')
const [isLoading, setIsLoading] = useState(false)
@@ -29,6 +29,9 @@ const CreateLink = () => {
const response = await api.post('/links', inputState, {
headers: { Authorization: user.token }
})
+ const linksDataState = { ...linksData }
+ linksDataState.rows.push(response.data.linkDatabase)
+ setLinksData(linksDataState)
setMessage(response.data.resultHTML)
setIsLoading(false)
setInputState({ url: '', shortcutName: '' })
@@ -66,6 +69,7 @@ const CreateLink = () => {
Entrez le lien à raccourcir :
{
Entrez le nom du raccourci :
{
}
let pageLinks = 1
-const LinksList = () => {
+const LinksList = ({
+ linksData,
+ setLinksData,
+ isLoadingLinks,
+ setLoadingLinks
+}) => {
const { isAuth, user } = useContext(UserContext)
- const [linksData, setLinksData] = useState({
- hasMore: true,
- rows: [],
- totalItems: 0
- })
- const [isLoadingLinks, setLoadingLinks] = useState(true)
const [isEditing, setIsEditing] = useState(false)
const [defaultInputState, setDefaultInputState] = useState({
@@ -288,7 +292,11 @@ const LinksList = () => {