Fix some issues
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React, { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Building2, Settings, Wrench, Thermometer, Activity, CheckCircle, AlertTriangle, Eye, Edit, FileText } from 'lucide-react';
|
||||
import { Building2, Settings, Wrench, Thermometer, Activity, CheckCircle, AlertTriangle, Eye, Edit, FileText, Mail } from 'lucide-react';
|
||||
import { EditViewModal, EditViewModalSection } from '../../ui/EditViewModal/EditViewModal';
|
||||
import { Equipment } from '../../../api/types/equipment';
|
||||
|
||||
@@ -101,7 +101,12 @@ export const EquipmentModal: React.FC<EquipmentModalProps> = ({
|
||||
[t('fields.specifications.depth')]: 'depth',
|
||||
[t('fields.current_temperature')]: 'temperature',
|
||||
[t('fields.target_temperature')]: 'targetTemperature',
|
||||
[t('fields.notes')]: 'notes'
|
||||
[t('fields.notes')]: 'notes',
|
||||
[t('fields.support_contact_email')]: 'support_contact_email',
|
||||
[t('fields.support_contact_phone')]: 'support_contact_phone',
|
||||
[t('fields.support_contact_company')]: 'support_contact_company',
|
||||
[t('fields.support_contact_contract_number')]: 'support_contact_contract_number',
|
||||
[t('fields.support_contact_response_time_sla')]: 'support_contact_response_time_sla'
|
||||
};
|
||||
|
||||
const propertyName = fieldLabelKeyMap[field.label];
|
||||
@@ -120,6 +125,13 @@ export const EquipmentModal: React.FC<EquipmentModalProps> = ({
|
||||
...newEquipment.specifications,
|
||||
[propertyName]: value
|
||||
};
|
||||
} else if (propertyName.startsWith('support_contact_')) {
|
||||
// Handle nested support_contact fields
|
||||
const contactField = propertyName.replace('support_contact_', '');
|
||||
newEquipment.support_contact = {
|
||||
...newEquipment.support_contact,
|
||||
[contactField]: value
|
||||
};
|
||||
} else {
|
||||
(newEquipment as any)[propertyName] = value;
|
||||
}
|
||||
@@ -262,6 +274,47 @@ export const EquipmentModal: React.FC<EquipmentModalProps> = ({
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: t('sections.support_contact'),
|
||||
icon: Mail,
|
||||
fields: [
|
||||
{
|
||||
label: t('fields.support_contact_email'),
|
||||
value: equipment.support_contact?.email || '',
|
||||
type: 'text',
|
||||
editable: true,
|
||||
placeholder: t('placeholders.support_contact_email')
|
||||
},
|
||||
{
|
||||
label: t('fields.support_contact_phone'),
|
||||
value: equipment.support_contact?.phone || '',
|
||||
type: 'text',
|
||||
editable: true,
|
||||
placeholder: t('placeholders.support_contact_phone')
|
||||
},
|
||||
{
|
||||
label: t('fields.support_contact_company'),
|
||||
value: equipment.support_contact?.company || '',
|
||||
type: 'text',
|
||||
editable: true,
|
||||
placeholder: t('placeholders.support_contact_company')
|
||||
},
|
||||
{
|
||||
label: t('fields.support_contact_contract_number'),
|
||||
value: equipment.support_contact?.contract_number || '',
|
||||
type: 'text',
|
||||
editable: true,
|
||||
placeholder: t('placeholders.support_contact_contract_number')
|
||||
},
|
||||
{
|
||||
label: t('fields.support_contact_response_time_sla'),
|
||||
value: equipment.support_contact?.response_time_sla || 0,
|
||||
type: 'number',
|
||||
editable: true,
|
||||
placeholder: '24'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: t('sections.specifications'),
|
||||
icon: Building2,
|
||||
|
||||
@@ -73,6 +73,16 @@ const EquipmentDetailsStep: React.FC<WizardStepProps> = ({ dataRef, onDataChange
|
||||
className="w-full px-3 py-2 border border-[var(--border-secondary)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] bg-[var(--bg-primary)] text-[var(--text-primary)]"
|
||||
/>
|
||||
</div>
|
||||
<div className="md:col-span-2">
|
||||
<label className="block text-sm font-medium text-[var(--text-secondary)] mb-2">{t('equipment.fields.supportContactEmail')}</label>
|
||||
<input
|
||||
type="email"
|
||||
value={data.support_contact?.email || ''}
|
||||
onChange={(e) => handleFieldChange('support_contact', { ...data.support_contact, email: e.target.value })}
|
||||
placeholder={t('equipment.fields.supportContactEmailPlaceholder')}
|
||||
className="w-full px-3 py-2 border border-[var(--border-secondary)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] bg-[var(--bg-primary)] text-[var(--text-primary)]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -184,9 +184,10 @@ export const SubscriptionPricingCards: React.FC<SubscriptionPricingCardsProps> =
|
||||
const topBenefits = getTopBenefits(tierKey, plan);
|
||||
|
||||
const CardWrapper = mode === 'landing' ? Link : 'div';
|
||||
const isCurrentPlan = mode === 'settings' && selectedPlan === tier;
|
||||
const cardProps = mode === 'landing'
|
||||
? { to: getRegisterUrl(tier) }
|
||||
: mode === 'selection' || mode === 'settings'
|
||||
: mode === 'selection' || (mode === 'settings' && !isCurrentPlan)
|
||||
? { onClick: () => handlePlanAction(tier, plan) }
|
||||
: {};
|
||||
|
||||
@@ -198,8 +199,10 @@ export const SubscriptionPricingCards: React.FC<SubscriptionPricingCardsProps> =
|
||||
{...cardProps}
|
||||
className={`
|
||||
relative rounded-2xl p-8 transition-all duration-300 block no-underline
|
||||
${mode === 'settings' || mode === 'selection' || mode === 'landing' ? 'cursor-pointer' : ''}
|
||||
${isSelected
|
||||
${(mode === 'settings' && !isCurrentPlan) || mode === 'selection' || mode === 'landing' ? 'cursor-pointer' : ''}
|
||||
${isCurrentPlan
|
||||
? 'bg-[var(--bg-secondary)] border-2 border-[var(--color-primary)] opacity-70 cursor-not-allowed'
|
||||
: isSelected
|
||||
? 'bg-gradient-to-br from-green-600 to-emerald-700 shadow-2xl ring-4 ring-green-400/60 scale-105 z-20 transform animate-[pulse_2s_ease-in-out_infinite]'
|
||||
: isPopular
|
||||
? 'bg-gradient-to-br from-blue-600 to-blue-800 shadow-xl ring-2 ring-blue-400 lg:scale-105 lg:z-10 hover:ring-4 hover:ring-blue-300 hover:shadow-2xl'
|
||||
@@ -207,8 +210,18 @@ export const SubscriptionPricingCards: React.FC<SubscriptionPricingCardsProps> =
|
||||
}
|
||||
`}
|
||||
>
|
||||
{/* Current Plan Badge */}
|
||||
{isCurrentPlan && (
|
||||
<div className="absolute -top-4 left-1/2 transform -translate-x-1/2 z-10">
|
||||
<div className="bg-[var(--color-primary)] text-white px-6 py-2 rounded-full text-sm font-bold shadow-xl flex items-center gap-1.5 border-2 border-[var(--color-primary)]">
|
||||
<Check className="w-4 h-4 stroke-[3]" />
|
||||
{t('ui.current_plan', 'Plan Actual')}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Selected Badge */}
|
||||
{isSelected && (
|
||||
{isSelected && !isCurrentPlan && (
|
||||
<div className="absolute -top-4 left-1/2 transform -translate-x-1/2 z-10">
|
||||
<div className="bg-white text-green-700 px-6 py-2 rounded-full text-sm font-bold shadow-xl flex items-center gap-1.5 border-2 border-green-400">
|
||||
<Check className="w-4 h-4 stroke-[3]" />
|
||||
@@ -218,7 +231,7 @@ export const SubscriptionPricingCards: React.FC<SubscriptionPricingCardsProps> =
|
||||
)}
|
||||
|
||||
{/* Popular Badge */}
|
||||
{isPopular && !isSelected && (
|
||||
{isPopular && !isSelected && !isCurrentPlan && (
|
||||
<div className="absolute -top-4 left-1/2 transform -translate-x-1/2">
|
||||
<div className="bg-gradient-to-r from-green-500 to-emerald-600 text-white px-6 py-2 rounded-full text-sm font-bold shadow-lg flex items-center gap-1">
|
||||
<Star className="w-4 h-4 fill-current" />
|
||||
@@ -229,10 +242,10 @@ export const SubscriptionPricingCards: React.FC<SubscriptionPricingCardsProps> =
|
||||
|
||||
{/* Plan Header */}
|
||||
<div className="mb-6">
|
||||
<h3 className={`text-2xl font-bold mb-2 ${(isPopular || isSelected) ? 'text-white' : 'text-[var(--text-primary)]'}`}>
|
||||
<h3 className={`text-2xl font-bold mb-2 ${(isPopular || isSelected) && !isCurrentPlan ? 'text-white' : 'text-[var(--text-primary)]'}`}>
|
||||
{t(`plans.${tier}.name`, plan.name)}
|
||||
</h3>
|
||||
<p className={`text-sm ${(isPopular || isSelected) ? 'text-white/90' : 'text-[var(--text-secondary)]'}`}>
|
||||
<p className={`text-sm ${(isPopular || isSelected) && !isCurrentPlan ? 'text-white/90' : 'text-[var(--text-secondary)]'}`}>
|
||||
{plan.tagline_key ? t(plan.tagline_key) : plan.tagline || ''}
|
||||
</p>
|
||||
</div>
|
||||
@@ -240,17 +253,17 @@ export const SubscriptionPricingCards: React.FC<SubscriptionPricingCardsProps> =
|
||||
{/* Price */}
|
||||
<div className="mb-6">
|
||||
<div className="flex items-baseline">
|
||||
<span className={`text-4xl font-bold ${(isPopular || isSelected) ? 'text-white' : 'text-[var(--text-primary)]'}`}>
|
||||
<span className={`text-4xl font-bold ${(isPopular || isSelected) && !isCurrentPlan ? 'text-white' : 'text-[var(--text-primary)]'}`}>
|
||||
{subscriptionService.formatPrice(price)}
|
||||
</span>
|
||||
<span className={`ml-2 text-lg ${(isPopular || isSelected) ? 'text-white/80' : 'text-[var(--text-secondary)]'}`}>
|
||||
<span className={`ml-2 text-lg ${(isPopular || isSelected) && !isCurrentPlan ? 'text-white/80' : 'text-[var(--text-secondary)]'}`}>
|
||||
/{billingCycle === 'monthly' ? t('ui.per_month') : t('ui.per_year')}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Trial Badge - Always Visible */}
|
||||
<div className={`mt-3 px-3 py-1.5 text-sm font-medium rounded-full inline-block ${
|
||||
(isPopular || isSelected) ? 'bg-white/20 text-white' : 'bg-green-500/10 text-green-600 dark:text-green-400'
|
||||
(isPopular || isSelected) && !isCurrentPlan ? 'bg-white/20 text-white' : 'bg-green-500/10 text-green-600 dark:text-green-400'
|
||||
}`}>
|
||||
{savings
|
||||
? t('ui.save_amount', { amount: subscriptionService.formatPrice(savings.savingsAmount) })
|
||||
@@ -264,9 +277,9 @@ export const SubscriptionPricingCards: React.FC<SubscriptionPricingCardsProps> =
|
||||
{/* Perfect For */}
|
||||
{plan.recommended_for_key && (
|
||||
<div className={`mb-6 text-center px-4 py-2 rounded-lg ${
|
||||
(isPopular || isSelected) ? 'bg-white/10' : 'bg-[var(--bg-primary)] border border-[var(--border-primary)]'
|
||||
(isPopular || isSelected) && !isCurrentPlan ? 'bg-white/10' : 'bg-[var(--bg-primary)] border border-[var(--border-primary)]'
|
||||
}`}>
|
||||
<p className={`text-sm font-medium ${(isPopular || isSelected) ? 'text-white/90' : 'text-[var(--text-secondary)]'}`}>
|
||||
<p className={`text-sm font-medium ${(isPopular || isSelected) && !isCurrentPlan ? 'text-white/90' : 'text-[var(--text-secondary)]'}`}>
|
||||
{t(plan.recommended_for_key)}
|
||||
</p>
|
||||
</div>
|
||||
@@ -275,12 +288,12 @@ export const SubscriptionPricingCards: React.FC<SubscriptionPricingCardsProps> =
|
||||
{/* Feature Inheritance Indicator */}
|
||||
{tier === SUBSCRIPTION_TIERS.PROFESSIONAL && (
|
||||
<div className={`mb-5 px-4 py-3 rounded-xl transition-all ${
|
||||
(isPopular || isSelected)
|
||||
(isPopular || isSelected) && !isCurrentPlan
|
||||
? 'bg-gradient-to-r from-white/20 to-white/10 border-2 border-white/40 shadow-lg'
|
||||
: 'bg-gradient-to-r from-blue-500/10 to-blue-600/5 border-2 border-blue-400/30 dark:from-blue-400/10 dark:to-blue-500/5 dark:border-blue-400/30'
|
||||
}`}>
|
||||
<p className={`text-xs font-bold uppercase tracking-wide text-center ${
|
||||
(isPopular || isSelected) ? 'text-white drop-shadow-sm' : 'text-blue-600 dark:text-blue-300'
|
||||
(isPopular || isSelected) && !isCurrentPlan ? 'text-white drop-shadow-sm' : 'text-blue-600 dark:text-blue-300'
|
||||
}`}>
|
||||
✓ {t('ui.feature_inheritance_professional')}
|
||||
</p>
|
||||
@@ -288,12 +301,12 @@ export const SubscriptionPricingCards: React.FC<SubscriptionPricingCardsProps> =
|
||||
)}
|
||||
{tier === SUBSCRIPTION_TIERS.ENTERPRISE && (
|
||||
<div className={`mb-5 px-4 py-3 rounded-xl transition-all ${
|
||||
(isPopular || isSelected)
|
||||
(isPopular || isSelected) && !isCurrentPlan
|
||||
? 'bg-gradient-to-r from-white/20 to-white/10 border-2 border-white/40 shadow-lg'
|
||||
: 'bg-gradient-to-r from-gray-700/20 to-gray-800/10 border-2 border-gray-600/40 dark:from-gray-600/20 dark:to-gray-700/10 dark:border-gray-500/40'
|
||||
}`}>
|
||||
<p className={`text-xs font-bold uppercase tracking-wide text-center ${
|
||||
(isPopular || isSelected) ? 'text-white drop-shadow-sm' : 'text-gray-700 dark:text-gray-300'
|
||||
(isPopular || isSelected) && !isCurrentPlan ? 'text-white drop-shadow-sm' : 'text-gray-700 dark:text-gray-300'
|
||||
}`}>
|
||||
✓ {t('ui.feature_inheritance_enterprise')}
|
||||
</p>
|
||||
@@ -307,34 +320,34 @@ export const SubscriptionPricingCards: React.FC<SubscriptionPricingCardsProps> =
|
||||
<div key={feature} className="flex items-start">
|
||||
<div className="flex-shrink-0 mt-1">
|
||||
<div className={`w-5 h-5 rounded-full flex items-center justify-center ${
|
||||
(isPopular || isSelected) ? 'bg-white' : 'bg-green-500'
|
||||
(isPopular || isSelected) && !isCurrentPlan ? 'bg-white' : 'bg-green-500'
|
||||
}`}>
|
||||
<Check className={`w-3 h-3 ${(isPopular || isSelected) ? 'text-blue-600' : 'text-white'}`} />
|
||||
<Check className={`w-3 h-3 ${(isPopular || isSelected) && !isCurrentPlan ? 'text-blue-600' : 'text-white'}`} />
|
||||
</div>
|
||||
</div>
|
||||
<span className={`ml-3 text-sm font-medium ${(isPopular || isSelected) ? 'text-white' : 'text-[var(--text-primary)]'}`}>
|
||||
<span className={`ml-3 text-sm font-medium ${(isPopular || isSelected) && !isCurrentPlan ? 'text-white' : 'text-[var(--text-primary)]'}`}>
|
||||
{formatFeatureName(feature)}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
|
||||
{/* Key Limits (Users, Locations, Products) */}
|
||||
<div className={`pt-4 mt-4 border-t space-y-2 ${(isPopular || isSelected) ? 'border-white/20' : 'border-[var(--border-primary)]'}`}>
|
||||
<div className={`pt-4 mt-4 border-t space-y-2 ${(isPopular || isSelected) && !isCurrentPlan ? 'border-white/20' : 'border-[var(--border-primary)]'}`}>
|
||||
<div className="flex items-center text-sm">
|
||||
<Users className={`w-4 h-4 mr-2 ${(isPopular || isSelected) ? 'text-white/80' : 'text-[var(--text-secondary)]'}`} />
|
||||
<span className={`font-medium ${(isPopular || isSelected) ? 'text-white' : 'text-[var(--text-primary)]'}`}>
|
||||
<Users className={`w-4 h-4 mr-2 ${(isPopular || isSelected) && !isCurrentPlan ? 'text-white/80' : 'text-[var(--text-secondary)]'}`} />
|
||||
<span className={`font-medium ${(isPopular || isSelected) && !isCurrentPlan ? 'text-white' : 'text-[var(--text-primary)]'}`}>
|
||||
{formatLimit(plan.limits.users, 'limits.users_unlimited')} {t('limits.users_label', 'usuarios')}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center text-sm">
|
||||
<MapPin className={`w-4 h-4 mr-2 ${(isPopular || isSelected) ? 'text-white/80' : 'text-[var(--text-secondary)]'}`} />
|
||||
<span className={`font-medium ${(isPopular || isSelected) ? 'text-white' : 'text-[var(--text-primary)]'}`}>
|
||||
<MapPin className={`w-4 h-4 mr-2 ${(isPopular || isSelected) && !isCurrentPlan ? 'text-white/80' : 'text-[var(--text-secondary)]'}`} />
|
||||
<span className={`font-medium ${(isPopular || isSelected) && !isCurrentPlan ? 'text-white' : 'text-[var(--text-primary)]'}`}>
|
||||
{formatLimit(plan.limits.locations, 'limits.locations_unlimited')} {t('limits.locations_label', 'ubicaciones')}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center text-sm">
|
||||
<Package className={`w-4 h-4 mr-2 ${(isPopular || isSelected) ? 'text-white/80' : 'text-[var(--text-secondary)]'}`} />
|
||||
<span className={`font-medium ${(isPopular || isSelected) ? 'text-white' : 'text-[var(--text-primary)]'}`}>
|
||||
<Package className={`w-4 h-4 mr-2 ${(isPopular || isSelected) && !isCurrentPlan ? 'text-white/80' : 'text-[var(--text-secondary)]'}`} />
|
||||
<span className={`font-medium ${(isPopular || isSelected) && !isCurrentPlan ? 'text-white' : 'text-[var(--text-primary)]'}`}>
|
||||
{formatLimit(plan.limits.products, 'limits.products_unlimited')} {t('limits.products_label', 'productos')}
|
||||
</span>
|
||||
</div>
|
||||
@@ -343,33 +356,45 @@ export const SubscriptionPricingCards: React.FC<SubscriptionPricingCardsProps> =
|
||||
|
||||
{/* CTA Button */}
|
||||
<Button
|
||||
disabled={isCurrentPlan}
|
||||
className={`w-full py-4 text-base font-semibold transition-all ${
|
||||
isSelected
|
||||
isCurrentPlan
|
||||
? 'bg-gray-400 text-gray-700 cursor-not-allowed opacity-60'
|
||||
: isSelected
|
||||
? 'bg-white text-green-700 hover:bg-gray-50 shadow-lg border-2 border-white/50'
|
||||
: isPopular
|
||||
? 'bg-white text-blue-600 hover:bg-gray-100'
|
||||
: 'bg-[var(--color-primary)] text-white hover:bg-[var(--color-primary-dark)]'
|
||||
}`}
|
||||
onClick={(e) => {
|
||||
if (mode === 'settings' || mode === 'selection') {
|
||||
if ((mode === 'settings' || mode === 'selection') && !isCurrentPlan) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
handlePlanAction(tier, plan);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{mode === 'selection' && isSelected
|
||||
{isCurrentPlan
|
||||
? (
|
||||
<span className="flex items-center justify-center gap-2">
|
||||
<Check className="w-5 h-5" />
|
||||
{t('ui.current_plan', 'Plan Actual')}
|
||||
</span>
|
||||
)
|
||||
: mode === 'selection' && isSelected
|
||||
? (
|
||||
<span className="flex items-center justify-center gap-2">
|
||||
<Check className="w-5 h-5" />
|
||||
{t('ui.plan_selected', 'Plan Seleccionado')}
|
||||
</span>
|
||||
)
|
||||
: mode === 'settings'
|
||||
? t('ui.change_subscription', 'Cambiar Suscripción')
|
||||
: t('ui.start_free_trial')}
|
||||
</Button>
|
||||
|
||||
{/* Footer */}
|
||||
<p className={`text-xs text-center mt-3 ${(isPopular || isSelected) ? 'text-white/80' : 'text-[var(--text-secondary)]'}`}>
|
||||
<p className={`text-xs text-center mt-3 ${(isPopular || isSelected) && !isCurrentPlan ? 'text-white/80' : 'text-[var(--text-secondary)]'}`}>
|
||||
{showPilotBanner
|
||||
? t('ui.free_trial_footer', { months: pilotTrialMonths })
|
||||
: t('ui.free_trial_footer', { months: 0 })
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import React, { createContext, useContext, useEffect, useRef, useState, ReactNode, useCallback } from 'react';
|
||||
import { useAuthStore } from '../stores/auth.store';
|
||||
import { useCurrentTenant } from '../stores/tenant.store';
|
||||
import { showToast } from '../utils/toast';
|
||||
import i18n from '../i18n';
|
||||
import { getTenantCurrencySymbol } from '../hooks/useTenantCurrency';
|
||||
// Toast notifications disabled - imports commented out
|
||||
// import { showToast } from '../utils/toast';
|
||||
// import i18n from '../i18n';
|
||||
// import { getTenantCurrencySymbol } from '../hooks/useTenantCurrency';
|
||||
|
||||
interface SSEEvent {
|
||||
type: string;
|
||||
@@ -164,6 +165,9 @@ export const SSEProvider: React.FC<SSEProviderProps> = ({ children }) => {
|
||||
|
||||
setLastEvent(sseEvent);
|
||||
|
||||
// Toast notifications disabled for SSE alerts
|
||||
// Code below kept for potential future re-enablement
|
||||
/*
|
||||
// Determine toast type based on enriched priority_level and type_class
|
||||
let toastType: 'info' | 'success' | 'warning' | 'error' = 'info';
|
||||
|
||||
@@ -217,6 +221,7 @@ export const SSEProvider: React.FC<SSEProviderProps> = ({ children }) => {
|
||||
}
|
||||
|
||||
showToast[toastType](message, { title, duration });
|
||||
*/
|
||||
|
||||
// Trigger listeners with enriched alert data
|
||||
// Wrap in queueMicrotask to prevent setState during render warnings
|
||||
@@ -264,6 +269,9 @@ export const SSEProvider: React.FC<SSEProviderProps> = ({ children }) => {
|
||||
|
||||
setLastEvent(sseEvent);
|
||||
|
||||
// Toast notifications disabled for SSE notifications
|
||||
// Code below kept for potential future re-enablement
|
||||
/*
|
||||
// Determine toast type based on notification priority or type
|
||||
let toastType: 'info' | 'success' | 'warning' | 'error' = 'info';
|
||||
|
||||
@@ -341,6 +349,7 @@ export const SSEProvider: React.FC<SSEProviderProps> = ({ children }) => {
|
||||
const duration = data.priority_level === 'critical' ? 0 : 5000;
|
||||
|
||||
showToast[toastType](message, { title, duration });
|
||||
*/
|
||||
|
||||
// Trigger listeners with notification data
|
||||
// Wrap in queueMicrotask to prevent setState during render warnings
|
||||
@@ -383,6 +392,9 @@ export const SSEProvider: React.FC<SSEProviderProps> = ({ children }) => {
|
||||
|
||||
setLastEvent(sseEvent);
|
||||
|
||||
// Toast notifications disabled for SSE recommendations
|
||||
// Code below kept for potential future re-enablement
|
||||
/*
|
||||
// Recommendations are typically positive insights
|
||||
let toastType: 'info' | 'success' | 'warning' | 'error' = 'info';
|
||||
|
||||
@@ -458,6 +470,7 @@ export const SSEProvider: React.FC<SSEProviderProps> = ({ children }) => {
|
||||
const duration = 5000; // Recommendations are typically informational
|
||||
|
||||
showToast[toastType](message, { title, duration });
|
||||
*/
|
||||
|
||||
// Trigger listeners with recommendation data
|
||||
// Wrap in queueMicrotask to prevent setState during render warnings
|
||||
|
||||
@@ -5,18 +5,35 @@
|
||||
import { useMemo } from 'react';
|
||||
import { RouteConfig } from '../router/routes.config';
|
||||
import { useSubscription } from '../api/hooks/subscription';
|
||||
import { useCurrentTenant } from '../stores';
|
||||
import { usePremises } from '../api/hooks/usePremises';
|
||||
|
||||
export const useSubscriptionAwareRoutes = (routes: RouteConfig[]) => {
|
||||
const { subscriptionInfo, canAccessAnalytics } = useSubscription();
|
||||
const currentTenant = useCurrentTenant();
|
||||
|
||||
// Check if tenant has child tenants (only for enterprise tier)
|
||||
const isEnterprise = subscriptionInfo.plan === 'enterprise';
|
||||
const { data: childTenants = [] } = usePremises(
|
||||
currentTenant?.id || '',
|
||||
{},
|
||||
{ enabled: isEnterprise && !!currentTenant?.id }
|
||||
);
|
||||
const hasChildTenants = childTenants.length > 0;
|
||||
|
||||
const filteredRoutes = useMemo(() => {
|
||||
const filterRoutesBySubscription = (routeList: RouteConfig[]): RouteConfig[] => {
|
||||
return routeList.reduce((filtered, route) => {
|
||||
// Check if route requires subscription features
|
||||
if (route.requiredSubscriptionFeature) {
|
||||
// Special case for multi_tenant_management which requires enterprise AND child tenants
|
||||
if (route.requiredSubscriptionFeature === 'multi_tenant_management') {
|
||||
if (!isEnterprise || !hasChildTenants) {
|
||||
return filtered; // Skip this route if not enterprise or no child tenants
|
||||
}
|
||||
}
|
||||
// Special case for distribution feature which requires enterprise
|
||||
if (route.requiredSubscriptionFeature === 'distribution') {
|
||||
const isEnterprise = subscriptionInfo.plan === 'enterprise';
|
||||
else if (route.requiredSubscriptionFeature === 'distribution') {
|
||||
if (!isEnterprise) {
|
||||
return filtered; // Skip this route
|
||||
}
|
||||
@@ -70,7 +87,7 @@ export const useSubscriptionAwareRoutes = (routes: RouteConfig[]) => {
|
||||
}
|
||||
|
||||
return filterRoutesBySubscription(routes);
|
||||
}, [routes, subscriptionInfo, canAccessAnalytics]);
|
||||
}, [routes, subscriptionInfo, canAccessAnalytics, isEnterprise, hasChildTenants]);
|
||||
|
||||
return {
|
||||
filteredRoutes,
|
||||
|
||||
@@ -53,6 +53,11 @@
|
||||
"severity": "Severity",
|
||||
"photos": "Photos",
|
||||
"estimated_impact": "Production Impact",
|
||||
"support_contact_email": "Support Contact Email",
|
||||
"support_contact_phone": "Support Contact Phone",
|
||||
"support_contact_company": "Support Company",
|
||||
"support_contact_contract_number": "Contract Number",
|
||||
"support_contact_response_time_sla": "Response Time SLA (hours)",
|
||||
"specifications": {
|
||||
"power": "Power",
|
||||
"capacity": "Capacity",
|
||||
@@ -96,6 +101,7 @@
|
||||
"performance": "Performance",
|
||||
"maintenance": "Maintenance Information",
|
||||
"maintenance_info": "Maintenance Information",
|
||||
"support_contact": "Support Contact Information",
|
||||
"specifications": "Specifications",
|
||||
"temperature_monitoring": "Temperature Monitoring",
|
||||
"notes": "Notes",
|
||||
@@ -111,7 +117,11 @@
|
||||
"notes": "Additional notes and observations",
|
||||
"technician": "Assigned technician name",
|
||||
"parts_needed": "List of required parts and materials",
|
||||
"maintenance_description": "Description of the maintenance work to be performed"
|
||||
"maintenance_description": "Description of the maintenance work to be performed",
|
||||
"support_contact_email": "support@company.com",
|
||||
"support_contact_phone": "+1-800-555-1234",
|
||||
"support_contact_company": "Support company name",
|
||||
"support_contact_contract_number": "CONTRACT-2024-001"
|
||||
},
|
||||
"descriptions": {
|
||||
"equipment_efficiency": "Current equipment efficiency percentage",
|
||||
|
||||
@@ -142,6 +142,8 @@
|
||||
"choose_starter": "Choose Starter",
|
||||
"choose_professional": "Choose Professional",
|
||||
"choose_enterprise": "Choose Enterprise",
|
||||
"change_subscription": "Change Subscription",
|
||||
"current_plan": "Current Plan",
|
||||
"compare_plans": "Compare Plans",
|
||||
"detailed_feature_comparison": "Detailed feature comparison across all subscription tiers",
|
||||
"payback_period": "Pays for itself in {days} days",
|
||||
|
||||
@@ -1104,7 +1104,9 @@
|
||||
"location": "Location",
|
||||
"locationPlaceholder": "E.g., Main kitchen",
|
||||
"status": "Status",
|
||||
"installDate": "Install Date"
|
||||
"installDate": "Install Date",
|
||||
"supportContactEmail": "Support Contact Email",
|
||||
"supportContactEmailPlaceholder": "support@company.com"
|
||||
},
|
||||
"types": {
|
||||
"oven": "Oven",
|
||||
|
||||
@@ -53,6 +53,11 @@
|
||||
"severity": "Gravedad",
|
||||
"photos": "Fotos",
|
||||
"estimated_impact": "Impacto en la Producción",
|
||||
"support_contact_email": "Email de Contacto de Soporte",
|
||||
"support_contact_phone": "Teléfono de Contacto de Soporte",
|
||||
"support_contact_company": "Empresa de Soporte",
|
||||
"support_contact_contract_number": "Número de Contrato",
|
||||
"support_contact_response_time_sla": "SLA Tiempo de Respuesta (horas)",
|
||||
"specifications": {
|
||||
"power": "Potencia",
|
||||
"capacity": "Capacidad",
|
||||
@@ -96,6 +101,7 @@
|
||||
"performance": "Rendimiento",
|
||||
"maintenance": "Información de Mantenimiento",
|
||||
"maintenance_info": "Información de Mantenimiento",
|
||||
"support_contact": "Información de Contacto de Soporte",
|
||||
"specifications": "Especificaciones",
|
||||
"temperature_monitoring": "Monitoreo de Temperatura",
|
||||
"notes": "Notas",
|
||||
@@ -111,7 +117,11 @@
|
||||
"notes": "Notas y observaciones adicionales",
|
||||
"technician": "Nombre del técnico asignado",
|
||||
"parts_needed": "Lista de repuestos y materiales necesarios",
|
||||
"maintenance_description": "Descripción del trabajo a realizar"
|
||||
"maintenance_description": "Descripción del trabajo a realizar",
|
||||
"support_contact_email": "soporte@empresa.com",
|
||||
"support_contact_phone": "+34-900-555-1234",
|
||||
"support_contact_company": "Nombre de la empresa de soporte",
|
||||
"support_contact_contract_number": "CONTRATO-2024-001"
|
||||
},
|
||||
"descriptions": {
|
||||
"equipment_efficiency": "Porcentaje de eficiencia actual de los equipos",
|
||||
|
||||
@@ -142,6 +142,8 @@
|
||||
"choose_starter": "Elegir Starter",
|
||||
"choose_professional": "Elegir Professional",
|
||||
"choose_enterprise": "Elegir Enterprise",
|
||||
"change_subscription": "Cambiar Suscripción",
|
||||
"current_plan": "Plan Actual",
|
||||
"compare_plans": "Comparar Planes",
|
||||
"detailed_feature_comparison": "Comparación detallada de características entre todos los niveles de suscripción",
|
||||
"payback_period": "Se paga solo en {days} días",
|
||||
@@ -149,6 +151,12 @@
|
||||
"calculate_savings": "Calcular Mis Ahorros",
|
||||
"feature_inheritance_starter": "Incluye todas las características esenciales",
|
||||
"feature_inheritance_professional": "Todas las características de Starter +",
|
||||
"feature_inheritance_enterprise": "Todas las características de Professional +"
|
||||
"feature_inheritance_enterprise": "Todas las características de Professional +",
|
||||
"update_payment_method": "Actualizar Método de Pago",
|
||||
"payment_method_updated": "Método de pago actualizado correctamente",
|
||||
"payment_details": "Detalles de Pago",
|
||||
"payment_info_secure": "Tu información de pago está protegida con encriptación de extremo a extremo",
|
||||
"updating_payment": "Actualizando...",
|
||||
"cancel": "Cancelar"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1129,7 +1129,9 @@
|
||||
"locationPlaceholder": "Ej: Cocina principal",
|
||||
"status": "Estado",
|
||||
"purchaseDate": "Fecha de Compra",
|
||||
"installDate": "Fecha de Instalación"
|
||||
"installDate": "Fecha de Instalación",
|
||||
"supportContactEmail": "Email de Contacto de Soporte",
|
||||
"supportContactEmailPlaceholder": "soporte@empresa.com"
|
||||
},
|
||||
"types": {
|
||||
"oven": "Horno",
|
||||
|
||||
@@ -53,6 +53,11 @@
|
||||
"severity": "Larritasuna",
|
||||
"photos": "Argazkiak",
|
||||
"estimated_impact": "Ekoizpenaren gaineko eragina",
|
||||
"support_contact_email": "Laguntza kontaktuaren emaila",
|
||||
"support_contact_phone": "Laguntza kontaktuaren telefonoa",
|
||||
"support_contact_company": "Laguntza enpresa",
|
||||
"support_contact_contract_number": "Kontratu zenbakia",
|
||||
"support_contact_response_time_sla": "Erantzun-denboraren SLA (orduak)",
|
||||
"specifications": {
|
||||
"power": "Potentzia",
|
||||
"capacity": "Edukiera",
|
||||
@@ -93,6 +98,7 @@
|
||||
"performance": "Errendimendua",
|
||||
"maintenance": "Mantentze informazioa",
|
||||
"maintenance_info": "Mantentze informazioa",
|
||||
"support_contact": "Laguntza kontaktuaren informazioa",
|
||||
"specifications": "Zehaztapenak",
|
||||
"temperature_monitoring": "Tenperatura-jarraipena",
|
||||
"notes": "Oharrak",
|
||||
@@ -108,7 +114,11 @@
|
||||
"notes": "Ohar eta behaketa gehigarriak",
|
||||
"technician": "Esleitutako teknikariaren izena",
|
||||
"parts_needed": "Beharrezko piezen eta materialen zerrenda",
|
||||
"maintenance_description": "Egingo den lanaren deskribapena"
|
||||
"maintenance_description": "Egingo den lanaren deskribapena",
|
||||
"support_contact_email": "laguntza@enpresa.eus",
|
||||
"support_contact_phone": "+34-900-555-1234",
|
||||
"support_contact_company": "Laguntza enpresaren izena",
|
||||
"support_contact_contract_number": "KONTRATUA-2024-001"
|
||||
},
|
||||
"descriptions": {
|
||||
"equipment_efficiency": "Uneko makinaren eraginkortasun-ehunekoa",
|
||||
|
||||
@@ -140,6 +140,8 @@
|
||||
"choose_starter": "Aukeratu Starter",
|
||||
"choose_professional": "Aukeratu Professional",
|
||||
"choose_enterprise": "Aukeratu Enterprise",
|
||||
"change_subscription": "Aldatu Harpidetza",
|
||||
"current_plan": "Oraingo Plana",
|
||||
"compare_plans": "Konparatu Planak",
|
||||
"detailed_feature_comparison": "Ezaugarrien konparazio zehatza harpidetza maila guztien artean",
|
||||
"payback_period": "Bere burua ordaintzen du {days} egunetan",
|
||||
|
||||
@@ -563,6 +563,42 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"equipment": {
|
||||
"title": "Gehitu Ekipamendua",
|
||||
"equipmentDetails": "Ekipamenduaren Xehetasunak",
|
||||
"subtitle": "Okindegiaren Ekipamendua",
|
||||
"fields": {
|
||||
"name": "Ekipamenduaren Izena",
|
||||
"namePlaceholder": "Adib: Ekoizpen Labe Nagusia",
|
||||
"type": "Ekipamendu Mota",
|
||||
"model": "Modeloa",
|
||||
"modelPlaceholder": "Adib: Rational SCC 101",
|
||||
"location": "Kokapena",
|
||||
"locationPlaceholder": "Adib: Sukalde nagusia",
|
||||
"status": "Egoera",
|
||||
"installDate": "Instalazio Data",
|
||||
"supportContactEmail": "Laguntza Kontaktuaren Emaila",
|
||||
"supportContactEmailPlaceholder": "laguntza@enpresa.eus"
|
||||
},
|
||||
"types": {
|
||||
"oven": "Labea",
|
||||
"mixer": "Nahasmaila",
|
||||
"proofer": "Fermentatzailea",
|
||||
"freezer": "Izozkailua",
|
||||
"packaging": "Ontziratzailea",
|
||||
"other": "Bestelakoa"
|
||||
},
|
||||
"steps": {
|
||||
"equipmentDetails": "Ekipamenduaren Xehetasunak",
|
||||
"equipmentDetailsDescription": "Mota, modeloa, kokapena"
|
||||
},
|
||||
"messages": {
|
||||
"errorGettingTenant": "Ezin izan da tenant informazioa lortu",
|
||||
"noBrand": "Markarik gabe",
|
||||
"successCreate": "Ekipamendua ondo sortu da",
|
||||
"errorCreate": "Errorea ekipamendua sortzean"
|
||||
}
|
||||
},
|
||||
"itemTypeSelector": {
|
||||
"title": "Hautatu Mota",
|
||||
"description": "Aukeratu zer gehitu nahi duzun",
|
||||
|
||||
Reference in New Issue
Block a user