Skip to content

Commit

Permalink
feat: save working hours
Browse files Browse the repository at this point in the history
  • Loading branch information
okradze committed Jan 9, 2024
1 parent 563c754 commit a4223f9
Show file tree
Hide file tree
Showing 9 changed files with 64 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 @@ -10,5 +10,7 @@ query campaignById($id: id!) @api(name: "pro") {
status
retry_attempts
retry_interval
working_hours_start
working_hours_end
}
}
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 @@ -11,5 +11,7 @@ query getCampaigns @api(name: "pro") {
call_statuses
retry_attempts
retry_interval
working_hours_start
working_hours_end
}
}
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 @@ -17,5 +17,7 @@ mutation createCampaign($input: input!) @api(name: pro) {
call_statuses
retry_attempts
retry_interval
working_hours_start
working_hours_end
}
}
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 @@ -12,5 +12,7 @@ mutation updateCampaign($id: id!, $input: input!) @api(name: "pro") {
call_statuses
retry_attempts
retry_interval
working_hours_start
working_hours_end
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,26 @@ const CampaignForm = ({ formik }: { formik: any }) => {
size='small'
/>
</StyledCombinedFields>

<StyledCombinedFields>
<FormikTextField
name='campaign_working_hours_start'
field_name='campaign_working_hours_start'
placeholder='Run Date'
label='Working Hours Start'
size={'small'}
type='time'
/>

<FormikTextField
name='campaign_working_hours_end'
field_name='campaign_working_hours_end'
placeholder=''
label='Working Hours End'
size={'small'}
type='time'
/>
</StyledCombinedFields>
</StyledInputWrapper>
</StyledForm>
</StyledRoot>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export const useCreateCampaign = () => {
campaign_start_date: getDateTimeFromDate(new Date(new Date().getTime() + 24 * 60 * 60 * 1000)),
campaign_retry_attempts: 2,
campaign_retry_interval: 15,
campaign_working_hours_start: '10:00',
campaign_working_hours_end: '18:00',
}

const handleSubmit = async (values: any) => {
Expand All @@ -37,6 +39,8 @@ export const useCreateCampaign = () => {
start_date: new Date(values.campaign_start_date).toISOString(),
retry_attempts: values.campaign_retry_attempts,
retry_interval: values.campaign_retry_interval,
working_hours_start: values.campaign_working_hours_start,
working_hours_end: values.campaign_working_hours_end,
}

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 @@ -31,6 +31,8 @@ export const useEditCampaign = () => {
campaign_start_date: getDateTime(campaignById?.start_date),
campaign_retry_attempts: campaignById?.retry_attempts,
campaign_retry_interval: campaignById?.retry_interval,
campaign_working_hours_start: campaignById?.campaign_working_hours_start,
campaign_working_hours_end: campaignById?.campaign_working_hours_end,
}

const handleSubmit = async (values: any) => {
Expand All @@ -44,6 +46,8 @@ export const useEditCampaign = () => {
start_date: new Date(values.campaign_start_date).toISOString(),
retry_attempts: values.campaign_retry_attempts,
retry_interval: values.campaign_retry_interval,
working_hours_start: values.campaign_working_hours_start,
working_hours_end: values.campaign_working_hours_end,
}

await updateCampaign(campaignId || '', updatedValues)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,25 @@ export interface CampaignInput {
type: string
retry_attempts: number
retry_interval: number
working_hours_start: string
working_hours_end: string
}

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

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

const {
data: { createCampaign },
Expand All @@ -30,6 +42,8 @@ export const useCreateCampaignService = () => {
type,
retry_attempts,
retry_interval,
working_hours_start,
working_hours_end,
},
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@ 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, retry_attempts, retry_interval } = input
const {
name,
agent_id,
group_id,
type,
start_date,
retry_attempts,
retry_interval,
working_hours_start,
working_hours_end,
} = input

const { data } = await mutation({
variables: {
Expand All @@ -19,6 +29,8 @@ export const useUpdateCampaignService = () => {
start_date,
retry_attempts,
retry_interval,
working_hours_start,
working_hours_end,
},
},
})
Expand Down

0 comments on commit a4223f9

Please sign in to comment.