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