|
@@ -15,6 +15,9 @@ import { API_URL } from "@/lib/config";
|
|
|
import { useToast } from "@/hooks/use-toast";
|
|
import { useToast } from "@/hooks/use-toast";
|
|
|
import { useTranslation } from "react-i18next";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
|
|
|
|
|
|
+const HIDE_ORDERS_ACCESS_SETTINGS = import.meta.env.VITE_HIDE_ORDERS_ACCESS_SETTINGS === 'true';
|
|
|
|
|
+const HIDE_CUSTOMERS_ACCESS_SETTINGS = import.meta.env.VITE_HIDE_CUSTOMERS_ACCESS_SETTINGS === 'true';
|
|
|
|
|
+
|
|
|
interface DataAccessPermissions {
|
|
interface DataAccessPermissions {
|
|
|
allow_customer_access: boolean;
|
|
allow_customer_access: boolean;
|
|
|
allow_order_access: boolean;
|
|
allow_order_access: boolean;
|
|
@@ -34,6 +37,10 @@ interface ConnectedStore {
|
|
|
sync_completed_at?: string | null;
|
|
sync_completed_at?: string | null;
|
|
|
sync_error?: string | null;
|
|
sync_error?: string | null;
|
|
|
data_access_permissions?: DataAccessPermissions;
|
|
data_access_permissions?: DataAccessPermissions;
|
|
|
|
|
+ exclusion_stats?: {
|
|
|
|
|
+ excluded_categories: number;
|
|
|
|
|
+ excluded_products: number;
|
|
|
|
|
+ };
|
|
|
alt_data?: {
|
|
alt_data?: {
|
|
|
wcVersion?: string;
|
|
wcVersion?: string;
|
|
|
wpVersion?: string;
|
|
wpVersion?: string;
|
|
@@ -468,12 +475,16 @@ export function IntegrationsContent() {
|
|
|
|
|
|
|
|
const items = [];
|
|
const items = [];
|
|
|
if (stats.products?.synced !== undefined) {
|
|
if (stats.products?.synced !== undefined) {
|
|
|
- items.push({ label: t('integrations.products'), count: stats.products.synced, errors: stats.products.errors || 0 });
|
|
|
|
|
|
|
+ const excludedProducts = shop.exclusion_stats?.excluded_products || 0;
|
|
|
|
|
+ const productLabel = excludedProducts > 0
|
|
|
|
|
+ ? `${t('integrations.products')} (${excludedProducts} excluded)`
|
|
|
|
|
+ : t('integrations.products');
|
|
|
|
|
+ items.push({ label: productLabel, count: stats.products.synced, errors: stats.products.errors || 0 });
|
|
|
}
|
|
}
|
|
|
- if (stats.orders?.synced !== undefined) {
|
|
|
|
|
|
|
+ if (stats.orders?.synced !== undefined && HIDE_ORDERS_ACCESS_SETTINGS == false) {
|
|
|
items.push({ label: t('integrations.orders'), count: stats.orders.synced, errors: stats.orders.errors || 0 });
|
|
items.push({ label: t('integrations.orders'), count: stats.orders.synced, errors: stats.orders.errors || 0 });
|
|
|
}
|
|
}
|
|
|
- if (stats.customers?.synced !== undefined) {
|
|
|
|
|
|
|
+ if (stats.customers?.synced !== undefined && HIDE_CUSTOMERS_ACCESS_SETTINGS == false) {
|
|
|
items.push({ label: t('integrations.customers'), count: stats.customers.synced, errors: stats.customers.errors || 0 });
|
|
items.push({ label: t('integrations.customers'), count: stats.customers.synced, errors: stats.customers.errors || 0 });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -494,6 +505,34 @@ export function IntegrationsContent() {
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ const getExclusionStats = (shop: ConnectedStore) => {
|
|
|
|
|
+ const exclusionStats = shop.exclusion_stats;
|
|
|
|
|
+ if (!exclusionStats || (exclusionStats.excluded_categories === 0 && exclusionStats.excluded_products === 0)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const exclusionItems = [];
|
|
|
|
|
+ if (exclusionStats.excluded_categories > 0) {
|
|
|
|
|
+ exclusionItems.push({ label: t('integrations.excludedCategories', 'Excluded Categories'), count: exclusionStats.excluded_categories });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (exclusionStats.excluded_products > 0) {
|
|
|
|
|
+ exclusionItems.push({ label: t('integrations.excludedProducts', 'Excluded Products'), count: exclusionStats.excluded_products });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (exclusionItems.length === 0) return null;
|
|
|
|
|
+
|
|
|
|
|
+ return (
|
|
|
|
|
+ <div className="flex flex-wrap gap-2 mt-2">
|
|
|
|
|
+ {exclusionItems.map((item) => (
|
|
|
|
|
+ <div key={item.label} className="text-xs bg-orange-700/30 border border-orange-500/30 px-2 py-1 rounded">
|
|
|
|
|
+ <span className="text-orange-400">{item.label}:</span>{' '}
|
|
|
|
|
+ <span className="text-orange-300 font-semibold">{item.count}</span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ ))}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ );
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
const getDataAccessBadges = (shop: ConnectedStore) => {
|
|
const getDataAccessBadges = (shop: ConnectedStore) => {
|
|
|
// Use the store_sync_config policies instead of the old data_access_permissions
|
|
// Use the store_sync_config policies instead of the old data_access_permissions
|
|
|
const syncConfig = getSyncConfig(shop);
|
|
const syncConfig = getSyncConfig(shop);
|
|
@@ -501,6 +540,10 @@ export function IntegrationsContent() {
|
|
|
const customersPolicy = syncConfig?.customers_access_policy || 'api_only';
|
|
const customersPolicy = syncConfig?.customers_access_policy || 'api_only';
|
|
|
const ordersPolicy = syncConfig?.orders_access_policy || 'api_only';
|
|
const ordersPolicy = syncConfig?.orders_access_policy || 'api_only';
|
|
|
|
|
|
|
|
|
|
+ // Check environment variables for hiding specific badges
|
|
|
|
|
+ const hideCustomers = import.meta.env.VITE_HIDE_CUSTOMERS_ACCESS_SETTINGS === 'true';
|
|
|
|
|
+ const hideOrders = import.meta.env.VITE_HIDE_ORDERS_ACCESS_SETTINGS === 'true';
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<div className="flex flex-wrap gap-1">
|
|
<div className="flex flex-wrap gap-1">
|
|
|
{productsPolicy !== 'not_allowed' && (
|
|
{productsPolicy !== 'not_allowed' && (
|
|
@@ -508,17 +551,17 @@ export function IntegrationsContent() {
|
|
|
{t('integrations.products')}
|
|
{t('integrations.products')}
|
|
|
</Badge>
|
|
</Badge>
|
|
|
)}
|
|
)}
|
|
|
- {customersPolicy !== 'not_allowed' && (
|
|
|
|
|
|
|
+ {!hideCustomers && customersPolicy !== 'not_allowed' && (
|
|
|
<Badge variant="outline" className="text-xs border-green-500 text-green-400">
|
|
<Badge variant="outline" className="text-xs border-green-500 text-green-400">
|
|
|
{t('integrations.customers')}
|
|
{t('integrations.customers')}
|
|
|
</Badge>
|
|
</Badge>
|
|
|
)}
|
|
)}
|
|
|
- {ordersPolicy !== 'not_allowed' && (
|
|
|
|
|
|
|
+ {!hideOrders && ordersPolicy !== 'not_allowed' && (
|
|
|
<Badge variant="outline" className="text-xs border-purple-500 text-purple-400">
|
|
<Badge variant="outline" className="text-xs border-purple-500 text-purple-400">
|
|
|
{t('integrations.orders')}
|
|
{t('integrations.orders')}
|
|
|
</Badge>
|
|
</Badge>
|
|
|
)}
|
|
)}
|
|
|
- {customersPolicy === 'not_allowed' && ordersPolicy === 'not_allowed' && (
|
|
|
|
|
|
|
+ {((hideCustomers || customersPolicy === 'not_allowed') && (hideOrders || ordersPolicy === 'not_allowed')) && (
|
|
|
<Badge variant="outline" className="text-xs border-orange-500 text-orange-400">
|
|
<Badge variant="outline" className="text-xs border-orange-500 text-orange-400">
|
|
|
{t('integrations.limitedAccess')}
|
|
{t('integrations.limitedAccess')}
|
|
|
</Badge>
|
|
</Badge>
|
|
@@ -793,7 +836,7 @@ export function IntegrationsContent() {
|
|
|
)}
|
|
)}
|
|
|
{shop.sync_error && (
|
|
{shop.sync_error && (
|
|
|
<div className="text-xs text-red-400 mt-1 truncate" title={shop.sync_error}>
|
|
<div className="text-xs text-red-400 mt-1 truncate" title={shop.sync_error}>
|
|
|
- Error: {shop.sync_error}
|
|
|
|
|
|
|
+ {shop.sync_error}
|
|
|
</div>
|
|
</div>
|
|
|
)}
|
|
)}
|
|
|
{getSyncStats(shop)}
|
|
{getSyncStats(shop)}
|