mirror of https://github.com/usbharu/Hideout.git
feat: Favoriteボタンが機能するように
This commit is contained in:
parent
4474e2beba
commit
c02dee4096
|
@ -4,14 +4,22 @@ import {Avatar} from "../atoms/Avatar";
|
||||||
import {Favorite, MoreVert, Reply, ScreenRotationAlt} from "@suid/icons-material";
|
import {Favorite, MoreVert, Reply, ScreenRotationAlt} from "@suid/icons-material";
|
||||||
import {ShareScopeIndicator} from "../molecules/ShareScopeIndicator";
|
import {ShareScopeIndicator} from "../molecules/ShareScopeIndicator";
|
||||||
import {PostResponse} from "../generated";
|
import {PostResponse} from "../generated";
|
||||||
|
import {useApi} from "../lib/ApiProvider";
|
||||||
|
|
||||||
export const Post: Component<{ post: PostResponse }> = (props) => {
|
export const Post: Component<{ post: PostResponse }> = (props) => {
|
||||||
|
|
||||||
|
const api = useApi()
|
||||||
|
|
||||||
const [anchorEl, setAnchorEl] = createSignal<null | HTMLElement>(null)
|
const [anchorEl, setAnchorEl] = createSignal<null | HTMLElement>(null)
|
||||||
const open = () => Boolean(anchorEl());
|
const open = () => Boolean(anchorEl());
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
setAnchorEl(null);
|
setAnchorEl(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleFavorite = () => {
|
||||||
|
api().postsPostIdReactionsPost({reaction: "❤"}, props.post.id)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
<CardHeader avatar={<Avatar src={props.post.user.url + "/icon.jpg"}/>} title={props.post.user.screenName}
|
<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>
|
<IconButton>
|
||||||
<ScreenRotationAlt/>
|
<ScreenRotationAlt/>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<IconButton>
|
<IconButton onclick={handleFavorite}>
|
||||||
<Favorite/>
|
<Favorite/>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<Box sx={{marginLeft: "auto"}}>
|
<Box sx={{marginLeft: "auto"}}>
|
||||||
|
|
Loading…
Reference in New Issue