Skip to content

Commit 0569d17

Browse files
dummy data on prod site
1 parent b263971 commit 0569d17

File tree

7 files changed

+21
-23
lines changed

7 files changed

+21
-23
lines changed

backend/controllers/blogController.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ export const createBlog = async (req: AuthenticatedRequest, res: Response) => {
148148
if (!req.user) return res.status(401).json({ error: 'Not authenticated' });
149149
if (!isAdmin(req.user.role)) return res.status(403).json({ error: 'Admin only' });
150150

151-
const { title, content, author, tags, featuredImageUrl, isPublished, publishedDate } = req.body;
151+
const { title, content, author, tags, tagIds, featuredImageUrl, isPublished, publishedDate } =
152+
req.body;
152153

153154
if (!title || !content || !author) {
154155
return res.status(400).json({ error: 'title, content, and author are required' });
@@ -168,8 +169,8 @@ export const createBlog = async (req: AuthenticatedRequest, res: Response) => {
168169

169170
const slug = await generateSlug(title, tempBlog.id);
170171

171-
const tagIds = tags || [];
172-
const tagConnections = tagIds.map((id: string) => ({ id }));
172+
const tagIdsToUse = tagIds || tags || [];
173+
const tagConnections = tagIdsToUse.map((id: string) => ({ id }));
173174

174175
const blog = await prisma.blog.update({
175176
where: { id: tempBlog.id },
@@ -209,7 +210,7 @@ export const updateBlog = async (req: AuthenticatedRequest, res: Response) => {
209210
});
210211
if (!blogToUpdate) return res.status(404).json({ error: 'Blog not found' });
211212

212-
const { title, content, author, tags, featuredImageUrl } = req.body;
213+
const { title, content, author, tags, tagIds, featuredImageUrl } = req.body;
213214

214215
const updateData: any = {
215216
...(title && { title }),
@@ -218,10 +219,11 @@ export const updateBlog = async (req: AuthenticatedRequest, res: Response) => {
218219
...(featuredImageUrl !== undefined && { featuredImageUrl }),
219220
};
220221

221-
// Handle tags update if provided
222-
if (tags) {
222+
// Handle tags update if provided (accept both 'tags' and 'tagIds')
223+
const tagIdsToUse = tagIds || tags;
224+
if (tagIdsToUse) {
223225
const currentTagIds = blogToUpdate.tags.map(t => t.id);
224-
const newTagIds = tags;
226+
const newTagIds = tagIdsToUse;
225227
const toDisconnect = currentTagIds.filter((id: string) => !newTagIds.includes(id));
226228
const toConnect = newTagIds.filter((id: string) => !currentTagIds.includes(id));
227229

backend/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"start": "cross-env NODE_ENV=production node dist/server.js",
1010
"test": "cross-env NODE_ENV=test jest",
1111
"format": "prettier --write \"**/*.{ts,tsx,js,json,md}\"",
12-
"format:check": "prettier --check \"**/*.{ts,tsx,js,json,md}\""
12+
"format:check": "prettier --check \"**/*.{ts,tsx,js,json,md}\"",
13+
"seed:test-content": "tsx prisma/seeds/testContentSeed.ts"
1314
},
1415
"dependencies": {
1516
"@aws-sdk/client-s3": "^3.922.0",

frontend/src/pages/Admin/AlertsPage/Alerts.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const AdminAlerts = () => {
6161
} | null>(null);
6262

6363
const fetchWithAuth = async (url: string, options: RequestInit = {}) => {
64-
const token = await getToken({ template: 'jwt-template-tcba' });
64+
const token = await getToken();
6565
if (!token) throw new Error('Authentication required');
6666

6767
const response = await fetch(url, {

frontend/src/pages/Admin/AnnouncementsPage/Announcements.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,15 @@ const AdminAnnouncements = () => {
7373
};
7474

7575
const fetchWithAuth = async (url: string, options: RequestInit = {}) => {
76-
let token = await getToken({
77-
skipCache: true,
78-
template: 'jwt-template-tcba',
79-
});
76+
let token = await getToken();
8077

8178
if (!token) {
8279
throw new Error('No authentication token available');
8380
}
8481

8582
if (isTokenExpiringSoon(token)) {
8683
console.log('Token expiring soon, proactively refreshing...');
87-
token = await getToken({ skipCache: true, template: 'jwt-template-tcba' });
84+
token = await getToken({ skipCache: true });
8885

8986
if (!token) {
9087
throw new Error('No authentication token available');
@@ -102,7 +99,7 @@ const AdminAnnouncements = () => {
10299
if (response.status === 401) {
103100
console.log('Token expired, refreshing and retrying...');
104101

105-
token = await getToken({ skipCache: true, template: 'jwt-template-tcba' });
102+
token = await getToken({ skipCache: true });
106103

107104
if (!token) {
108105
throw new Error('No authentication token available');

frontend/src/pages/Admin/BlogsPage/Blogs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const AdminBlogs = () => {
6767
} | null>(null);
6868

6969
const fetchWithAuth = async (url: string, options: RequestInit = {}) => {
70-
const token = await getToken({ template: 'jwt-template-tcba' });
70+
const token = await getToken();
7171
if (!token) throw new Error('Authentication required');
7272

7373
const response = await fetch(url, {

frontend/src/pages/Admin/OrganizationManagementPage/OrganizationManagement.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,7 @@ const OrganizationManagement = () => {
101101
};
102102

103103
const fetchWithAuth = async (url: string, options: RequestInit = {}) => {
104-
let token = await getToken({
105-
skipCache: true,
106-
template: 'jwt-template-tcba',
107-
});
104+
let token = await getToken();
108105

109106
if (!token) {
110107
throw new Error('No authentication token available');

frontend/src/pages/BlogPage/Blog.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ const Blog = () => {
9494
</>
9595
)}
9696
</div>
97-
<p className='font-[Open_Sans] text-[18px] font-normal leading-[150%] text-[#3C3C3C] py-8'>
98-
{blog.content}
99-
</p>
97+
<div
98+
className='font-[Open_Sans] text-[18px] font-normal leading-[150%] text-[#3C3C3C] py-8 prose prose-lg max-w-none'
99+
dangerouslySetInnerHTML={{ __html: blog.content }}
100+
/>
100101
</div>
101102
</div>
102103
);

0 commit comments

Comments
 (0)