feat: split out dividers; proper block sorting

This commit is contained in:
Cory Dransfeldt 2024-07-14 21:17:17 -07:00
parent 4b908fc3df
commit 1a6e250875
No known key found for this signature in database
5 changed files with 13 additions and 8 deletions

View file

@ -24,7 +24,7 @@ const fetchBlockData = async (collection, itemId) => {
const fetchBlocksForPage = async (pageId) => {
const { data, error } = await supabase
.from('pages_blocks')
.select('collection, item')
.select('collection, item, sort')
.eq('pages_id', pageId)
if (error) {
@ -37,11 +37,12 @@ const fetchBlocksForPage = async (pageId) => {
return {
type: block['collection'],
sort: block['sort'],
...blockData
}
}))
return blocks
return blocks.sort((a, b) => a.sort - b.sort)
}
const fetchAllPages = async () => {