display genres on edit story page
This commit is contained in:
		
							parent
							
								
									ec3ece5bde
								
							
						
					
					
						commit
						58a36194c6
					
				|  | @ -109,10 +109,8 @@ export default function Table(props) { | ||||||
| 
 | 
 | ||||||
|     if (Array.isArray(contents)) { |     if (Array.isArray(contents)) { | ||||||
|       const badgeIndex = props?.badges?.findIndex(e=>{return e[0]==key}) |       const badgeIndex = props?.badges?.findIndex(e=>{return e[0]==key}) | ||||||
|       console.log("badgeIndex for key "+key+": "+badgeIndex) |  | ||||||
|       if(badgeIndex>=0){ |       if(badgeIndex>=0){ | ||||||
|         const array = contents.map(e=>{return e[props.badges[badgeIndex][1]]}) |         const array = contents.map(e=>{return e[props.badges[badgeIndex][1]]}) | ||||||
|         console.dir(array) |  | ||||||
|         return <Cell><Badges data={array} setFocus={props.setFocus} /></Cell> |         return <Cell><Badges data={array} setFocus={props.setFocus} /></Cell> | ||||||
|       } |       } | ||||||
|       if (typeof contents[0] === 'object') { |       if (typeof contents[0] === 'object') { | ||||||
|  |  | ||||||
|  | @ -13,7 +13,18 @@ export async function action({request,params}){ | ||||||
|     return redirect(`/story/${params.storyId}`) |     return redirect(`/story/${params.storyId}`) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | const makeGenreObject = (genres,titleGenres) =>{ | ||||||
|  |     const obj = {} | ||||||
|  |     for (const genre of genres) { | ||||||
|  |         if(genre){ | ||||||
|  |             obj[genre] = titleGenres.some(e=>{ | ||||||
|  |                 return e.name===genre | ||||||
|  |             }) | ||||||
|  |         } | ||||||
|          |          | ||||||
|  |     } | ||||||
|  |     return obj | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -60,7 +71,7 @@ export default function EditStory(){ | ||||||
|         setData(prev=>{ |         setData(prev=>{ | ||||||
|            return { |            return { | ||||||
|                 ...prev, |                 ...prev, | ||||||
|                 genres:storyData.genres |                 genres:makeGenreObject(genres,storyData.genres) | ||||||
|             } |             } | ||||||
|         }) |         }) | ||||||
|     },[storyData]) |     },[storyData]) | ||||||
|  |  | ||||||
|  | @ -7,6 +7,7 @@ import PageHeader from "../Components/PageHeader.jsx"; | ||||||
| 
 | 
 | ||||||
| export default function Stories(){ | export default function Stories(){ | ||||||
|     const { stories } = useLoaderData(); |     const { stories } = useLoaderData(); | ||||||
|  |     console.dir(stories) | ||||||
|     const filterColumns = [ |     const filterColumns = [ | ||||||
|         'submissions', |         'submissions', | ||||||
|         'deleted' |         'deleted' | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue