Change scoreboard to query instead of subscription.
This commit is contained in:
@@ -8,8 +8,11 @@ import { connect } from "react-redux";
|
|||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { useApolloClient } from "@apollo/client";
|
import { useApolloClient, useQuery } from "@apollo/client";
|
||||||
import { GET_BLOCKED_DAYS } from "../../graphql/scoreboard.queries";
|
import {
|
||||||
|
GET_BLOCKED_DAYS,
|
||||||
|
QUERY_SCOREBOARD,
|
||||||
|
} from "../../graphql/scoreboard.queries";
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
//currentUser: selectCurrentUser
|
//currentUser: selectCurrentUser
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
@@ -22,10 +25,15 @@ export default connect(
|
|||||||
mapDispatchToProps
|
mapDispatchToProps
|
||||||
)(ScoreboardDisplayComponent);
|
)(ScoreboardDisplayComponent);
|
||||||
|
|
||||||
export function ScoreboardDisplayComponent({
|
export function ScoreboardDisplayComponent({ bodyshop }) {
|
||||||
bodyshop,
|
const scoreboardSubscription = useQuery(QUERY_SCOREBOARD, {
|
||||||
scoreboardSubscription,
|
variables: {
|
||||||
}) {
|
start: moment().startOf("month"),
|
||||||
|
end: moment().endOf("month"),
|
||||||
|
},
|
||||||
|
pollInterval: 60000,
|
||||||
|
});
|
||||||
|
|
||||||
const { data } = scoreboardSubscription;
|
const { data } = scoreboardSubscription;
|
||||||
const client = useApolloClient();
|
const client = useApolloClient();
|
||||||
const scoreBoardlist = (data && data.scoreboard) || [];
|
const scoreBoardlist = (data && data.scoreboard) || [];
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { gql } from "@apollo/client";
|
import { gql } from "@apollo/client";
|
||||||
|
|
||||||
export const SUBSCRIPTION_SCOREBOARD = gql`
|
export const QUERY_SCOREBOARD = gql`
|
||||||
subscription SUBSCRIPTION_SCOREBOARD($start: date!, $end: date!) {
|
query QUERY_SCOREBOARD($start: date!, $end: date!) {
|
||||||
scoreboard(
|
scoreboard(
|
||||||
where: { _and: { date: { _gte: $start, _lte: $end } } }
|
where: { _and: { date: { _gte: $start, _lte: $end } } }
|
||||||
order_by: { date: asc }
|
order_by: { date: asc }
|
||||||
|
|||||||
@@ -2,17 +2,14 @@ import React, { useEffect } from "react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
|
import FeatureWrapper from "../../components/feature-wrapper/feature-wrapper.component";
|
||||||
|
import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
|
||||||
|
import ScoreboardDisplay from "../../components/scoreboard-display/scoreboard-display.component";
|
||||||
import {
|
import {
|
||||||
setBreadcrumbs,
|
setBreadcrumbs,
|
||||||
setSelectedHeader,
|
setSelectedHeader,
|
||||||
} from "../../redux/application/application.actions";
|
} from "../../redux/application/application.actions";
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
import ScoreboardDisplay from "../../components/scoreboard-display/scoreboard-display.component";
|
|
||||||
import { useSubscription } from "@apollo/client";
|
|
||||||
import { SUBSCRIPTION_SCOREBOARD } from "../../graphql/scoreboard.queries";
|
|
||||||
import moment from "moment";
|
|
||||||
import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
|
|
||||||
import FeatureWrapper from "../../components/feature-wrapper/feature-wrapper.component";
|
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
@@ -26,13 +23,6 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
export function ScoreboardContainer({ setBreadcrumbs, setSelectedHeader }) {
|
export function ScoreboardContainer({ setBreadcrumbs, setSelectedHeader }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const scoreboardSubscription = useSubscription(SUBSCRIPTION_SCOREBOARD, {
|
|
||||||
variables: {
|
|
||||||
start: moment().startOf("month"),
|
|
||||||
end: moment().endOf("month"),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.title = t("titles.scoreboard");
|
document.title = t("titles.scoreboard");
|
||||||
setSelectedHeader("scoreboard");
|
setSelectedHeader("scoreboard");
|
||||||
@@ -47,7 +37,7 @@ export function ScoreboardContainer({ setBreadcrumbs, setSelectedHeader }) {
|
|||||||
return (
|
return (
|
||||||
<FeatureWrapper featureName="scoreboard">
|
<FeatureWrapper featureName="scoreboard">
|
||||||
<RbacWrapper action="scoreboard:view">
|
<RbacWrapper action="scoreboard:view">
|
||||||
<ScoreboardDisplay scoreboardSubscription={scoreboardSubscription} />
|
<ScoreboardDisplay />
|
||||||
</RbacWrapper>
|
</RbacWrapper>
|
||||||
</FeatureWrapper>
|
</FeatureWrapper>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user