From 118174118ef096584ad77aba84c02de9d42cf2aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Castillo?= Date: Mon, 8 Jul 2024 20:29:52 -0300 Subject: [PATCH] Adjust params for template search, change menu text, initial order dir on reducer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Castillo --- src/actions/email-actions.js | 14 ++++++++++++-- src/i18n/en.json | 2 +- src/pages/emails/email-log-list-page.js | 2 +- src/reducers/emails/email-log-list-reducer.js | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/actions/email-actions.js b/src/actions/email-actions.js index 35eddade5..9a0e4758f 100644 --- a/src/actions/email-actions.js +++ b/src/actions/email-actions.js @@ -31,6 +31,7 @@ import { } from 'openstack-uicore-foundation/lib/utils/actions'; import {checkOrFilter,getAccessTokenSafely} from '../utils/methods'; import { saveMarketingSetting } from "./marketing-actions"; +import URI from "urijs"; export const REQUEST_TEMPLATES = 'REQUEST_TEMPLATES'; @@ -234,10 +235,19 @@ const normalizeEntity = (entity) => { export const queryTemplates = _.debounce(async (input, callback) => { const accessToken = await getAccessTokenSafely(); - + + let endpoint = URI(`${window.EMAIL_API_BASE_URL}/api/v1/mail-templates`); + input = escapeFilterValue(input); - fetch(`${window.EMAIL_API_BASE_URL}/api/v1/mail-templates?identifier__contains=${input}&access_token=${accessToken}`) + endpoint.addQuery('access_token', accessToken); + endpoint.addQuery('order','-id') + + if(input) { + endpoint.addQuery('identifier__contains', input); + } + + fetch(endpoint) .then(fetchResponseHandler) .then((json) => { const options = [...json.data]; diff --git a/src/i18n/en.json b/src/i18n/en.json index e07d9e200..159f92e33 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -137,7 +137,7 @@ "emails": "Emails", "email_templates": "Templates", "sent_email": "Sent Emails", - "email_logs": "Email Logs", + "email_logs": "Logs", "summitdocs": "Event Docs", "email_flow_events": "Email Events", "email_flow_overrides": "Overrides", diff --git a/src/pages/emails/email-log-list-page.js b/src/pages/emails/email-log-list-page.js index 4ded5cb79..2c10b5278 100644 --- a/src/pages/emails/email-log-list-page.js +++ b/src/pages/emails/email-log-list-page.js @@ -36,7 +36,7 @@ const SentEmailListPage = ({ ...props }) => { useEffect(() => { - props.getSentEmails(term, currentPage, perPage, order, 0, filters); + props.getSentEmails(term, currentPage, perPage, order, orderDir, filters); }, []); const defaultFilters = { diff --git a/src/reducers/emails/email-log-list-reducer.js b/src/reducers/emails/email-log-list-reducer.js index 0ebe75abe..72cd513c0 100644 --- a/src/reducers/emails/email-log-list-reducer.js +++ b/src/reducers/emails/email-log-list-reducer.js @@ -24,7 +24,7 @@ const DEFAULT_STATE = { emails : [], term : '', order : 'id', - orderDir : 1, + orderDir : 0, currentPage : 1, lastPage : 1, perPage : 10,