Feat: started working on tier level edit

This commit is contained in:
2025-01-10 15:18:59 +03:00
parent 1cfdb5ee08
commit c30855beda
8 changed files with 21 additions and 19 deletions

View File

@@ -5,14 +5,9 @@ import './App.scss';
import { TierImage } from './components/Image';
import { Tier } from './components/Tier';
import { TierModal } from './components/TierModal';
import { tierImage } from './dto/tier';
import useStore from './store';
interface tierImage {
name: string;
url: string;
category: string;
}
const App = () => {
const [images, addTierImage, tierLevels, editTierImage] = useStore(
useShallow(state => [state.images, state.addTierImage, state.tierLevels, state.editTierImage]),
@@ -24,11 +19,6 @@ const App = () => {
if (uploadBtn.current) uploadBtn.current.click();
};
const getRandomCategoryName = () => {
const categoryNames = tierLevels.flatMap(category => category.name);
return categoryNames[Math.floor(Math.random() * categoryNames.length)];
};
const handleAdd = (images: tierImage[]) => {
images.forEach(image => {
addTierImage(image);
@@ -55,7 +45,7 @@ const App = () => {
/>
))}
</div>
<div className='flex flex-row w-full'>
<div className='flex flex-row w-full '>
{images
.filter(image => image.category === '')
.map((image, index) => (
@@ -80,7 +70,7 @@ const App = () => {
upload_images.push({
url: url,
name: event.target.files[i].name.replace('.jpeg', ''),
category: getRandomCategoryName(),
category: '',
});
}
handleAdd(upload_images);