Skip to content

Commit

Permalink
fix(webpage): remove OpenAPI config and phone pressure
Browse files Browse the repository at this point in the history
  • Loading branch information
igr-santos committed Oct 30, 2024
1 parent f48251f commit f442cb8
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 190 deletions.
3 changes: 0 additions & 3 deletions clients/deploy/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ services:
- REACT_APP_DOMAIN_API_REST=${PUBLIC_REST_API:-http://api-rest.bonde.devel}
- REACT_APP_DOMAIN_PUBLIC=${DEFAULT_DOMAIN_RULE:-bonde.devel}
- REACT_APP_ACTIVE_API_CACHE=${ACTIVE_API_CACHE:-false}
- REACT_APP_OPENAPI_URL=${PUBLIC_OPENAPI_URL:-https://openapi.staging.bonde.org}
- REACT_APP_OPENAPI_TOKEN=${PUBLIC_OPENAPI_TOKEN}
- REACT_APP_OPENAPI_CAMPAIGN_ID=${PUBLIC_OPENAPI_CAMPAIGN_ID}
healthcheck:
test: "${DOCKER_WEB_HEALTHCHECK_TEST:-wget -qO- localhost:3000/api/ping}"
interval: "60s"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,161 +1,6 @@
import { useEffect, useState } from 'react';
import { gql } from '@apollo/client';
import {
PressureAnalytics,
FinishMessageCustom,
PressureTellAFriend,
} from '../bonde-webpage';
import Utils from '../Utils';

import {
PhonePressurePlugin,
// asyncFillWidget,
// selectors as MobSelectors,
} from '../bonde-webpage';
import { client } from '../apis/graphql';

export const addTwilioCall = gql`
mutation addTwilioCall(
$widgetId: Int!
$communityId: Int!
$from: String!
$to: String!
) {
addTwilioCall(
input: {
call: {
widgetId: $widgetId
communityId: $communityId
from: $from
to: $to
}
}
) {
twilioCall {
id
widgetId
activistId
twilioAccountSid
twilioCallSid
from
to
data
createdAt
updatedAt
communityId
}
}
}
`;

export const watchTwilioCallTransitions = gql`
query watchTwilioCallTransitions($widgetId: Int!, $from: String!) {
watchTwilioCallTransitions(call: { widgetId: $widgetId, from: $from }) {
widgetId
activistId
twilioCallId
twilioCallAccountSid
twilioCallCallSid
twilioCallFrom
twilioCallTo
twilioCallTransitionId
twilioCallTransitionSequenceNumber
twilioCallTransitionStatus
twilioCallTransitionCallDuration
twilioCallTransitionCreatedAt
twilioCallTransitionUpdatedAt
}
}
`;

export const countTwilioCallsByWidget = gql`
query CountTwilioCallsByWidget($widgetId: Int!) {
allTwilioCalls(condition: { widgetId: $widgetId }) {
totalCount
}
}
`;

const TwilioCall = ({ children, totalCount }) => {
const [phonePressureCount, setPhonePressureCount] = useState(0);
const [callTransition, setCallTransition] = useState<any>(null);
const [observableQuery, setObservableQuery] = useState<any>(null);

useEffect(() => {
if (totalCount > phonePressureCount) {
setPhonePressureCount(totalCount);
}
}, [totalCount]);

const call = (variables: any, watchQuery = false) => {
setPhonePressureCount(phonePressureCount + 1);
return client.mutate({ mutation: addTwilioCall, variables }).then(() => {
if (watchQuery && !observableQuery) {
const observable = client.watchQuery({
pollInterval: 2000,
query: watchTwilioCallTransitions,
variables: { widgetId: variables.widgetId, from: variables.from },
});
observable.subscribe({
next: ({
data: { watchTwilioCallTransitions: transitions },
}: any) => {
setCallTransition(transitions);
},
});
setObservableQuery(observable);
}
});
};

return children({
call,
callTransition,
observableQuery,
phonePressureCount,
});
};

// const mapDispatchToProps = { asyncFillWidget };

// const mapStateToProps = (state: any) =>
// MobSelectors(state).getMobilizationLink();

const PressurePhoneConnected = (props: any) => {
const [totalCount, setTotalCount] = useState(0);

useEffect(() => {
client
.query({
query: countTwilioCallsByWidget,
variables: { widgetId: props.widget.id },
})
.then(({ data }) => {
setTotalCount(data.allTwilioCalls.totalCount);
});
}, []);

const PressurePhoneConnected = () => {
return (
<TwilioCall totalCount={totalCount}>
{(twilio: any) =>
<PhonePressurePlugin
{...props}
asyncFillWidget={(values: any) => console.log("should be implement asyncFillWidget >>> ", { values })}
twilio={twilio}
analyticsEvents={PressureAnalytics}
overrides={{
FinishCustomMessage: { component: FinishMessageCustom },
FinishDefaultMessage: {
component: PressureTellAFriend,
props: {
imageUrl: Utils.imageUrl,
href: Utils.getSharedPath(props.mobilization),
},
},
}}
/>
}
</TwilioCall>
<div title="Pressão por Telefone Desabilitada"></div>
);
};

Expand Down

This file was deleted.

0 comments on commit f442cb8

Please sign in to comment.