mirror of
https://github.com/usatiuk/y.git
synced 2025-10-28 10:37:47 +01:00
post author link
This commit is contained in:
@@ -23,10 +23,24 @@
|
||||
.info {
|
||||
flex-grow: 1;
|
||||
align-self: start;
|
||||
|
||||
> * {
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
|
||||
> *:first-child {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
.actions {
|
||||
align-self: end;
|
||||
|
||||
button {
|
||||
background: none;
|
||||
border: none;
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import "./Post.scss";
|
||||
import { Form } from "react-router-dom";
|
||||
import { Form, Link } from "react-router-dom";
|
||||
|
||||
export function Post({
|
||||
text,
|
||||
createdDate,
|
||||
actions,
|
||||
authorUsername,
|
||||
id,
|
||||
}: {
|
||||
text: string;
|
||||
createdDate: string;
|
||||
authorUsername: string;
|
||||
actions: boolean;
|
||||
id: number;
|
||||
}) {
|
||||
@@ -18,6 +20,12 @@ export function Post({
|
||||
<div className={"footer"}>
|
||||
<div className={"info"}>
|
||||
<span className={"createdDate"}>{createdDate}</span>
|
||||
<Link
|
||||
className={"authorLink"}
|
||||
to={"/home/profile/" + authorUsername}
|
||||
>
|
||||
by {authorUsername}
|
||||
</Link>
|
||||
</div>
|
||||
{actions && (
|
||||
<div className={"actions"}>
|
||||
|
||||
@@ -20,6 +20,7 @@ export function PostList({
|
||||
createdDate={`${date.toUTCString()}`}
|
||||
key={p.id}
|
||||
id={p.id}
|
||||
authorUsername={p.authorUsername}
|
||||
actions={selfUuid == p.authorUuid}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -58,6 +58,7 @@ export const PostTo = z.object({
|
||||
authorUuid: z.string(),
|
||||
text: z.string(),
|
||||
createdAt: z.number(),
|
||||
authorUsername: z.string(),
|
||||
});
|
||||
export type TPostTo = z.infer<typeof PostTo>;
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
package com.usatiuk.tjv.y.server.dto;
|
||||
|
||||
import com.usatiuk.tjv.y.server.entity.Post;
|
||||
|
||||
public record PostTo(Long id, String authorUuid, String text, Long createdAt) {
|
||||
public record PostTo(Long id, String authorUuid, String authorUsername, String text, Long createdAt) {
|
||||
}
|
||||
|
||||
@@ -5,6 +5,6 @@ import com.usatiuk.tjv.y.server.entity.Post;
|
||||
|
||||
public class PostMapper {
|
||||
public static PostTo makeDto(Post post) {
|
||||
return new PostTo(post.getId(), post.getAuthor().getUuid(), post.getText(), post.getCreatedAt().getEpochSecond());
|
||||
return new PostTo(post.getId(), post.getAuthor().getUuid(), post.getAuthor().getUsername(), post.getText(), post.getCreatedAt().getEpochSecond());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user