Skip to content

Commit

Permalink
feat: campaign retry attempts and interval in minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
okradze committed Jan 9, 2024
1 parent 55e33f4 commit dcc699a
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 2 deletions.
2 changes: 2 additions & 0 deletions apps/ui/src/plugins/contact/gql/campaign/campaignById.gql
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ query campaignById($id: id!) @api(name: "pro") {
type
start_date
status
retry_attempts
retry_interval
}
}
2 changes: 2 additions & 0 deletions apps/ui/src/plugins/contact/gql/campaign/campaigns.gql
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ query getCampaigns @api(name: "pro") {
status
total_calls
call_statuses
retry_attempts
retry_interval
}
}
2 changes: 2 additions & 0 deletions apps/ui/src/plugins/contact/gql/campaign/createCampaign.gql
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ mutation createCampaign($input: input!) @api(name: pro) {
status
total_calls
call_statuses
retry_attempts
retry_interval
}
}
2 changes: 2 additions & 0 deletions apps/ui/src/plugins/contact/gql/campaign/updateCampaign.gql
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ mutation updateCampaign($id: id!, $input: input!) @api(name: "pro") {
status
total_calls
call_statuses
retry_attempts
retry_interval
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import FormikTextField from 'components/TextFieldFormik'
import { StyledForm, StyledInputWrapper, StyledRoot } from '../../Contact/ContactForm/ContactForm'
import AgentDropdown from 'pages/Agents/AgentForm/components/AgentDropdown'
import { useCampaignForm } from './useCampaignForm'
import { StyledCombinedFields } from 'pages/Agents/AgentForm/AgentForm'

const CampaignForm = ({ formik }: { formik: any }) => {
const { setFieldValue, values } = formik
Expand Down Expand Up @@ -49,6 +50,22 @@ const CampaignForm = ({ formik }: { formik: any }) => {
size={'small'}
type='datetime-local'
/>

<StyledCombinedFields>
<FormikTextField
name='campaign_retry_attempts'
placeholder='2'
label='Retry Attempts'
size='small'
/>

<FormikTextField
name='campaign_retry_interval'
placeholder='15'
label='Retry Interval In Minutes'
size='small'
/>
</StyledCombinedFields>
</StyledInputWrapper>
</StyledForm>
</StyledRoot>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export const useCreateCampaign = () => {
campaign_group_id: null,
campaign_type: 'Outbound',
campaign_start_date: getDateTimeFromDate(new Date(new Date().getTime() + 24 * 60 * 60 * 1000)),
campaign_retry_attempts: 2,
campaign_retry_interval: 15,
}

const handleSubmit = async (values: any) => {
Expand All @@ -33,6 +35,8 @@ export const useCreateCampaign = () => {
group_id: values.campaign_group_id,
type: values.campaign_type,
start_date: new Date(values.campaign_start_date).toISOString(),
retry_attempts: values.campaign_retry_attempts,
retry_interval: values.campaign_retry_interval,
}

await createCampaign(campaignInput)
Expand Down
4 changes: 4 additions & 0 deletions apps/ui/src/plugins/contact/pages/Campaign/useEditCampaign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export const useEditCampaign = () => {
campaign_agent_id: campaignById?.agent_id,
campaign_group_id: campaignById?.group_id,
campaign_start_date: getDateTime(campaignById?.start_date),
campaign_retry_attempts: campaignById?.retry_attempts,
campaign_retry_interval: campaignById?.retry_interval,
}

const handleSubmit = async (values: any) => {
Expand All @@ -40,6 +42,8 @@ export const useEditCampaign = () => {
group_id: values.campaign_group_id,
type: values.campaign_type,
start_date: new Date(values.campaign_start_date).toISOString(),
retry_attempts: values.campaign_retry_attempts,
retry_interval: values.campaign_retry_interval,
}

await updateCampaign(campaignId || '', updatedValues)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ export interface CampaignInput {
group_id: string
start_date: any
type: string
retry_attempts: number
retry_interval: number
}

export const useCreateCampaignService = () => {
const [mutation] = useMutation(CREATE_CAMPAIGN_GQL)

const createCampaignService = async (input: CampaignInput) => {
const { name, agent_id, group_id, start_date, type } = input
const { name, agent_id, group_id, start_date, type, retry_attempts, retry_interval } = input

const {
data: { createCampaign },
Expand All @@ -26,6 +28,8 @@ export const useCreateCampaignService = () => {
group_id,
start_date,
type,
retry_attempts,
retry_interval,
},
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CampaignInput } from './useCreateCampaignService'
export const useUpdateCampaignService = () => {
const [mutation] = useMutation(UPDATE_CAMPAIGN_GQL)
const updateCampaign = async (id: string, input: CampaignInput) => {
const { name, agent_id, group_id, type, start_date } = input
const { name, agent_id, group_id, type, start_date, retry_attempts, retry_interval } = input

const { data } = await mutation({
variables: {
Expand All @@ -17,6 +17,8 @@ export const useUpdateCampaignService = () => {
group_id,
type,
start_date,
retry_attempts,
retry_interval,
},
},
})
Expand Down

0 comments on commit dcc699a

Please sign in to comment.