diff --git a/src/actions/summit-actions.js b/src/actions/summit-actions.js index 15a178edd..d6e2f940c 100644 --- a/src/actions/summit-actions.js +++ b/src/actions/summit-actions.js @@ -21,7 +21,8 @@ import { stopLoading, startLoading, showSuccessMessage, - authErrorHandler + authErrorHandler, + escapeFilterValue } from "openstack-uicore-foundation/lib/utils/actions"; import moment from "moment-timezone"; import { @@ -130,7 +131,12 @@ export const clearCurrentSummit = () => (dispatch) => { }; export const loadSummits = - (page = DEFAULT_CURRENT_PAGE, perPage = DEFAULT_PER_PAGE) => + ( + page = DEFAULT_CURRENT_PAGE, + perPage = DEFAULT_PER_PAGE, + term = "", + hidePastEvents = false + ) => async (dispatch, getState) => { const accessToken = await getAccessTokenSafely(); @@ -146,6 +152,22 @@ export const loadSummits = order: "-start_date" }; + const filters = []; + + if (term) { + const escapedTerm = escapeFilterValue(term); + filters.push(`name=@${escapedTerm}`); + } + + if (hidePastEvents) { + const now = moment().tz("UTC").unix(); + filters.push(`end_date>=${now}`); + } + + if (filters.length > 0) { + params["filter[]"] = filters; + } + getRequest( createAction(REQUEST_SUMMITS), createAction(RECEIVE_SUMMITS), diff --git a/src/i18n/en.json b/src/i18n/en.json index 9c4f9fd05..c47dff548 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -297,10 +297,23 @@ }, "directory": { "select": "Select", - "summits": "Events", - "add_summit": "Add Event", + "summits": "Shows", + "shows": "shows", + "add_summit": "Add Show", "remove_warning": "Are you sure you want to delete event", - "invitation_only": "Invitation Only" + "error_loading": "Error loading directory.", + "invitation_only": "Invitation Only", + "id": "ID", + "summit_name": "Event Name", + "sponsors": "Sponsors", + "forms": "Forms", + "attachments": "Attachments", + "hide_past_events": "Hide past events", + "start_date": "Start Date", + "end_date": "End Date", + "placeholders": { + "search": "Search..." + } }, "dashboard": { "dashboard": "Dashboard", diff --git a/src/pages/summits/summit-dashboard-page.js b/src/pages/summits/summit-dashboard-page.js index 4185da456..010bc48d0 100644 --- a/src/pages/summits/summit-dashboard-page.js +++ b/src/pages/summits/summit-dashboard-page.js @@ -9,13 +9,14 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - **/ + * */ import React from "react"; +import PropTypes from "prop-types"; import { connect } from "react-redux"; import moment from "moment-timezone"; -import { getSummitById } from "../../actions/summit-actions"; import T from "i18n-react/dist/i18n-react"; import { Breadcrumb } from "react-breadcrumbs"; +import { getSummitById } from "../../actions/summit-actions"; import Member from "../../models/member"; import "../../styles/summit-dashboard-page.less"; @@ -37,18 +38,21 @@ class SummitDashboardPage extends React.Component { } onCollapseChange(section) { - let newCollapseState = { ...this.state.collapseState }; + const newCollapseState = { ...this.state.collapseState }; newCollapseState[section] = !newCollapseState[section]; this.setState({ ...this.state, collapseState: newCollapseState }); } componentDidMount() { const { currentSummit } = this.props; - this.interval = setInterval(this.localTimer.bind(this), 1000); + this.interval = setInterval( + this.localTimer.bind(this), + moment.duration(1, "second").asMilliseconds() + ); - if (currentSummit) { - let localtime = moment().tz(currentSummit.time_zone.name); - this.setState({ ...this.state, localtime: localtime }); + if (currentSummit?.time_zone?.name) { + const localtime = moment().tz(currentSummit.time_zone.name); + this.setState({ ...this.state, localtime }); } } @@ -63,8 +67,8 @@ class SummitDashboardPage extends React.Component { } getFormattedTime(atime) { - atime = atime * 1000; - return moment(atime) + return moment + .unix(atime) .tz(this.props.currentSummit.time_zone.name) .format("MMMM Do YYYY, h:mm:ss a"); } @@ -77,10 +81,10 @@ class SummitDashboardPage extends React.Component { render() { const { currentSummit, match, member } = this.props; - let memberObj = new Member(member); - let canEditSummit = memberObj.canEditSummit(); + const memberObj = new Member(member); + const canEditSummit = memberObj.canEditSummit(); - if (!currentSummit.id) return
; + if (!currentSummit.id || !currentSummit.time_zone?.name) return ; return (| {summit.id} | -{summit.name} | -{formatEpoch(summit.start_date, "MMMM Do YYYY")} | -{formatEpoch(summit.end_date, "MMMM Do YYYY")} | -- {summit.invite_only_registration && ( - - {" "} - {T.translate("directory.invitation_only")} - - )} - | -- this.onSelectedSummit(e, summit)} - className="btn btn-default btn-sm" - > - {T.translate("directory.select")} - - {canEditSummit && ( - - {T.translate("general.edit")} - - )} - {canDeleteSummits && ( - - {T.translate("general.delete")} - - )} - | -
{err.message}