Redux State Shape
Mitul Mistry edited this page Nov 4, 2021
·
2 revisions
This is a sample state for what the Redux store should like (on the React front end):
{
entities: {
artworks: {
27992: {
id: 27992,
title: "A Sunday on La Grande Jatte — 1884",
artistTitle: "Georges Seurat",
altText: "Large painting of people… brushstrokes are dots.",
imageUrl: "https://www.artic.edu/iiif/2/1adf2696-8489-499b-cad2-821d7fde4b33/full/843,/0/default.jpg",
},
72180: {
id: 72180,
title: "Still Life with Flowers",
artistTitle: "Henri Fantin-Latour",
altText: "A work made of oil on canvas.",
imageUrl: "https://www.artic.edu/iiif/2/94245750-c169-eb03-673e-cd03f718f885/full/843,/0/default.jpg",
}
},
collections: {
5: {
id: 5,
username: "aic_user1",
description: "A collection of art",
likes: 3,
artworks: {
27992: {
id: 27992,
altText: "Large painting of people… brushstrokes are dots.",
imageUrl: "https://www.artic.edu/iiif/2/1adf2696-8489-499b-cad2-821d7fde4b33/full/843,/0/default.jpg",
},
72180: {
id: 72180,
altText: "A work made of oil on canvas.",
imageUrl: "https://www.artic.edu/iiif/2/94245750-c169-eb03-673e-cd03f718f885/full/843,/0/default.jpg",
}
}
},
7: {
id: 7,
username: "aic_user2",
description: "Another collection of art",
likes: 5,
artworks: {
27992: {
id: 27992,
altText: "Large painting of people… brushstrokes are dots.",
imageUrl: "https://www.artic.edu/iiif/2/1adf2696-8489-499b-cad2-821d7fde4b33/full/843,/0/default.jpg",
},
72180: {
id: 72180,
altText: "A work made of oil on canvas.",
imageUrl: "https://www.artic.edu/iiif/2/94245750-c169-eb03-673e-cd03f718f885/full/843,/0/default.jpg",
}
}
}
},
users: {
10: {
id: 10,
username: "aic_user10",
avatarUrl: "https://via.placeholder.com/150",
},
23: {
id: 23,
username: "aic_user23",
avatarUrl: "https://via.placeholder.com/150",
}
},
likes: {
1: {
id: 1,
userId: 2,
collectionId: 1,
}
},
comments: {
1: {
id: 5,
userId: 4,
collectionId: 7,
body: "This is a great collection!",
}
}
},
ui: {
loading: true/false,
modal: true/false,
darkMode: true/false
},
errors: {
login: ["Incorrect username/password combination"],
profileForm: ["Bio cannot be longer than 1000 characters."],
collectionForm: ["Collection description cannot be longer than 1000 characters."],
commentForm: ["Comment cannot be blank."],
},
session: { currentUserId: 25 }
}