-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/ue design #23
base: dev
Are you sure you want to change the base?
Fix/ue design #23
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,11 @@ import { editCommentReply } from '@/api/commentReply/editCommentReply'; | |
import { useAPI } from '@/api/api'; | ||
import { sendCommentReply } from '@/api/commentReply/sendCommentReply'; | ||
import { usePageSettings } from '@/module/pageSettings'; | ||
import Enter from '@/icons/Enter'; | ||
import User from '@/icons/User'; | ||
import Comment from '@/icons/Comment'; | ||
import Clock from '@/icons/Clock'; | ||
import Link from '@/components/UI/Link'; | ||
|
||
function CommentEditorFooter(originalComment: string, onUpdate: (text: string) => void, t: TFunction) { | ||
return function CommentEditorFooter({ text, disable }: { text: string; disable: () => void }) { | ||
|
@@ -46,55 +51,72 @@ export default function CommentDetailsPage() { | |
return ( | ||
<div className={styles.page}> | ||
<h1> | ||
{comment.isAnonymous | ||
? t('ues:detailed.comments.resume.anonymous', { | ||
ue: ue.code, | ||
semester: comment.semester.code, | ||
date: comment.createdAt.toLocaleDateString(), | ||
}) | ||
: t('ues:detailed.comments.resume', { | ||
authorFirstName: comment.author.firstName, | ||
authorLastName: comment.author.lastName, | ||
ue: ue.code, | ||
semester: comment.semester.code, | ||
date: comment.createdAt.toLocaleDateString(), | ||
})} | ||
{t('ues:detailed.comments.resume', { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. summary ça serait mieux je pense plutôt que resume, ça peut faire penser que c'est "reprendre" ou "CV", et en plus en anglais ya des accents sur les "e", donc encore moins intuitif ^^ |
||
ue: ue.code, | ||
})} | ||
</h1> | ||
{comment.updatedAt && ( | ||
<p className={styles.updateDate}> | ||
{t('ues:detailed.comments.updatedAt', { date: comment.updatedAt.toLocaleDateString() })} | ||
</p> | ||
)} | ||
<div className={styles.meta}> | ||
{!comment.isAnonymous && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
<div> | ||
<User /> | ||
<Link href={`/users/${comment.author.id}`} noStyle> | ||
{comment.author.firstName} {comment.author.lastName} | ||
</Link> | ||
</div> | ||
)} | ||
<div> | ||
<Comment /> | ||
{t('ues:detailed.comments.semester', { semester: comment.semester.code })} | ||
</div> | ||
<div> | ||
<Clock /> | ||
<div> | ||
<div>{t('ues:detailed.comments.writtenDate', { date: comment.createdAt.toLocaleDateString() })}</div> | ||
{comment.updatedAt && ( | ||
<div>{t('ues:detailed.comments.updatedAt', { date: comment.updatedAt.toLocaleDateString() })}</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. une icone clock pour chacune des 2 ça serait mieux je pense, ça fait bizarre de pas avoir d'icone à côté de updatedAt |
||
)} | ||
</div> | ||
</div> | ||
</div> | ||
<p className={styles.body}>{comment.body}</p> | ||
<div className={styles.comments}> | ||
{comment.answers.map((answer, i) => ( | ||
<div key={answer.id} className={styles.comment}> | ||
<p className={styles.author}> | ||
{answer.author | ||
? `${answer.author.firstName} ${answer.author.lastName}` | ||
: t('ues:detailed.comments.author.deleted')} | ||
</p> | ||
<p className={styles.date}> | ||
{t('ues:detailed.comments.writtenDate', { date: answer.createdAt.toLocaleDateString() })} | ||
</p> | ||
<EditableText | ||
className={styles.body} | ||
text={answer.body} | ||
EditingFooter={CommentEditorFooter( | ||
answer.body, | ||
async (body) => { | ||
const newAnswer = await editCommentReply(api, answer.id, body).toPromise(); | ||
if (!newAnswer) return false; | ||
setComment({ | ||
...comment, | ||
answers: [...comment.answers.slice(0, i), newAnswer, ...comment.answers.slice(i + 1)], | ||
}); | ||
return true; | ||
}, | ||
t, | ||
)} | ||
enabled={answer.author.id === user.id} | ||
/> | ||
<div className={styles.sideIcon}> | ||
<Enter className={styles.answerIcon} /> | ||
</div> | ||
<div> | ||
<p className={styles.author}> | ||
{answer.author ? ( | ||
<Link href={`/users/${answer.author.id}`} noStyle> | ||
{answer.author.firstName} {answer.author.lastName} | ||
</Link> | ||
) : ( | ||
t('ues:detailed.comments.author.deleted') | ||
)} | ||
</p> | ||
<p className={styles.date}> | ||
{t('ues:detailed.comments.writtenDate', { date: answer.createdAt.toLocaleDateString() })} | ||
</p> | ||
<EditableText | ||
className={styles.body} | ||
text={answer.body} | ||
EditingFooter={CommentEditorFooter( | ||
answer.body, | ||
async (body) => { | ||
const newAnswer = await editCommentReply(api, answer.id, body).toPromise(); | ||
if (!newAnswer) return false; | ||
setComment({ | ||
...comment, | ||
answers: [...comment.answers.slice(0, i), newAnswer, ...comment.answers.slice(i + 1)], | ||
}); | ||
return true; | ||
}, | ||
t, | ||
)} | ||
enabled={answer.author.id === user.id} | ||
/> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tu veux pas garder les ' ?