Skip to content

Commit

Permalink
Merge pull request #1977 from glific/bug/copy-trigger
Browse files Browse the repository at this point in the history
Copy trigger editable fixes
  • Loading branch information
kurund authored Mar 24, 2022
2 parents c599f39 + 62b67be commit 5eaa55f
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions src/containers/Trigger/Trigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,17 @@ const getFrequencyDetails = (

return frequencyDetails;
};
export const Trigger: React.SFC<TriggerProps> = ({ match }) => {
let isEditing = false;
if (match.params.id) {
isEditing = true;
}

const triggerIcon = <TriggerIcon className={styles.TriggerIcon} />;

const queries = {
getItemQuery: GET_TRIGGER,
createItemQuery: CREATE_TRIGGER,
updateItemQuery: UPDATE_TRIGGER,
deleteItemQuery: DELETE_TRIGGER,
};

export const Trigger: React.SFC<TriggerProps> = ({ match }) => {
const [flowId, setFlowId] = useState(null);
const [isActive, setIsActive] = useState(true);
const [startTime, setStartTime] = useState('');
Expand Down Expand Up @@ -149,6 +154,23 @@ export const Trigger: React.SFC<TriggerProps> = ({ match }) => {
{ label: t('Weekly'), value: 'weekly' },
{ label: t('Monthly'), value: 'monthly' },
];
const dialogMessage = t("You won't be able to use this for tagging messages.");

let isEditing = false;
let type;

const isCopyState = location.state === 'copy';

if (match.params.id && !isCopyState) {
isEditing = true;
}

if (isCopyState) {
queries.updateItemQuery = CREATE_TRIGGER;
type = 'copy';
} else {
queries.updateItemQuery = UPDATE_TRIGGER;
}

const schemaShape: any = {
flowId: Yup.object().nullable().required(t('Flow is required')),
Expand Down Expand Up @@ -189,26 +211,6 @@ export const Trigger: React.SFC<TriggerProps> = ({ match }) => {

const FormSchema = Yup.object().shape(schemaShape);

const dialogMessage = t("You won't be able to use this for tagging messages.");

const triggerIcon = <TriggerIcon className={styles.TriggerIcon} />;

const queries = {
getItemQuery: GET_TRIGGER,
createItemQuery: CREATE_TRIGGER,
updateItemQuery: UPDATE_TRIGGER,
deleteItemQuery: DELETE_TRIGGER,
};

let type;

if (location.state === 'copy') {
queries.updateItemQuery = CREATE_TRIGGER;
type = 'copy';
} else {
queries.updateItemQuery = UPDATE_TRIGGER;
}

const { data: flow } = useQuery(GET_FLOWS, {
variables: setVariables({
status: FLOW_STATUS_PUBLISHED,
Expand Down

0 comments on commit 5eaa55f

Please sign in to comment.