Update unpublished logic so unpublished items can have inventory added, and can't be found via category or direct link

main
Ashelyn Dawn 3 years ago
parent eb4a2ed3f8
commit e275d1c34a

@ -50,6 +50,10 @@ router.post('/', ensureAdmin, parseJSON, itemValidators, async (req, res) => {
router.get('/by-slug/:slug', async (req, res) => {
const item = await db.item.findBySlug(req.params.slug);
if(!item.published)
return res.json(null)
res.json(item)
})

@ -74,7 +74,8 @@ create or replace view sos.v_category as
) child_item_counts on "child_category".category_uuid = "child_item_counts".category_uuid
left join sos."category" "parent_category" on "parent_category_link".category_category_parent_uuid = "parent_category".category_uuid
left join sos."category_item" on "category".category_uuid = "category_item".category_item_category_uuid
left join sos.v_item on "category_item".category_item_item_uuid = item_uuid;
left join sos.v_item on "category_item".category_item_item_uuid = item_uuid
where item_published = true;
create or replace view sos.v_cart_price as
select cart_uuid,

@ -9,7 +9,7 @@ import axios from 'axios'
import router from 'next/router'
NewShipment.getInitialProps = async ({ctx: {axios}}) => {
const {data: allItems} = await axios.get('/api/items')
const {data: allItems} = await axios.get('/api/items?showUnpublished=true')
return {allItems}
}

Loading…
Cancel
Save