diff --git a/src/client/AdminRoot.tsx b/src/client/AdminRoot.tsx index 1ec2666..6ddd49f 100644 --- a/src/client/AdminRoot.tsx +++ b/src/client/AdminRoot.tsx @@ -8,12 +8,13 @@ import ArticleTable from './ArticleTable'; */ export default function AdminRoot() { return ( - +

Admin index

-
); } diff --git a/src/client/ArticleTable.tsx b/src/client/ArticleTable.tsx index 7950758..fd02d85 100644 --- a/src/client/ArticleTable.tsx +++ b/src/client/ArticleTable.tsx @@ -18,13 +18,22 @@ export default function ArticleTable() { }).then((articles: any) => { var $articles: any = []; articles.data.forEach((article: any) => { + const tags: Array = []; + for (let i = 0; i < article.tags.length; i++) { + if (i < article.tags.length - 1) { + tags.push(article.tags[i].name + ', '); + } else { + tags.push(article.tags[i].name); + } + } $articles.push( {article.title} - {article.id} + {tags} {new Date(article.createdAt).toLocaleDateString()} + {new Date(article.updatedAt).toLocaleDateString()} - Edit + Edit ); @@ -53,6 +62,7 @@ export default function ArticleTable() { Title Tags Creation Date + Last Update Actions diff --git a/src/client/Button.tsx b/src/client/Button.tsx index 55c7366..9d3034c 100644 --- a/src/client/Button.tsx +++ b/src/client/Button.tsx @@ -2,6 +2,7 @@ import React from 'react'; import axios from 'axios'; interface ButtonProps { + classes: string; to: string; method: 'GET' | 'POST' | 'PUT' | 'DELETE'; text: string; @@ -11,7 +12,7 @@ interface ButtonProps { /** * @return {jsx} The root component */ -export default function Button({to, method, text}: ButtonProps) { +export default function Button({classes, to, method, text}: ButtonProps) { async function buttonFetch() { console.log('buttonFetch'); console.log(to); @@ -27,7 +28,8 @@ export default function Button({to, method, text}: ButtonProps) { } return ( - + ); } /* eslint-enable */ diff --git a/src/server/routes/api.ts b/src/server/routes/api.ts index 40b390a..94d4e96 100644 --- a/src/server/routes/api.ts +++ b/src/server/routes/api.ts @@ -42,6 +42,16 @@ router.get('/articletable', authorize, async (_req, res) => { 'id', 'title', 'createdAt', + 'updatedAt', + ], + include: [{ + model: Tag, + attributes: [ + 'name', + ], + }], + order: [ + ['updatedAt', 'DESC'], ], }); res.send(articles);