Skip to content

Redux State Shape

Crystal Chavez edited this page Apr 29, 2022 · 5 revisions
state = {

     session: { user: {} },
     photos: {},
     albums: {},
     tags: {},
     follows: [],
     followers: [],
     favorites: [],

}

state.session.user = { 

    id,
    user_name,
    email,

}

state.photos = {

    id: {

        id,
        userId,
        title,
        photo_url,
        description,
        tags: [],
        comments: {}

        },
    id2: {

        id2,
        userId,
        title,
        photo_url,
        description,
        tags: [],
        comments: {}

        },
    id3: {

        id3,
        userId,
        title,
        photo_url,
        description,
        tags: [],
        comments: {}

        },
 }

state.photos[id] = {

       id,
       userId,
       title,
       photo_url,
       description,
       tags: [],
       comments: {}

 }

state.photos[id].tags = [id, id2, id3]

state.photos[id].comments = {

    id: {

        id,
        userId,
        photoId,
        comment,

     },

   id2: {

       id2,
       userId,
       photoId,
       comment,

   },

   id3: {

       id3,
       userId,
       photoId,
       comment,

   }
}

state.photos[id].comments[id] = {

      id,
      userId,
      photoId,
      comment,

}
state.albums = {

     id: {
         id,
         userId,
         title

       },

     id2: {

         id2,
         userId,
         title

       },
}

state.albums[id] = {

        id,
        userId,
        title,
        photos: []

}

state.albums[id].photos = [id1, id2, id3]

state.tags = {
      id: {

       id,
       tag_name,
       photos: []

         }

      id2:{
           ...
          }
       
  

}

state.tags.photos = [photo_id1, photo_id2, photo_id3]

state.favorites = [photo_id1, photo_id2, photo_id3]

state.followers = [user_id1, user_id2, user_id3]

state.follow= [user_id1, user_id2, user_id3]
Clone this wiki locally