Spaces:
Sleeping
Sleeping
File size: 1,512 Bytes
6f7ef5c aa120c6 6f7ef5c aa120c6 6f7ef5c aa120c6 6f7ef5c aa120c6 6f7ef5c aa120c6 6f7ef5c aa120c6 6f7ef5c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | import { useState } from 'react';
import { useParams } from 'react-router-dom';
import RankItems from './RankItems';
import ItemUpload from './ItemUpload';
const RankItemsContainer = ({ dataType, imgArr }) => {
const { tierListId } = useParams();
const albumLocalStorageKey = "albums";
const movieLocalStorageKey = "movies";
var localStorageKey = "";
const [albumItems, setAlbumItems] = useState(null);
const [movieItems, setMovieItems] = useState(null);
var data = [];
var setFunc = null;
if (dataType === 1) {
data = movieItems;
setFunc = setMovieItems;
localStorageKey = movieLocalStorageKey;
}
else if (dataType === 2) {
data = albumItems;
setFunc = setAlbumItems;
localStorageKey = albumLocalStorageKey;
}
const handleUploadComplete = () => {
// Refresh the items list after a new upload
setFunc(null); // This will trigger a reload in RankItems
};
return (
<div>
<ItemUpload
tierListId={tierListId}
itemType={dataType}
onUploadComplete={handleUploadComplete}
/>
<RankItems
items={data}
setItems={setFunc}
dataType={dataType}
imgArr={imgArr}
localStorageKey={localStorageKey}
tierListId={tierListId}
/>
</div>
);
};
export default RankItemsContainer; |