-
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.
Merge remote-tracking branch 'origin/staging' into #386-Add-tags-comp…
…onent
- Loading branch information
Showing
12 changed files
with
199 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react'; | ||
import BlogListView from '../../../components/module-components/create-blogs/BlogListView'; | ||
|
||
const page = () => { | ||
return <BlogListView />; | ||
}; | ||
|
||
export default page; |
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 |
---|---|---|
@@ -1,48 +1,7 @@ | ||
'use client'; | ||
import React from 'react'; | ||
|
||
import { useState } from 'react'; | ||
import Button from '../../components/reusable-components/button/Button'; | ||
|
||
const ContentPanel = () => { | ||
const [activeTab, setActiveTab] = useState('blogs'); | ||
|
||
const handleTabClick = (tab: string) => { | ||
setActiveTab(tab); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<h1>Content Panel</h1> | ||
<div> | ||
<Button | ||
href="" | ||
type="button" | ||
buttonClass={['primaryButton']} | ||
buttonText="Blogs" | ||
onClick={() => handleTabClick('blogs')} | ||
/> | ||
<Button | ||
href="" | ||
type="button" | ||
buttonClass={['primaryButton']} | ||
buttonText="Tags" | ||
onClick={() => handleTabClick('tags')} | ||
/> | ||
</div> | ||
<div> | ||
{activeTab === 'blogs' && ( | ||
<div> | ||
<h2>Blogs Section</h2> | ||
</div> | ||
)} | ||
{activeTab === 'tags' && ( | ||
<div> | ||
<h2>Tags Section</h2> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
const page = () => { | ||
return <div />; | ||
}; | ||
|
||
export default ContentPanel; | ||
export default page; |
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
115 changes: 115 additions & 0 deletions
115
components/module-components/create-blogs/BlogListView.tsx
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,115 @@ | ||
'use client'; | ||
|
||
import React, { useEffect, useState } from 'react'; | ||
import Button from '../../reusable-components/button/Button'; | ||
import ReusableTable from '../../reusable-components/reusable-table/ReusableTable'; | ||
import Filter from '../SearchAndFilter/Filter'; | ||
import Search from '../SearchAndFilter/Search'; | ||
import ActionDropdown from '../../reusable-components/reusable-table/ActionDropdown'; | ||
import style from './createBlogs.module.scss'; | ||
|
||
interface Author { | ||
first_name: string; | ||
last_name: string; | ||
} | ||
|
||
interface Tag { | ||
name: string; | ||
} | ||
|
||
interface BlogPostAPI { | ||
id: string; | ||
title: string; | ||
tags: Tag[]; | ||
author: Author; | ||
} | ||
|
||
interface BlogPost { | ||
id: string; | ||
title: string; | ||
tags: Tag[]; | ||
author: string; | ||
} | ||
|
||
const BlogListView = () => { | ||
const [data, setData] = useState<BlogPost[]>([]); | ||
const url = `${process.env.NEXT_PUBLIC_API_BASE_URL}/blog-posts`; | ||
|
||
useEffect(() => { | ||
const fetchData = async () => { | ||
try { | ||
const response = await fetch(url); | ||
if (!response.ok) { | ||
throw new Error(`${response.status} ${response.statusText}`); | ||
} | ||
const result = await response.json(); | ||
const transformedData: BlogPost[] = result.data.map((item: BlogPostAPI) => ({ | ||
id: item.id, | ||
title: item.title, | ||
tags: item.tags, | ||
author: `${item.author.first_name} ${item.author.last_name}`, | ||
})); | ||
setData(transformedData); | ||
} catch (error) { | ||
console.error('Error fetching data:', error); | ||
} | ||
}; | ||
|
||
fetchData(); | ||
}, [url]); | ||
|
||
const headers: (keyof BlogPost)[] = ['title', 'author', 'tags']; | ||
const displayNames = { | ||
title: 'Title', | ||
author: 'Author', | ||
tags: 'Tags', | ||
}; | ||
|
||
const handleView = (id: string) => { | ||
console.log('View blog', id); | ||
}; | ||
|
||
const handleEdit = (id: string) => { | ||
console.log('Edit blog', id); | ||
}; | ||
|
||
const handleDelete = (id: string) => { | ||
console.log('Delete blog', id); | ||
}; | ||
|
||
const renderActionsDropdown = (item: BlogPost) => ( | ||
<ActionDropdown | ||
dropdownItems={[ | ||
{ id: 'view', label: 'View', onClick: () => handleView(item.id) }, | ||
{ id: 'edit', label: 'Edit', onClick: () => handleEdit(item.id) }, | ||
{ id: 'delete', label: 'Delete', onClick: () => handleDelete(item.id) }, | ||
]} | ||
/> | ||
); | ||
|
||
return ( | ||
<div className={style.mainContainer}> | ||
<div className={style.inputWrapper}> | ||
<Search handleInputChange={() => {}} searchValue="Search" /> | ||
<div className={style.rightContainer}> | ||
<Filter handleRoleChange={() => {}} /> | ||
<Button | ||
href="" | ||
type="button" | ||
buttonText="Add Blog" | ||
buttonClass={['primaryButton']} | ||
moveIcon | ||
/> | ||
</div> | ||
</div> | ||
<ReusableTable | ||
headers={headers} | ||
displayNames={displayNames} | ||
data={data} | ||
renderActionsDropdown={renderActionsDropdown} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default BlogListView; |
14 changes: 14 additions & 0 deletions
14
components/module-components/create-blogs/createBlogs.module.scss
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,14 @@ | ||
.mainContainer { | ||
margin: 50px 0; | ||
|
||
.inputWrapper { | ||
margin: 50px 0; | ||
display: flex; | ||
width: 100%; | ||
|
||
.rightContainer { | ||
display: flex; | ||
gap: 20px; | ||
} | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
app/content-panel/tags/AddTags.tsx → ...onents/module-components/tags/AddTags.tsx
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
4 changes: 2 additions & 2 deletions
4
app/content-panel/tags/TagTable.tsx → ...nents/module-components/tags/TagTable.tsx
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
2 changes: 1 addition & 1 deletion
2
app/content-panel/tags/Tags.module.scss → ...s/module-components/tags/Tags.module.scss
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
File renamed without changes.
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
25 changes: 23 additions & 2 deletions
25
components/reusable-components/reusable-table/TableRowComponent.tsx
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