Skip to content

Commit 6437e5b

Browse files
authored
Merge pull request #187 from ctfguide-tech/dev
feat: fix issues with writeups
2 parents 2d53a2c + 7893fef commit 6437e5b

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/components/profile/v2/Writeups.jsx

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useEffect, useState } from 'react';
22
import request from '@/utils/request';
33
import { Dialog } from '@headlessui/react';
4+
import { MarkdownViewer } from '@/components/MarkdownViewer';
45

56
const Writeups = ({ user }) => {
67
const [writeups, setWriteups] = useState([]);
@@ -47,14 +48,14 @@ const Writeups = ({ user }) => {
4748
{writeups.length > 0 ? (
4849
<div className="overflow-auto">
4950
{writeups.map((writeup, index) => (
50-
<div key={index} onClick={() => openModal(writeup)} className='mb-1 bg-neutral-700 hover:bg-neutral-600 hover:cursor-pointer px-5 py-3 w-full text-white flex mx-auto border border-neutral-600'>
51+
<div key={index} onClick={() => openModal(writeup)} className='mb-2 bg-neutral-700/50 hover:bg-neutral-700/90 duration-100 hover:cursor-pointer px-5 py-2 w-full text-white flex mx-auto'>
5152
<div className='w-full flex'>
52-
<div className="">
53-
<h3 className="text-2xl">{writeup.title}</h3>
54-
<p className="text-sm">Authored by <span onClick={() => window.location.href = `../../users/${user.username}`} className='text-blue-500 cursor-pointer'>{user.username}</span></p>
53+
<div>
54+
<h3 className="text-xl">{writeup.title}</h3>
55+
<p className="text-sm text-blue-500 font-semibold" onClick={() => window.location.href = `../../users/${user.username}`}>@{user.username}</p>
5556
</div>
5657
<div className="ml-auto mt-2">
57-
<p className="text-sm text-right">{writeup.views} views</p>
58+
<p className="text-sm text-right hidden">{writeup.views} views</p>
5859
<div className="space-x-2 text-right text-lg">
5960
<i className="fas fa-arrow-up text-green-500 cursor-pointer"></i> {writeup.upvotes}
6061
<i className="fas fa-arrow-down text-red-500 cursor-pointer"></i> {writeup.downvotes}
@@ -86,10 +87,10 @@ const Writeups = ({ user }) => {
8687

8788
<h1 className='text-2xl'>{selectedWriteup.title}</h1>
8889
<p>
89-
Authored by <span onClick={() => window.location.href = `../../users/${user.username}`} className='text-blue-500 cursor-pointer'>{user.username}</span> for challenge <span onClick={() => window.location.href = `../../challenges/${selectedWriteup.challengeId}`} className='text-yellow-500 cursor-pointer'>{selectedWriteup.title}</span>.
90+
Authored by <span onClick={() => window.location.href = `../../users/${user.username}`} className='text-blue-500 cursor-pointer'>{user.username}</span> for challenge <span onClick={() => window.location.href = `../../challenges/${selectedWriteup.challengeId}`} className='text-yellow-500 cursor-pointer'>{selectedWriteup.challenge.title}</span>.
9091
</p>
9192
<div className="mt-2">
92-
<p>{selectedWriteup.content}</p>
93+
<MarkdownViewer content={selectedWriteup.content} />
9394
</div>
9495

9596

src/pages/challenges/[...id].jsx

+2
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,8 @@ function WriteUpPage({ cache, setCache, onWriteupSelect }) {
882882

883883
const openModal = (writeup) => {
884884
setSelectedWriteup(writeup);
885+
setUpvotes(writeup.upvotes); // Set initial upvotes
886+
setDownvotes(writeup.downvotes); // Set initial downvotes
885887
setIsModalOpen(true);
886888
};
887889

0 commit comments

Comments
 (0)