feat: Favoriteボタンが機能するように

This commit is contained in:
usbharu 2023-08-08 17:36:25 +09:00
parent fa6896a124
commit 0b57b438f9
1 changed files with 9 additions and 1 deletions

View File

@ -4,14 +4,22 @@ import {Avatar} from "../atoms/Avatar";
import {Favorite, MoreVert, Reply, ScreenRotationAlt} from "@suid/icons-material";
import {ShareScopeIndicator} from "../molecules/ShareScopeIndicator";
import {PostResponse} from "../generated";
import {useApi} from "../lib/ApiProvider";
export const Post: Component<{ post: PostResponse }> = (props) => {
const api = useApi()
const [anchorEl, setAnchorEl] = createSignal<null | HTMLElement>(null)
const open = () => Boolean(anchorEl());
const handleClose = () => {
setAnchorEl(null);
}
const handleFavorite = () => {
api().postsPostIdReactionsPost({reaction: "❤"}, props.post.id)
}
return (
<Card>
<CardHeader avatar={<Avatar src={props.post.user.url + "/icon.jpg"}/>} title={props.post.user.screenName}
@ -32,7 +40,7 @@ export const Post: Component<{ post: PostResponse }> = (props) => {
<IconButton>
<ScreenRotationAlt/>
</IconButton>
<IconButton>
<IconButton onclick={handleFavorite}>
<Favorite/>
</IconButton>
<Box sx={{marginLeft: "auto"}}>