Skip to content

Commit

Permalink
Fixes editing campaign lists and scheduling deleted campaigns (#409)
Browse files Browse the repository at this point in the history
  • Loading branch information
pushchris authored Mar 29, 2024
1 parent 57ecb39 commit b4cbf1b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions apps/platform/src/campaigns/CampaignGenerateListJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default class CampaignGenerateListJob extends Job {
const key = `campaign_generate_${id}`

const campaign = await getCampaign(id, project_id) as SentCampaign
if (!campaign) return
if (campaign.state === 'aborted' || campaign.state === 'draft') return

// Increase lock duration based on estimated send size
Expand Down
1 change: 1 addition & 0 deletions apps/platform/src/campaigns/ProcessCampaignsJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default class ProcessCampaignsJob extends Job {
const campaigns = await Campaign.query()
.whereIn('state', ['pending', 'scheduled', 'running'])
.whereNotNull('send_at')
.whereNull('deleted_at')
.where('type', 'blast')
for (const campaign of campaigns) {

Expand Down
13 changes: 7 additions & 6 deletions apps/ui/src/views/campaign/CampaignForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ const ProviderSelection = ({ providers, form }: { providers: Provider[], form: U
)
}

const TypeSelection = ({ campaign, form }: { campaign?: Campaign, form: UseFormReturn<CampaignCreateParams> }) => {
const TypeSelection = ({ campaign, showType, form }: { campaign?: Campaign, showType: boolean, form: UseFormReturn<CampaignCreateParams> }) => {
const { t } = useTranslation()
const type = useWatch({
control: form.control,
Expand All @@ -215,14 +215,14 @@ const TypeSelection = ({ campaign, form }: { campaign?: Campaign, form: UseFormR
}]

return <>
<RadioInput.Field
{showType && <RadioInput.Field
form={form}
name="type"
subtitle={t('campaign_form_type')}
label={t('type')}
options={options}
required
/>
/>}
{
type !== 'trigger' && (
<>
Expand Down Expand Up @@ -303,9 +303,10 @@ export function CampaignForm({ campaign, onSave, type }: CampaignEditParams) {
name="tags"
label={t('tags')}
/>
{
!type && <TypeSelection campaign={campaign} form={form} />
}
<TypeSelection
campaign={campaign}
form={form}
showType={!type} />
{
campaign
? (
Expand Down

0 comments on commit b4cbf1b

Please sign in to comment.