Skip to content

Commit

Permalink
Removed deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
macterra committed Oct 15, 2023
1 parent c8fcb44 commit 0fd35be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 27 deletions.
25 changes: 1 addition & 24 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,39 +78,16 @@ function ViewProfile() {
}

function ViewCollection() {
const { xid } = useParams();
const [refreshProfile, setRefreshProfile] = useState(null);
const [userId, setUserId] = useState(null);
const navigate = useNavigate();

useEffect(() => {
const fetchProfile = async () => {
try {
const response = await fetch(`/api/v1/collections/${xid}`);
const collectionData = await response.json();

if (collectionData.error) {
navigate('/');
}
else {
setUserId(collectionData.asset.owner);
}
} catch (error) {
console.error('Error fetching profile data:', error);
}
};

fetchProfile();
});

return (
<ThemeProvider theme={darkTheme}>
<CssBaseline />
<div className="App">
<AppHeader navigate={navigate} />
<header className="App-header">
<Box display="flex" flexDirection="column" flexGrow={1}>
<CollectionView navigate={navigate} setRefreshProfile={setRefreshProfile} />
<CollectionView navigate={navigate} />
</Box>
</header>
</div>
Expand Down
12 changes: 9 additions & 3 deletions frontend/src/CollectionView.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Box, Button, Grid } from '@mui/material';
import ImageGrid from './ImageGrid';
import AgentBadge from './AgentBadge';

const CollectionView = ({ navigate, setRefreshProfile }) => {
const CollectionView = ({ navigate }) => {
const { xid } = useParams();
const [collection, setCollection] = useState(null);
const [refreshKey, setRefreshKey] = useState(0);
Expand All @@ -25,6 +25,9 @@ const CollectionView = ({ navigate, setRefreshProfile }) => {
if (!collectionData.error) {
setCollection(collectionData);
}
else {
navigate('/');
}

const rates = await axios.get('/api/v1/rates');
const uploadRate = rates.data.uploadRate;
Expand Down Expand Up @@ -73,7 +76,6 @@ const CollectionView = ({ navigate, setRefreshProfile }) => {
const mb = data.bytesUploaded / 1000000;
alert(`You were debited ${data.creditsDebited} credits to upload ${data.filesUploaded} files (${mb.toFixed(2)} MB)`);
setRefreshKey((prevKey) => prevKey + 1);
setRefreshProfile((prevKey) => prevKey + 1);
}
if (data.filesSkipped) {
if (data.filesSkipped === 1) {
Expand Down Expand Up @@ -135,7 +137,11 @@ const CollectionView = ({ navigate, setRefreshProfile }) => {
<div style={{ fontSize: '0.5em' }}>by</div>
<AgentBadge xid={collection.asset.owner} />
</Box>
<span style={{ fontSize: '12px' }}> ({collection.collection.assets.length} items)</span>
{collection.collection.assets.length === 1 ? (
<span style={{ fontSize: '12px' }}> (1 item)</span>
) : (
<span style={{ fontSize: '12px' }}> ({collection.collection.assets.length} items)</span>
)}
{collection.isOwnedByUser &&
<Box style={{ marginLeft: '20px', marginRight: '20px' }}>
<Grid container alignItems="center" justifyContent="space-between">
Expand Down

0 comments on commit 0fd35be

Please sign in to comment.