Skip to content

Commit

Permalink
added id as a parameter in Campaign Form2 and Form3
Browse files Browse the repository at this point in the history
  • Loading branch information
srp-pawar committed Apr 24, 2024
1 parent 3b1a0c1 commit 527236a
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { UPDATE_LAST_EXECUTION_ID } from '@/users/graphql/queries/updateLastExec
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
import { useNavigate } from 'react-router-dom';
import { CustomPath } from '@/types/CustomPath';
import { send } from 'vite';

type RecordIndexTableContainerEffectProps = {
objectNameSingular: string;
Expand Down Expand Up @@ -131,7 +132,7 @@ export const RecordIndexTableContainerEffect = ({
color: ${({ theme }) => theme.font.color.secondary};
display: flex;
flex-direction: column;
height: auto%;
height: auto;
justify-content: space-evenly;
width: 100%;
`;
Expand Down Expand Up @@ -356,13 +357,13 @@ export const RecordIndexTableContainerEffect = ({
);

let idsToSend: any[] = [];
let idType: 'selected' | 'unselected';
let idType: 'selectedID' | 'unselectedID';

if (selectedLeadIds.length < unSelectedLeadIds.length) {
idType = 'selected';
idType = 'selectedID';
idsToSend = selectedLeadIds.map((leadId) => ({ id: leadId }));
} else {
idType = 'unselected';
idType = 'unselectedID';
idsToSend = unSelectedLeadIds.map((leadId) => ({ id: leadId }));
}

Expand Down Expand Up @@ -426,28 +427,33 @@ export const RecordIndexTableContainerEffect = ({
console.log('Request Body:', requestBody);

// Now you can send the requestBody to your endpoint
// const response = await fetch('someEndpointURL', {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json',
// },
// body: JSON.stringify(requestBody),
// });
// const data = await response.json();

// console.log('Response from the API:', data);
const response = true;

if (response) {
const campaignResponse = await fetch(`http://localhost:3000/campaign/execute`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(requestBody),
});
const data = await campaignResponse.json();

console.log('Response from the API:', data);
// const response = true;

if (campaignResponse.status==201) {
setConfirmModalOpen(false);
setIsModalOpen(false);
}else{
throw Error("Campaign Not started ")
}
navigate(CustomPath.CampaignTriggersPage);
enqueueSnackBar('Campaign running successfully', {
variant: 'success',
});
} catch (error) {
console.log('Error in triggering campaign', error);
enqueueSnackBar('Error in triggering campaign', {
variant: 'error',
});
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ query FindManyCampaigns($filter: CampaignFilterInput, $orderBy: CampaignOrderByI
segment{
id
name
filters
}
subspecialty
specialty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const CampaignForm2 = () => {
const fetchUserDetails = async () => {
try {
const response = await fetch(
`http://localhost:3000/campaign?id=${userid}`,
`http://localhost:3000/campaign/${userid}`,
);
if (!response.ok) {
throw new Error('Failed to fetch user details');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export const CampaignForm3 = () => {
const fetchUserDetails = async () => {
try {
const response = await fetch(
`http://localhost:3000/campaign?id=${userid}`,
`http://localhost:3000/campaign/${userid}`,
);
if (!response.ok) {
throw new Error('Failed to fetch user details');
Expand Down
2 changes: 1 addition & 1 deletion packages/twenty-server/src/campaign/campaign.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class CampaignController {
async validateFormDetails(@Param() id: any) {
try {
id = id.id.toString();

return this.campaignService.validateFormDetails(id);
} catch (error) {
return error;
Expand Down
1 change: 1 addition & 0 deletions packages/twenty-server/src/campaign/campaign.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ export class CampaignService {
return fetchedData;
} catch (error) {
console.error(error);
return error
}
}

Expand Down

0 comments on commit 527236a

Please sign in to comment.