From da81ef2e5e09dd48caff5f456e5b9a3c6e593112 Mon Sep 17 00:00:00 2001 From: The Nguyen <6950941+treoden@users.noreply.github.com> Date: Sun, 1 Sep 2024 23:07:43 +0700 Subject: [PATCH] Fix status issue when loading cms page --- .../cms/pages/frontStore/cmsPageView/index.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/packages/evershop/src/modules/cms/pages/frontStore/cmsPageView/index.js b/packages/evershop/src/modules/cms/pages/frontStore/cmsPageView/index.js index 0f53246d0..1e513ec1d 100644 --- a/packages/evershop/src/modules/cms/pages/frontStore/cmsPageView/index.js +++ b/packages/evershop/src/modules/cms/pages/frontStore/cmsPageView/index.js @@ -1,24 +1,18 @@ -const { select } = require('@evershop/postgres-query-builder'); const { pool } = require('@evershop/evershop/src/lib/postgres/connection'); const { setContextValue } = require('../../../../graphql/services/contextHelper'); +const { + getCmsPagesBaseQuery +} = require('../../../services/getCmsPagesBaseQuery'); module.exports = async (request, response, delegate, next) => { try { - const query = select(); + const query = getCmsPagesBaseQuery(); query - .from('cms_page') - .leftJoin('cms_page_description') - .on( - 'cms_page.cms_page_id', - '=', - 'cms_page_description.cms_page_description_cms_page_id' - ); - - query.where('cms_page_description.url_key', '=', request.params.url_key); + .where('cms_page_description.url_key', '=', request.params.url_key) + .and('cms_page.status', '=', 1); const page = await query.load(pool); - if (page === null) { response.status(404); next();