Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ import {
createWoocommerceSalesChannelMutation,
getAmazonRedirectUrlMutation,
getEbayRedirectUrlMutation,
getShopifyRedirectUrlMutation,
getSheinRedirectUrlMutation,
refreshSalesChannelWebsitesMutation,
} from '../../../../shared/api/mutations/salesChannels.js';
import { createWebhookIntegrationMutation } from '../../../../shared/api/mutations/webhookIntegrations.js';
import { Toast } from '../../../../shared/modules/toast';
Expand Down Expand Up @@ -479,7 +479,7 @@ const handleFinish = async () => {
if (data && data[mutationKey]) {
Toast.success(t('integrations.create.success'));
loading.value = false;
handleSalesChannelSuccess(data[mutationKey], resolvedIntegrationType.value);
await handleSalesChannelSuccess(data[mutationKey], resolvedIntegrationType.value);
}
} catch (err) {
loading.value = false;
Expand All @@ -498,7 +498,6 @@ const handleFinish = async () => {
const handleShopifySalesChannelSuccess = async (channelData: any) => {
const id = channelData.id;

/*
const { data } = await apolloClient.mutate({
mutation: getShopifyRedirectUrlMutation,
variables: {
Expand All @@ -513,29 +512,15 @@ const handleShopifySalesChannelSuccess = async (channelData: any) => {
return;
}

// If we have errors from OperationInfo
const messages = result?.messages || [];
messages.forEach((msg: any) => {
Toast.error(msg.message);
});
*/
try {
loading.value = true;
await apolloClient.mutate({
mutation: refreshSalesChannelWebsitesMutation,
variables: {
data: { id },
},
if (messages.length) {
messages.forEach((msg: any) => {
Toast.error(msg.message);
});
Toast.success(t("integrations.show.pullData.success"));
} catch (error) {
Toast.error(t("integrations.show.pullData.error"));
console.error("Pull data failed:", error);
} finally {
loading.value = false;
} else {
Toast.error(t('integrations.salesChannel.shopify.installed.genericError'));
}

// Redirect to show page anyway
router.push({
name: 'integrations.integrations.show',
params: { type: IntegrationTypes.Shopify, id },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<script setup lang="ts">
import { computed, defineProps } from 'vue';
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { Label } from "../../../../../../../shared/components/atoms/label";
import { TextInput } from "../../../../../../../shared/components/atoms/input-text";
import { ShopifyChannelInfo } from '../../../../integrations';
import { Icon } from "../../../../../../../shared/components/atoms/icon";
import { Button } from "../../../../../../../shared/components/atoms/button";
Expand All @@ -14,7 +13,7 @@ import {
FieldQuery
} from "../../../../../../../shared/components/organisms/general-form/containers/form-fields/field-query";

const props = defineProps<{
defineProps<{
channelInfo: ShopifyChannelInfo
}>();

Expand Down Expand Up @@ -48,74 +47,40 @@ const propertyField = computed(() => ({
<template>
<div>
<h1 class="text-2xl text-center mb-2">
{{ t('integrations.create.wizard.step4.magento.content') }}
{{ t('integrations.create.wizard.step4.shopify.content') }}
</h1>
<hr/>
<Flex vertical>
<FlexCell>
<Flex class="mt-4 gap-4" center>
<FlexCell center>
<Flex vertical class="gap-2">
<Flex vertical class="gap-4">
<FlexCell>
<Label class="font-semibold block text-sm leading-6 text-gray-900">
{{ t('integrations.labels.apiKey') }}
</Label>
</FlexCell>
<FlexCell>
<TextInput
class="w-96"
v-model="channelInfo.apiKey"
:placeholder="t('integrations.placeholders.apiKey')"
/>
</FlexCell>
<FlexCell>
<Label class="font-semibold block text-sm leading-6 text-gray-900">
{{ t('integrations.labels.apiSecret') }}
</Label>
</FlexCell>
<FlexCell>
<TextInput
class="w-96"
v-model="channelInfo.apiSecret"
:placeholder="t('integrations.placeholders.apiSecret')"
:secret="true"
/>
<div class="w-96 rounded-xl border border-emerald-200 bg-emerald-50 px-4 py-3 text-sm leading-6 text-emerald-900">
{{ t('integrations.create.wizard.step1.shopifyInfoModal.section.integrationStep8') }}
</div>
</FlexCell>
<FlexCell>
<Label class="font-semibold block text-sm leading-6 text-gray-900">
{{ t('integrations.labels.accessToken') }}
{{ t('integrations.labels.vendorProperty') }}
</Label>
</FlexCell>
<FlexCell>
<TextInput
class="w-96"
v-model="channelInfo.accessToken"
:placeholder="t('integrations.placeholders.accessToken')"
secret
/>
</FlexCell>

<FlexCell>
<Flex between>
<FlexCell grow>
<Label class="font-semibold block text-sm leading-6 text-gray-900">
{{ t('integrations.labels.vendorProperty') }}
</Label>
<div class="mt-1 text-sm leading-6 text-gray-400 w-96">
<p>{{ t('integrations.salesChannel.helpText.shopifyVendorProperty') }}</p>
</div>
</FlexCell>
<FlexCell center>
<Button class="btn-primary px-1.5 py-1 rounded-full" @click="openInNewTab">
<Icon name="plus"/>
</Button>
</FlexCell>
<FlexCell center>
<Button class="btn-primary px-1.5 py-1 rounded-full" @click="openInNewTab">
<Icon name="plus"/>
</Button>
</FlexCell>
</Flex>

</FlexCell>
<FlexCell>
<FieldQuery v-model="channelInfo.vendorProperty.id" :field="propertyField as QueryFormField" />

<div class="mt-1 text-sm leading-6 text-gray-400 w-96">
<p>{{ t('integrations.salesChannel.helpText.shopifyVendorProperty') }}</p>
</div>
</FlexCell>
</Flex>
</FlexCell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ const createShopifySalesChannel = async (queryParams: Record<string, any>, hostn
const handleShopifySalesChannelSuccess = async (channelData: any) => {
const id = channelData.id;

/*
const { data } = await apolloClient.mutate({
mutation: getShopifyRedirectUrlMutation,
variables: { data: { id } },
Expand All @@ -90,15 +89,18 @@ const handleShopifySalesChannelSuccess = async (channelData: any) => {
const result = data?.getShopifyRedirectUrl;

if (result?.redirectUrl) {
window.location.href = result.redirectUrl;
window.location.href = result.redirectUrl;
return;
}

const messages = result?.messages || [];
messages.forEach((msg: any) => {
Toast.error(msg.message);
});
*/
if (messages.length) {
messages.forEach((msg: any) => {
Toast.error(msg.message);
});
} else {
Toast.error(t('integrations.salesChannel.shopify.installed.genericError'));
}

router.push({
name: 'integrations.integrations.show',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
updateShopifySalesChannelMutation
} from "../../../../../../../shared/api/mutations/salesChannels.js";
import { processGraphQLErrors } from "../../../../../../../shared/utils";
import { cleanShopHostname } from "../../../../configs";
import apolloClient from "../../../../../../../../apollo-client";
import {FieldType, PropertyTypes} from "../../../../../../../shared/utils/constants";
import {propertiesQuerySelector} from "../../../../../../../shared/api/queries/properties";
Expand All @@ -40,8 +39,6 @@ interface EditShopifyForm {
importOrders: boolean;
minNameLength: number | null;
minDescriptionLength: number | null;
apiKey: string;
apiSecret: string;
accessToken?: string;
state?: string;
gptEnable: boolean;
Expand Down Expand Up @@ -111,6 +108,7 @@ const cleanupAndMutate = async (mutate) => {
const payload = { ...formData.value };

delete (payload as any).startingStock;
delete (payload as any).accessToken;

if (!payload.vendorProperty?.id) {
delete (payload as any).vendorProperty;
Expand Down Expand Up @@ -239,30 +237,6 @@ useShiftBackspaceKeyboardListener(goBack);
</div>
</div>

<div class="grid grid-cols-12 gap-4">
<div class="md:col-span-6 col-span-12">
<Label class="font-semibold block text-sm leading-6 text-gray-900 mb-1">
{{ t('integrations.labels.apiKey') }}
</Label>
<TextInput v-model="formData.apiKey" disabled class="w-full" />
</div>
<div class="md:col-span-6 col-span-12">
<Label class="font-semibold block text-sm leading-6 text-gray-900 mb-1">
{{ t('integrations.labels.apiSecret') }}
</Label>
<TextInput v-model="formData.apiSecret" disabled :secret="true" class="w-full" />
</div>
</div>

<div class="grid grid-cols-12 gap-4">
<div class="md:col-span-12 col-span-12">
<Label class="font-semibold block text-sm leading-6 text-gray-900 mb-1">
{{ t('integrations.labels.accessToken') }}
</Label>
<TextInput v-model="formData.accessToken" secret class="w-full" />
</div>
</div>

<!-- Accordion -->
<Accordion class="mt-8" :items="accordionItems">
<!-- Throttling -->
Expand Down
Loading