|
|
@@ -10,6 +10,10 @@ import { Shield, ShieldCheck, ShieldAlert, Info, Loader2, Database, Cloud, Ban }
|
|
|
import { API_URL } from "@/lib/config";
|
|
|
import { useToast } from "@/hooks/use-toast";
|
|
|
|
|
|
+// GDPR Compliance: Check if settings should be hidden
|
|
|
+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';
|
|
|
+
|
|
|
type DataAccessPolicy = 'sync' | 'api_only' | 'not_allowed';
|
|
|
|
|
|
interface DataAccessPermissions {
|
|
|
@@ -116,12 +120,27 @@ export function DataAccessSettings({
|
|
|
};
|
|
|
|
|
|
const getSecurityLevel = () => {
|
|
|
- const notAllowedCount = Object.values(policies).filter(p => p === 'not_allowed').length;
|
|
|
- const apiOnlyCount = Object.values(policies).filter(p => p === 'api_only').length;
|
|
|
+ // Only count policies for visible settings
|
|
|
+ const visiblePolicies = [
|
|
|
+ policies.products_access_policy,
|
|
|
+ ...(!HIDE_CUSTOMERS_ACCESS_SETTINGS ? [policies.customers_access_policy] : []),
|
|
|
+ ...(!HIDE_ORDERS_ACCESS_SETTINGS ? [policies.orders_access_policy] : [])
|
|
|
+ ];
|
|
|
+
|
|
|
+ const notAllowedCount = visiblePolicies.filter(p => p === 'not_allowed').length;
|
|
|
+ const apiOnlyCount = visiblePolicies.filter(p => p === 'api_only').length;
|
|
|
+ const totalVisible = visiblePolicies.length;
|
|
|
+
|
|
|
+ // When all settings are hidden except products, show based on products only
|
|
|
+ if (totalVisible === 1) {
|
|
|
+ if (policies.products_access_policy === 'not_allowed') return { level: "maximum", icon: ShieldCheck, color: "text-green-500", label: "Maximum Privacy" };
|
|
|
+ if (policies.products_access_policy === 'api_only') return { level: "high", icon: ShieldCheck, color: "text-green-400", label: "High Privacy" };
|
|
|
+ return { level: "full", icon: ShieldAlert, color: "text-orange-500", label: "Full Sync" };
|
|
|
+ }
|
|
|
|
|
|
- if (notAllowedCount === 3) return { level: "maximum", icon: ShieldCheck, color: "text-green-500", label: "Maximum Privacy" };
|
|
|
- if (notAllowedCount >= 2) return { level: "high", icon: ShieldCheck, color: "text-green-400", label: "High Privacy" };
|
|
|
- if (notAllowedCount === 1 || apiOnlyCount >= 2) return { level: "medium", icon: Shield, color: "text-yellow-500", label: "Medium Privacy" };
|
|
|
+ if (notAllowedCount === totalVisible) return { level: "maximum", icon: ShieldCheck, color: "text-green-500", label: "Maximum Privacy" };
|
|
|
+ if (notAllowedCount >= totalVisible - 1) return { level: "high", icon: ShieldCheck, color: "text-green-400", label: "High Privacy" };
|
|
|
+ if (notAllowedCount >= 1 || apiOnlyCount >= totalVisible - 1) return { level: "medium", icon: Shield, color: "text-yellow-500", label: "Medium Privacy" };
|
|
|
if (apiOnlyCount >= 1) return { level: "balanced", icon: Shield, color: "text-blue-500", label: "Balanced" };
|
|
|
return { level: "full", icon: ShieldAlert, color: "text-orange-500", label: "Full Sync" };
|
|
|
};
|
|
|
@@ -210,6 +229,21 @@ export function DataAccessSettings({
|
|
|
</AlertDescription>
|
|
|
</Alert>
|
|
|
|
|
|
+ {/* Notice when PII settings are hidden for GDPR compliance */}
|
|
|
+ {(HIDE_CUSTOMERS_ACCESS_SETTINGS || HIDE_ORDERS_ACCESS_SETTINGS) && (
|
|
|
+ <Alert className="bg-green-500/10 border-green-500/50">
|
|
|
+ <ShieldCheck className="h-4 w-4 text-green-400" />
|
|
|
+ <AlertDescription className="text-green-300 text-sm">
|
|
|
+ <strong>GDPR Protection Active:</strong> Personal data (
|
|
|
+ {[
|
|
|
+ HIDE_CUSTOMERS_ACCESS_SETTINGS && 'customer data',
|
|
|
+ HIDE_ORDERS_ACCESS_SETTINGS && 'order data'
|
|
|
+ ].filter(Boolean).join(' and ')}
|
|
|
+ ) is accessed directly from your store without local caching, ensuring maximum privacy compliance.
|
|
|
+ </AlertDescription>
|
|
|
+ </Alert>
|
|
|
+ )}
|
|
|
+
|
|
|
{/* Policy Settings */}
|
|
|
<div className="space-y-6">
|
|
|
{/* Products Access */}
|
|
|
@@ -226,33 +260,37 @@ export function DataAccessSettings({
|
|
|
{renderPolicyOptions('products', 'products_access_policy', false)}
|
|
|
</div>
|
|
|
|
|
|
- {/* Customers Access */}
|
|
|
- <div className="p-4 bg-slate-700/50 rounded-lg border border-slate-600">
|
|
|
- <div className="flex items-center gap-2 mb-2">
|
|
|
- <h4 className="text-white font-medium">Customer Data</h4>
|
|
|
- <Badge variant="outline" className="text-xs border-orange-500 text-orange-400">
|
|
|
- Personal Data (PII)
|
|
|
- </Badge>
|
|
|
+ {/* Customers Access - Hidden when VITE_HIDE_CUSTOMERS_ACCESS_SETTINGS is true */}
|
|
|
+ {!HIDE_CUSTOMERS_ACCESS_SETTINGS && (
|
|
|
+ <div className="p-4 bg-slate-700/50 rounded-lg border border-slate-600">
|
|
|
+ <div className="flex items-center gap-2 mb-2">
|
|
|
+ <h4 className="text-white font-medium">Customer Data</h4>
|
|
|
+ <Badge variant="outline" className="text-xs border-orange-500 text-orange-400">
|
|
|
+ Personal Data (PII)
|
|
|
+ </Badge>
|
|
|
+ </div>
|
|
|
+ <p className="text-sm text-slate-400 mb-3">
|
|
|
+ Customer information (names, emails, addresses, purchase history)
|
|
|
+ </p>
|
|
|
+ {renderPolicyOptions('customers', 'customers_access_policy', true)}
|
|
|
</div>
|
|
|
- <p className="text-sm text-slate-400 mb-3">
|
|
|
- Customer information (names, emails, addresses, purchase history)
|
|
|
- </p>
|
|
|
- {renderPolicyOptions('customers', 'customers_access_policy', true)}
|
|
|
- </div>
|
|
|
+ )}
|
|
|
|
|
|
- {/* Orders Access */}
|
|
|
- <div className="p-4 bg-slate-700/50 rounded-lg border border-slate-600">
|
|
|
- <div className="flex items-center gap-2 mb-2">
|
|
|
- <h4 className="text-white font-medium">Order Data</h4>
|
|
|
- <Badge variant="outline" className="text-xs border-orange-500 text-orange-400">
|
|
|
- Personal Data (PII)
|
|
|
- </Badge>
|
|
|
+ {/* Orders Access - Hidden when VITE_HIDE_ORDERS_ACCESS_SETTINGS is true */}
|
|
|
+ {!HIDE_ORDERS_ACCESS_SETTINGS && (
|
|
|
+ <div className="p-4 bg-slate-700/50 rounded-lg border border-slate-600">
|
|
|
+ <div className="flex items-center gap-2 mb-2">
|
|
|
+ <h4 className="text-white font-medium">Order Data</h4>
|
|
|
+ <Badge variant="outline" className="text-xs border-orange-500 text-orange-400">
|
|
|
+ Personal Data (PII)
|
|
|
+ </Badge>
|
|
|
+ </div>
|
|
|
+ <p className="text-sm text-slate-400 mb-3">
|
|
|
+ Order information (order details, amounts, customer info, shipping addresses)
|
|
|
+ </p>
|
|
|
+ {renderPolicyOptions('orders', 'orders_access_policy', true)}
|
|
|
</div>
|
|
|
- <p className="text-sm text-slate-400 mb-3">
|
|
|
- Order information (order details, amounts, customer info, shipping addresses)
|
|
|
- </p>
|
|
|
- {renderPolicyOptions('orders', 'orders_access_policy', true)}
|
|
|
- </div>
|
|
|
+ )}
|
|
|
</div>
|
|
|
|
|
|
{/* Action Buttons */}
|
|
|
@@ -293,7 +331,9 @@ export function DataAccessSettings({
|
|
|
</Alert>
|
|
|
)}
|
|
|
|
|
|
- {(policies.customers_access_policy === 'api_only' || policies.orders_access_policy === 'api_only') && (
|
|
|
+ {/* Only show api_only alert for visible settings */}
|
|
|
+ {((!HIDE_CUSTOMERS_ACCESS_SETTINGS && policies.customers_access_policy === 'api_only') ||
|
|
|
+ (!HIDE_ORDERS_ACCESS_SETTINGS && policies.orders_access_policy === 'api_only')) && (
|
|
|
<Alert className="bg-blue-500/10 border-blue-500/50">
|
|
|
<Info className="h-4 w-4 text-blue-400" />
|
|
|
<AlertDescription className="text-blue-300 text-sm">
|