feat: new listmonk api config for requests sent to listmonk
This commit is contained in:
@@ -29,10 +29,8 @@ declare module '@vue/runtime-core' {
|
|||||||
HoppSmartTable: typeof import('@hoppscotch/ui')['HoppSmartTable']
|
HoppSmartTable: typeof import('@hoppscotch/ui')['HoppSmartTable']
|
||||||
HoppSmartTabs: typeof import('@hoppscotch/ui')['HoppSmartTabs']
|
HoppSmartTabs: typeof import('@hoppscotch/ui')['HoppSmartTabs']
|
||||||
HoppSmartToggle: typeof import('@hoppscotch/ui')['HoppSmartToggle']
|
HoppSmartToggle: typeof import('@hoppscotch/ui')['HoppSmartToggle']
|
||||||
IconLucideArrowLeft: typeof import('~icons/lucide/arrow-left')['default']
|
|
||||||
IconLucideChevronDown: typeof import('~icons/lucide/chevron-down')['default']
|
IconLucideChevronDown: typeof import('~icons/lucide/chevron-down')['default']
|
||||||
IconLucideInbox: typeof import('~icons/lucide/inbox')['default']
|
IconLucideInbox: typeof import('~icons/lucide/inbox')['default']
|
||||||
IconLucideUser: typeof import('~icons/lucide/user')['default']
|
|
||||||
SettingsAuthProvider: typeof import('./components/settings/AuthProvider.vue')['default']
|
SettingsAuthProvider: typeof import('./components/settings/AuthProvider.vue')['default']
|
||||||
SettingsConfigurations: typeof import('./components/settings/Configurations.vue')['default']
|
SettingsConfigurations: typeof import('./components/settings/Configurations.vue')['default']
|
||||||
SettingsDataSharing: typeof import('./components/settings/DataSharing.vue')['default']
|
SettingsDataSharing: typeof import('./components/settings/DataSharing.vue')['default']
|
||||||
|
|||||||
@@ -17,4 +17,9 @@ const restApi = axios.create({
|
|||||||
baseURL: import.meta.env.VITE_BACKEND_API_URL,
|
baseURL: import.meta.env.VITE_BACKEND_API_URL,
|
||||||
});
|
});
|
||||||
|
|
||||||
export { gqlApi, restApi };
|
const listmonkApi = axios.create({
|
||||||
|
...baseConfig,
|
||||||
|
baseURL: 'https://listmonk.hoppscotch.com/api/public',
|
||||||
|
});
|
||||||
|
|
||||||
|
export { gqlApi, restApi, listmonkApi };
|
||||||
|
|||||||
@@ -74,11 +74,11 @@ import { useRouter } from 'vue-router';
|
|||||||
import { useI18n } from '~/composables/i18n';
|
import { useI18n } from '~/composables/i18n';
|
||||||
import { useToast } from '~/composables/toast';
|
import { useToast } from '~/composables/toast';
|
||||||
import { auth } from '~/helpers/auth';
|
import { auth } from '~/helpers/auth';
|
||||||
|
import { listmonkApi } from '~/helpers/axiosConfig';
|
||||||
import {
|
import {
|
||||||
ToggleAnalyticsCollectionDocument,
|
ToggleAnalyticsCollectionDocument,
|
||||||
ToggleAnalyticsCollectionMutationVariables,
|
ToggleAnalyticsCollectionMutationVariables,
|
||||||
} from '~/helpers/backend/graphql';
|
} from '~/helpers/backend/graphql';
|
||||||
import { addSubscriberNewsletterList } from '~/helpers/listmonk';
|
|
||||||
import IconBookOpenText from '~icons/lucide/book-open-text';
|
import IconBookOpenText from '~icons/lucide/book-open-text';
|
||||||
import IconLogIn from '~icons/lucide/log-in';
|
import IconLogIn from '~icons/lucide/log-in';
|
||||||
import IconShieldQuestion from '~icons/lucide/shield-question';
|
import IconShieldQuestion from '~icons/lucide/shield-question';
|
||||||
@@ -92,13 +92,12 @@ const shareData = ref(true);
|
|||||||
const shareEmail = ref(true);
|
const shareEmail = ref(true);
|
||||||
|
|
||||||
const submitSelection = async () => {
|
const submitSelection = async () => {
|
||||||
if (shareData.value) {
|
const dataSharingResult = shareData.value && (await toggleDataSharing());
|
||||||
await toggleDataSharing();
|
const newsletterResult = shareEmail.value && (await toggleNewsletter());
|
||||||
|
|
||||||
|
if (dataSharingResult && newsletterResult) {
|
||||||
|
router.push('/');
|
||||||
}
|
}
|
||||||
if (shareEmail.value) {
|
|
||||||
await toggleNewsletter();
|
|
||||||
}
|
|
||||||
router.push('/');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const dataSharingMutation = useMutation(ToggleAnalyticsCollectionDocument);
|
const dataSharingMutation = useMutation(ToggleAnalyticsCollectionDocument);
|
||||||
@@ -111,17 +110,26 @@ const toggleDataSharing = async () => {
|
|||||||
);
|
);
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
toast.error('Failed to update data sharing settings');
|
toast.error('Failed to update data sharing settings');
|
||||||
} else {
|
return false;
|
||||||
toast.success('Data sharing settings updated');
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggleNewsletter = async () => {
|
const toggleNewsletter = async () => {
|
||||||
shareData.value = !shareData.value;
|
shareData.value = !shareData.value;
|
||||||
await addSubscriberNewsletterList(
|
try {
|
||||||
user?.email as string,
|
await listmonkApi.post('/subscription', {
|
||||||
user?.displayName as string
|
email: user?.email,
|
||||||
);
|
name: user?.displayName,
|
||||||
|
list_uuids: ['f5f0b457-44d0-4aa1-b6f9-165dc1efa56a'],
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
toast.error(t('Unable to update newsletter settings'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user