Add button to go to squeaks from profile page (#388)

This commit is contained in:
Jonathan Zernik 2020-11-05 16:34:13 -05:00 committed by GitHub
parent f0290e0677
commit feb6a83bce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 6 deletions

View file

@ -1,4 +1,5 @@
import React, { useState, useEffect } from 'react';
import {useHistory} from "react-router-dom";
import { useParams } from 'react-router-dom';
import {
Grid,
@ -31,7 +32,7 @@ export default function ProfilePage() {
const { id } = useParams();
const [squeakProfile, setSqueakProfile] = useState(null);
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
const history = useHistory();
const getSqueakProfile = (id) => {
getSqueakProfileRequest(id, setSqueakProfile);
@ -47,6 +48,10 @@ export default function ProfilePage() {
})
};
const goToSqueakAddressPage = (squeakAddress) => {
history.push("/app/squeakaddress/" + squeakAddress);
};
useEffect(()=>{
getSqueakProfile(id)
@ -87,6 +92,7 @@ export default function ProfilePage() {
Profile name: {squeakProfile.getProfileName()}
</p>
{ProfileSettingsForm()}
{ViewSqueaksButton()}
{DeleteProfileButton()}
</>
)
@ -127,6 +133,23 @@ export default function ProfilePage() {
)
}
function ViewSqueaksButton() {
return (
<>
<Grid item xs={12}>
<div className={classes.root}>
<Button
variant="contained"
onClick={() => {
goToSqueakAddressPage(squeakProfile.getAddress());
}}>View Squeaks
</Button>
</div>
</Grid>
</>
)
}
function DeleteProfileDialogContent() {
return (
<>

View file

@ -70,6 +70,10 @@ export default function Profiles() {
history.push("/app/squeakaddress/" + squeakAddress);
};
const goToProfilePage = (profileId) => {
history.push("/app/profile/" + profileId);
};
const handleClickOpenCreateSigningProfileDialog = () => {
setCreateSigningProfileDialogOpen(true);
};
@ -174,21 +178,32 @@ export default function Profiles() {
title="Signing Profiles"
data={signingProfiles.map(p =>
[
p.getProfileId(),
p.getProfileName(),
p.getAddress(),
p.getFollowing().toString(),
p.getSharing().toString(),
]
)}
columns={["Name", "Address", "Following", "Sharing"]}
columns={[
{
name: "Id",
options: {
display: false,
}
},
"Name", "Address", "Following", "Sharing"
]}
options={{
filter: false,
print: false,
viewColumns: false,
selectableRows: "none",
onRowClick: rowData => {
var address = rowData[1];
goToSqueakAddressPage(address);
var id = rowData[0];
var address = rowData[2];
//goToSqueakAddressPage(address);
goToProfilePage(id);
}
}}/>
</Grid>

View file

@ -37,7 +37,7 @@ export default function SqueakAddressPage() {
getAddressSqueakDisplaysRequest(address, setSqueaks);
};
const goToCreateProfilePage = (profileId) => {
const goToProfilePage = (profileId) => {
history.push("/app/profile/" + profileId);
};
@ -72,7 +72,7 @@ export default function SqueakAddressPage() {
<div className={classes.root}>
Profile:
<Button variant="contained" onClick={() => {
goToCreateProfilePage(squeakProfile.getProfileId());
goToProfilePage(squeakProfile.getProfileId());
}}>{squeakProfile.getProfileName()}</Button>
</div>
)