Improve UI and traslations
This commit is contained in:
@@ -654,7 +654,7 @@ export const InventorySetupStep: React.FC<SetupStepProps> = ({ onUpdate, onCompl
|
||||
</span>
|
||||
)}
|
||||
{stock.batch_number && (
|
||||
<span className="text-[var(--text-tertiary)]">Batch: {stock.batch_number}</span>
|
||||
<span className="text-[var(--text-tertiary)]">{t('setup_wizard:inventory.batch_label', 'Batch')}: {stock.batch_number}</span>
|
||||
)}
|
||||
</div>
|
||||
<button
|
||||
|
||||
@@ -345,7 +345,7 @@ export const RecipesSetupStep: React.FC<SetupStepProps> = ({ onUpdate, onComplet
|
||||
{selectedTemplate?.id === template.id && (
|
||||
<div className="bg-[var(--bg-primary)] rounded p-3 mb-3 space-y-2 text-xs">
|
||||
<div>
|
||||
<p className="font-medium text-[var(--text-primary)] mb-1">Ingredients:</p>
|
||||
<p className="font-medium text-[var(--text-primary)] mb-1">{t('setup_wizard:recipes.template_ingredients', 'Ingredients:')}</p>
|
||||
<ul className="list-disc list-inside space-y-0.5 text-[var(--text-secondary)]">
|
||||
{template.ingredients.map((ing, idx) => (
|
||||
<li key={idx}>
|
||||
@@ -356,13 +356,13 @@ export const RecipesSetupStep: React.FC<SetupStepProps> = ({ onUpdate, onComplet
|
||||
</div>
|
||||
{template.instructions && (
|
||||
<div>
|
||||
<p className="font-medium text-[var(--text-primary)] mb-1">Instructions:</p>
|
||||
<p className="font-medium text-[var(--text-primary)] mb-1">{t('setup_wizard:recipes.template_instructions', 'Instructions:')}</p>
|
||||
<p className="text-[var(--text-secondary)] whitespace-pre-line">{template.instructions}</p>
|
||||
</div>
|
||||
)}
|
||||
{template.tips && template.tips.length > 0 && (
|
||||
<div>
|
||||
<p className="font-medium text-[var(--text-primary)] mb-1">Tips:</p>
|
||||
<p className="font-medium text-[var(--text-primary)] mb-1">{t('setup_wizard:recipes.template_tips', 'Tips:')}</p>
|
||||
<ul className="list-disc list-inside space-y-0.5 text-[var(--text-secondary)]">
|
||||
{template.tips.map((tip, idx) => (
|
||||
<li key={idx}>{tip}</li>
|
||||
|
||||
@@ -1,23 +1,69 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { SetupStepProps } from '../types';
|
||||
import { useTeamMembers, useAddTeamMemberWithUserCreation, useRemoveTeamMember } from '../../../../api/hooks/tenant';
|
||||
import { useCurrentTenant } from '../../../../stores/tenant.store';
|
||||
import { useAuthUser } from '../../../../stores/auth.store';
|
||||
import type { TenantMemberResponse } from '../../../../api/types/tenant';
|
||||
|
||||
interface TeamMember {
|
||||
id: string;
|
||||
name: string;
|
||||
email: string;
|
||||
role: string;
|
||||
}
|
||||
// Map frontend roles to backend roles
|
||||
const mapRoleToBackend = (frontendRole: string): 'admin' | 'member' | 'viewer' => {
|
||||
switch (frontendRole) {
|
||||
case 'admin':
|
||||
return 'admin';
|
||||
case 'manager':
|
||||
return 'admin'; // Managers get admin permissions
|
||||
case 'baker':
|
||||
return 'member';
|
||||
case 'cashier':
|
||||
return 'member';
|
||||
default:
|
||||
return 'member';
|
||||
}
|
||||
};
|
||||
|
||||
// Map backend roles to frontend display roles
|
||||
const mapRoleFromBackend = (backendRole: string): string => {
|
||||
switch (backendRole) {
|
||||
case 'owner':
|
||||
return 'admin';
|
||||
case 'admin':
|
||||
return 'admin';
|
||||
case 'member':
|
||||
return 'baker';
|
||||
case 'viewer':
|
||||
return 'cashier';
|
||||
default:
|
||||
return 'baker';
|
||||
}
|
||||
};
|
||||
|
||||
export const TeamSetupStep: React.FC<SetupStepProps> = ({ onUpdate, onComplete, onPrevious, canContinue }) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
// Local state for team members (will be sent to backend when API is available)
|
||||
const [teamMembers, setTeamMembers] = useState<TeamMember[]>([]);
|
||||
// Get tenant ID
|
||||
const currentTenant = useCurrentTenant();
|
||||
const user = useAuthUser();
|
||||
const tenantId = currentTenant?.id || user?.tenant_id || '';
|
||||
|
||||
// Fetch existing team members
|
||||
const { data: teamMembersData, isLoading } = useTeamMembers(tenantId, true, { enabled: !!tenantId });
|
||||
// Filter out the current user (owner) from the list
|
||||
const teamMembers: TenantMemberResponse[] = (teamMembersData || []).filter(
|
||||
(member) => member.user_id !== user?.id
|
||||
);
|
||||
|
||||
// Mutations
|
||||
const addMemberMutation = useAddTeamMemberWithUserCreation();
|
||||
const removeMemberMutation = useRemoveTeamMember();
|
||||
|
||||
const [isAdding, setIsAdding] = useState(false);
|
||||
const [formData, setFormData] = useState({
|
||||
name: '',
|
||||
email: '',
|
||||
password: '',
|
||||
confirmPassword: '',
|
||||
phone: '',
|
||||
role: 'baker',
|
||||
});
|
||||
const [errors, setErrors] = useState<Record<string, string>>({});
|
||||
@@ -26,7 +72,7 @@ export const TeamSetupStep: React.FC<SetupStepProps> = ({ onUpdate, onComplete,
|
||||
useEffect(() => {
|
||||
onUpdate?.({
|
||||
itemCount: teamMembers.length,
|
||||
canContinue: teamMembers.length > 0,
|
||||
canContinue: true, // Team step is optional - user can skip
|
||||
});
|
||||
}, [teamMembers.length, onUpdate]);
|
||||
|
||||
@@ -45,46 +91,83 @@ export const TeamSetupStep: React.FC<SetupStepProps> = ({ onUpdate, onComplete,
|
||||
}
|
||||
|
||||
// Check for duplicate email
|
||||
if (teamMembers.some((member) => member.email.toLowerCase() === formData.email.toLowerCase())) {
|
||||
if (teamMembers.some((member) => member.user_email?.toLowerCase() === formData.email.toLowerCase())) {
|
||||
newErrors.email = t('setup_wizard:team.errors.email_duplicate', 'This email is already added');
|
||||
}
|
||||
|
||||
// Password validation
|
||||
if (!formData.password.trim()) {
|
||||
newErrors.password = t('setup_wizard:team.errors.password_required', 'Password is required');
|
||||
} else if (formData.password.length < 8) {
|
||||
newErrors.password = t('setup_wizard:team.errors.password_min_length', 'Password must be at least 8 characters');
|
||||
}
|
||||
|
||||
// Confirm password validation
|
||||
if (!formData.confirmPassword.trim()) {
|
||||
newErrors.confirmPassword = t('setup_wizard:team.errors.confirm_password_required', 'Please confirm the password');
|
||||
} else if (formData.password !== formData.confirmPassword) {
|
||||
newErrors.confirmPassword = t('setup_wizard:team.errors.passwords_mismatch', 'Passwords do not match');
|
||||
}
|
||||
|
||||
setErrors(newErrors);
|
||||
return Object.keys(newErrors).length === 0;
|
||||
};
|
||||
|
||||
// Form handlers
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
if (!validateForm()) return;
|
||||
if (!tenantId) {
|
||||
setErrors({ form: t('common:error_no_tenant', 'No tenant found') });
|
||||
return;
|
||||
}
|
||||
|
||||
// Add team member to local state
|
||||
const newMember: TeamMember = {
|
||||
id: Date.now().toString(),
|
||||
name: formData.name,
|
||||
email: formData.email,
|
||||
role: formData.role,
|
||||
};
|
||||
try {
|
||||
await addMemberMutation.mutateAsync({
|
||||
tenantId,
|
||||
memberData: {
|
||||
create_user: true,
|
||||
email: formData.email,
|
||||
full_name: formData.name,
|
||||
password: formData.password,
|
||||
phone: formData.phone || undefined,
|
||||
role: mapRoleToBackend(formData.role),
|
||||
language: 'es',
|
||||
timezone: 'Europe/Madrid',
|
||||
},
|
||||
});
|
||||
|
||||
setTeamMembers([...teamMembers, newMember]);
|
||||
|
||||
// Reset form
|
||||
resetForm();
|
||||
// Reset form
|
||||
resetForm();
|
||||
} catch (error: any) {
|
||||
console.error('Error adding team member:', error);
|
||||
const errorMessage = error?.message || t('common:error_saving', 'Error saving. Please try again.');
|
||||
setErrors({ form: errorMessage });
|
||||
}
|
||||
};
|
||||
|
||||
const resetForm = () => {
|
||||
setFormData({
|
||||
name: '',
|
||||
email: '',
|
||||
password: '',
|
||||
confirmPassword: '',
|
||||
phone: '',
|
||||
role: 'baker',
|
||||
});
|
||||
setErrors({});
|
||||
setIsAdding(false);
|
||||
};
|
||||
|
||||
const handleRemove = (memberId: string) => {
|
||||
setTeamMembers(teamMembers.filter((member) => member.id !== memberId));
|
||||
const handleRemove = async (memberUserId: string) => {
|
||||
if (!tenantId) return;
|
||||
|
||||
try {
|
||||
await removeMemberMutation.mutateAsync({ tenantId, memberUserId });
|
||||
} catch (error) {
|
||||
console.error('Error removing team member:', error);
|
||||
}
|
||||
};
|
||||
|
||||
const roleOptions = [
|
||||
@@ -94,6 +177,12 @@ export const TeamSetupStep: React.FC<SetupStepProps> = ({ onUpdate, onComplete,
|
||||
{ value: 'cashier', label: t('team:role.cashier', 'Cashier'), icon: '💰', description: t('team:role.cashier_desc', 'Sales and POS') },
|
||||
];
|
||||
|
||||
// Get display role for a member
|
||||
const getMemberDisplayRole = (member: TenantMemberResponse) => {
|
||||
const displayRole = mapRoleFromBackend(member.role);
|
||||
return roleOptions.find(opt => opt.value === displayRole) || roleOptions[2]; // Default to baker
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* Why This Matters */}
|
||||
@@ -143,6 +232,16 @@ export const TeamSetupStep: React.FC<SetupStepProps> = ({ onUpdate, onComplete,
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Loading state */}
|
||||
{isLoading && (
|
||||
<div className="text-center py-4">
|
||||
<svg className="animate-spin h-6 w-6 text-[var(--color-primary)] mx-auto" fill="none" viewBox="0 0 24 24">
|
||||
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
|
||||
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" />
|
||||
</svg>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Team members list */}
|
||||
{teamMembers.length > 0 && (
|
||||
<div className="space-y-2">
|
||||
@@ -150,43 +249,54 @@ export const TeamSetupStep: React.FC<SetupStepProps> = ({ onUpdate, onComplete,
|
||||
{t('setup_wizard:team.your_team', 'Your Team Members')}
|
||||
</h4>
|
||||
<div className="space-y-2 max-h-80 overflow-y-auto">
|
||||
{teamMembers.map((member) => (
|
||||
<div
|
||||
key={member.id}
|
||||
className="flex items-center justify-between p-3 bg-[var(--bg-secondary)] border border-[var(--border-secondary)] rounded-lg hover:border-[var(--border-primary)] transition-colors"
|
||||
>
|
||||
<div className="flex-1 min-w-0 flex items-center gap-3">
|
||||
<div className="w-10 h-10 bg-[var(--color-primary)]/10 rounded-full flex items-center justify-center flex-shrink-0">
|
||||
<span className="text-lg">
|
||||
{roleOptions.find(opt => opt.value === member.role)?.icon || '👤'}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2">
|
||||
<h5 className="font-medium text-[var(--text-primary)] truncate">{member.name}</h5>
|
||||
<span className="text-xs px-2 py-0.5 bg-[var(--bg-primary)] rounded-full text-[var(--text-secondary)]">
|
||||
{roleOptions.find(opt => opt.value === member.role)?.label || member.role}
|
||||
{teamMembers.map((member) => {
|
||||
const displayRole = getMemberDisplayRole(member);
|
||||
return (
|
||||
<div
|
||||
key={member.id}
|
||||
className="flex items-center justify-between p-3 bg-[var(--bg-secondary)] border border-[var(--border-secondary)] rounded-lg hover:border-[var(--border-primary)] transition-colors"
|
||||
>
|
||||
<div className="flex-1 min-w-0 flex items-center gap-3">
|
||||
<div className="w-10 h-10 bg-[var(--color-primary)]/10 rounded-full flex items-center justify-center flex-shrink-0">
|
||||
<span className="text-lg">
|
||||
{displayRole.icon}
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-xs text-[var(--text-secondary)] truncate">{member.email}</p>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2">
|
||||
<h5 className="font-medium text-[var(--text-primary)] truncate">{member.user_full_name || member.user_email || 'Unknown'}</h5>
|
||||
<span className="text-xs px-2 py-0.5 bg-[var(--bg-primary)] rounded-full text-[var(--text-secondary)]">
|
||||
{displayRole.label}
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-xs text-[var(--text-secondary)] truncate">{member.user_email || ''}</p>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleRemove(member.user_id)}
|
||||
disabled={removeMemberMutation.isPending}
|
||||
className="p-1.5 text-[var(--text-secondary)] hover:text-[var(--color-error)] hover:bg-[var(--color-error)]/10 rounded transition-colors ml-2 disabled:opacity-50"
|
||||
aria-label={t('common:remove', 'Remove')}
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleRemove(member.id)}
|
||||
className="p-1.5 text-[var(--text-secondary)] hover:text-[var(--color-error)] hover:bg-[var(--color-error)]/10 rounded transition-colors ml-2"
|
||||
aria-label={t('common:remove', 'Remove')}
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Form-level error */}
|
||||
{errors.form && (
|
||||
<div className="p-3 bg-[var(--color-error)]/10 border border-[var(--color-error)]/20 rounded-lg">
|
||||
<p className="text-sm text-[var(--color-error)]">{errors.form}</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Add form */}
|
||||
{isAdding ? (
|
||||
<form onSubmit={handleSubmit} className="space-y-4 p-4 border-2 border-[var(--color-primary)] rounded-lg bg-[var(--bg-secondary)]">
|
||||
@@ -220,7 +330,7 @@ export const TeamSetupStep: React.FC<SetupStepProps> = ({ onUpdate, onComplete,
|
||||
{errors.name && <p className="mt-1 text-xs text-[var(--color-error)]">{errors.name}</p>}
|
||||
</div>
|
||||
|
||||
{/* Email */}
|
||||
{/* Email (Username) */}
|
||||
<div>
|
||||
<label htmlFor="member-email" className="block text-sm font-medium text-[var(--text-primary)] mb-1">
|
||||
{t('setup_wizard:team.fields.email', 'Email Address')} <span className="text-[var(--color-error)]">*</span>
|
||||
@@ -233,9 +343,62 @@ export const TeamSetupStep: React.FC<SetupStepProps> = ({ onUpdate, onComplete,
|
||||
className={`w-full px-3 py-2 bg-[var(--bg-primary)] border ${errors.email ? 'border-[var(--color-error)]' : 'border-[var(--border-secondary)]'} rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] text-[var(--text-primary)]`}
|
||||
placeholder={t('setup_wizard:team.placeholders.email', 'e.g., maria@panaderia.com')}
|
||||
/>
|
||||
<p className="mt-1 text-xs text-[var(--text-tertiary)]">
|
||||
{t('setup_wizard:team.email_hint', 'This will be used as their username to log in')}
|
||||
</p>
|
||||
{errors.email && <p className="mt-1 text-xs text-[var(--color-error)]">{errors.email}</p>}
|
||||
</div>
|
||||
|
||||
{/* Password */}
|
||||
<div>
|
||||
<label htmlFor="member-password" className="block text-sm font-medium text-[var(--text-primary)] mb-1">
|
||||
{t('setup_wizard:team.fields.password', 'Password')} <span className="text-[var(--color-error)]">*</span>
|
||||
</label>
|
||||
<input
|
||||
id="member-password"
|
||||
type="password"
|
||||
value={formData.password}
|
||||
onChange={(e) => setFormData({ ...formData, password: e.target.value })}
|
||||
className={`w-full px-3 py-2 bg-[var(--bg-primary)] border ${errors.password ? 'border-[var(--color-error)]' : 'border-[var(--border-secondary)]'} rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] text-[var(--text-primary)]`}
|
||||
placeholder={t('setup_wizard:team.placeholders.password', '••••••••')}
|
||||
/>
|
||||
<p className="mt-1 text-xs text-[var(--text-tertiary)]">
|
||||
{t('setup_wizard:team.password_hint', 'Minimum 8 characters')}
|
||||
</p>
|
||||
{errors.password && <p className="mt-1 text-xs text-[var(--color-error)]">{errors.password}</p>}
|
||||
</div>
|
||||
|
||||
{/* Confirm Password */}
|
||||
<div>
|
||||
<label htmlFor="member-confirm-password" className="block text-sm font-medium text-[var(--text-primary)] mb-1">
|
||||
{t('setup_wizard:team.fields.confirm_password', 'Confirm Password')} <span className="text-[var(--color-error)]">*</span>
|
||||
</label>
|
||||
<input
|
||||
id="member-confirm-password"
|
||||
type="password"
|
||||
value={formData.confirmPassword}
|
||||
onChange={(e) => setFormData({ ...formData, confirmPassword: e.target.value })}
|
||||
className={`w-full px-3 py-2 bg-[var(--bg-primary)] border ${errors.confirmPassword ? 'border-[var(--color-error)]' : 'border-[var(--border-secondary)]'} rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] text-[var(--text-primary)]`}
|
||||
placeholder={t('setup_wizard:team.placeholders.confirm_password', '••••••••')}
|
||||
/>
|
||||
{errors.confirmPassword && <p className="mt-1 text-xs text-[var(--color-error)]">{errors.confirmPassword}</p>}
|
||||
</div>
|
||||
|
||||
{/* Phone (Optional) */}
|
||||
<div>
|
||||
<label htmlFor="member-phone" className="block text-sm font-medium text-[var(--text-primary)] mb-1">
|
||||
{t('setup_wizard:team.fields.phone', 'Phone')} <span className="text-[var(--text-tertiary)]">({t('common:optional', 'Optional')})</span>
|
||||
</label>
|
||||
<input
|
||||
id="member-phone"
|
||||
type="tel"
|
||||
value={formData.phone}
|
||||
onChange={(e) => setFormData({ ...formData, phone: e.target.value })}
|
||||
className="w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border-secondary)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] text-[var(--text-primary)]"
|
||||
placeholder={t('setup_wizard:team.placeholders.phone', '+34 600 000 000')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Role */}
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-[var(--text-primary)] mb-2">
|
||||
@@ -247,10 +410,10 @@ export const TeamSetupStep: React.FC<SetupStepProps> = ({ onUpdate, onComplete,
|
||||
key={option.value}
|
||||
type="button"
|
||||
onClick={() => setFormData({ ...formData, role: option.value })}
|
||||
className={`p - 3 text - left border - 2 rounded - lg transition - all ${formData.role === option.value
|
||||
className={`p-3 text-left border-2 rounded-lg transition-all ${formData.role === option.value
|
||||
? 'border-[var(--color-primary)] bg-[var(--color-primary)]/20 shadow-lg ring-2 ring-[var(--color-primary)]/30'
|
||||
: 'border-[var(--border-secondary)] hover:border-[var(--color-primary)]/50 hover:bg-[var(--bg-secondary)]'
|
||||
} `}
|
||||
}`}
|
||||
>
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
<span className="text-lg">{option.icon}</span>
|
||||
@@ -266,9 +429,20 @@ export const TeamSetupStep: React.FC<SetupStepProps> = ({ onUpdate, onComplete,
|
||||
<div className="flex gap-2 pt-2">
|
||||
<button
|
||||
type="submit"
|
||||
className="px-4 py-2 bg-[var(--color-primary)] text-white rounded-lg hover:bg-[var(--color-primary-dark)] transition-colors font-medium"
|
||||
disabled={addMemberMutation.isPending}
|
||||
className="px-4 py-2 bg-[var(--color-primary)] text-white rounded-lg hover:bg-[var(--color-primary-dark)] transition-colors font-medium disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2"
|
||||
>
|
||||
{t('common:add', 'Add')}
|
||||
{addMemberMutation.isPending ? (
|
||||
<>
|
||||
<svg className="animate-spin h-4 w-4" fill="none" viewBox="0 0 24 24">
|
||||
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
|
||||
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" />
|
||||
</svg>
|
||||
{t('common:saving', 'Saving...')}
|
||||
</>
|
||||
) : (
|
||||
t('common:add', 'Add')
|
||||
)}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -204,26 +204,7 @@ export const Footer = forwardRef<FooterRef, FooterProps>(({
|
||||
const footerSections = sections || defaultSections;
|
||||
|
||||
// Social links - none for internal business application, full set for public pages
|
||||
const defaultSocialLinks: SocialLink[] = compact ? [] : [
|
||||
{
|
||||
id: 'twitter',
|
||||
label: t('common:footer.social_labels.twitter', 'Twitter'),
|
||||
href: 'https://twitter.com/panaderia-ia',
|
||||
icon: Twitter,
|
||||
},
|
||||
{
|
||||
id: 'linkedin',
|
||||
label: t('common:footer.social_labels.linkedin', 'LinkedIn'),
|
||||
href: 'https://linkedin.com/company/panaderia-ia',
|
||||
icon: Linkedin,
|
||||
},
|
||||
{
|
||||
id: 'github',
|
||||
label: t('common:footer.social_labels.github', 'GitHub'),
|
||||
href: 'https://github.com/panaderia-ia',
|
||||
icon: Github,
|
||||
},
|
||||
];
|
||||
const defaultSocialLinks: SocialLink[] = [];
|
||||
|
||||
const socialLinksToShow = socialLinks || defaultSocialLinks;
|
||||
|
||||
@@ -247,7 +228,7 @@ export const Footer = forwardRef<FooterRef, FooterProps>(({
|
||||
// Render link
|
||||
const renderLink = (link: FooterLink) => {
|
||||
const LinkIcon = link.icon;
|
||||
|
||||
|
||||
const linkContent = (
|
||||
<span className="flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors duration-200">
|
||||
{LinkIcon && <LinkIcon className="w-4 h-4" />}
|
||||
@@ -284,7 +265,7 @@ export const Footer = forwardRef<FooterRef, FooterProps>(({
|
||||
// Render social link
|
||||
const renderSocialLink = (social: SocialLink) => {
|
||||
const SocialIcon = social.icon;
|
||||
|
||||
|
||||
return (
|
||||
<a
|
||||
key={social.id}
|
||||
|
||||
@@ -78,7 +78,7 @@ export const PublicHeader = forwardRef<PublicHeaderRef, PublicHeaderProps>(({
|
||||
const [activeSection, setActiveSection] = useState<string>('');
|
||||
|
||||
// Default navigation items
|
||||
const defaultNavItems: Array<{id: string; label: string; href: string; external?: boolean}> = [
|
||||
const defaultNavItems: Array<{ id: string; label: string; href: string; external?: boolean }> = [
|
||||
{ id: 'home', label: t('common:nav.home', 'Inicio'), href: '/' },
|
||||
{ id: 'features', label: t('common:nav.features', 'Funcionalidades'), href: '/features' },
|
||||
{ id: 'about', label: t('common:nav.about', 'Nosotros'), href: '/about' },
|
||||
@@ -293,107 +293,107 @@ export const PublicHeader = forwardRef<PublicHeaderRef, PublicHeaderProps>(({
|
||||
"flex justify-between items-center transition-all duration-300",
|
||||
isScrolled ? "py-3 lg:py-4" : "py-4 lg:py-6"
|
||||
)}>
|
||||
{/* Logo and brand */}
|
||||
<div className="flex items-center gap-3 min-w-0">
|
||||
<Link to="/" className="flex items-center gap-3 hover:opacity-80 transition-opacity">
|
||||
{logo || (
|
||||
<>
|
||||
<div className="w-8 h-8 bg-gradient-to-br from-[var(--color-primary)] to-[var(--color-primary-dark)] rounded-lg flex items-center justify-center shadow-sm">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" className="w-5 h-5 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth="2.5">
|
||||
<polyline points="23 6 13.5 15.5 8.5 10.5 1 18"></polyline>
|
||||
<polyline points="17 6 23 6 23 12"></polyline>
|
||||
</svg>
|
||||
</div>
|
||||
<h1 className="text-xl lg:text-2xl font-bold text-[var(--text-primary)]">
|
||||
{t('common:app.name', 'BakeWise')}
|
||||
</h1>
|
||||
</>
|
||||
)}
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{/* Desktop navigation */}
|
||||
<nav className="hidden md:flex items-center space-x-8" role="navigation">
|
||||
{navItems.map((item) => renderNavLink(item, false))}
|
||||
</nav>
|
||||
|
||||
{/* Right side actions */}
|
||||
<div className="flex items-center gap-2 lg:gap-3">
|
||||
{/* Language selector - More compact */}
|
||||
{showLanguageSelector && (
|
||||
<div className="hidden sm:flex">
|
||||
<CompactLanguageSelector className="w-[70px]" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Theme toggle */}
|
||||
{showThemeToggle && (
|
||||
<ThemeToggle
|
||||
variant="button"
|
||||
size="md"
|
||||
className="hidden sm:flex"
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Authentication buttons - Enhanced */}
|
||||
{showAuthButtons && (
|
||||
<div className="flex items-center gap-2 lg:gap-3">
|
||||
<Link to={getLoginUrl()}>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="md"
|
||||
className="hidden sm:inline-flex font-medium hover:bg-[var(--bg-secondary)] transition-all duration-200"
|
||||
>
|
||||
{t('common:header.login')}
|
||||
</Button>
|
||||
</Link>
|
||||
<Link to={getRegisterUrl()}>
|
||||
<Button
|
||||
size="md"
|
||||
className="bg-gradient-to-r from-[var(--color-primary)] to-[var(--color-primary-dark)] hover:opacity-90 text-white font-semibold shadow-lg hover:shadow-xl transition-all duration-200 px-6"
|
||||
>
|
||||
<span className="hidden sm:inline">{t('common:header.start_free')}</span>
|
||||
<span className="sm:hidden">{t('common:header.register')}</span>
|
||||
</Button>
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Mobile theme toggle */}
|
||||
{showThemeToggle && (
|
||||
<ThemeToggle
|
||||
variant="button"
|
||||
size="sm"
|
||||
className="sm:hidden"
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Mobile menu button */}
|
||||
<div className="md:hidden">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="p-2 min-h-[44px] min-w-[44px]"
|
||||
aria-label={isMobileMenuOpen ? t('common:header.close_menu', 'Cerrar menú') : t('common:header.open_menu', 'Abrir menú')}
|
||||
aria-expanded={isMobileMenuOpen}
|
||||
aria-controls="mobile-menu"
|
||||
onClick={() => setIsMobileMenuOpen(!isMobileMenuOpen)}
|
||||
>
|
||||
<svg
|
||||
className={clsx("w-6 h-6 transition-transform duration-300", isMobileMenuOpen && "rotate-90")}
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
{isMobileMenuOpen ? (
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
||||
) : (
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 6h16M4 12h16M4 18h16" />
|
||||
)}
|
||||
</svg>
|
||||
</Button>
|
||||
{/* Logo and brand */}
|
||||
<div className="flex items-center gap-3 min-w-0">
|
||||
<Link to="/" className="flex items-center gap-3 hover:opacity-80 transition-opacity">
|
||||
{logo || (
|
||||
<>
|
||||
<div className="w-8 h-8 bg-gradient-to-br from-[var(--color-primary)] to-[var(--color-primary-dark)] rounded-lg flex items-center justify-center shadow-sm">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" className="w-5 h-5 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth="2.5">
|
||||
<polyline points="23 6 13.5 15.5 8.5 10.5 1 18"></polyline>
|
||||
<polyline points="17 6 23 6 23 12"></polyline>
|
||||
</svg>
|
||||
</div>
|
||||
<h1 className="text-xl lg:text-2xl font-bold text-[var(--text-primary)] hidden md:block">
|
||||
{t('common:app.name', 'BakeWise')}
|
||||
</h1>
|
||||
</>
|
||||
)}
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{/* Desktop navigation */}
|
||||
<nav className="hidden md:flex items-center space-x-8" role="navigation">
|
||||
{navItems.map((item) => renderNavLink(item, false))}
|
||||
</nav>
|
||||
|
||||
{/* Right side actions */}
|
||||
<div className="flex items-center gap-2 lg:gap-3">
|
||||
{/* Language selector - More compact */}
|
||||
{showLanguageSelector && (
|
||||
<div className="hidden sm:flex">
|
||||
<CompactLanguageSelector className="w-[70px]" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Theme toggle */}
|
||||
{showThemeToggle && (
|
||||
<ThemeToggle
|
||||
variant="button"
|
||||
size="md"
|
||||
className="hidden sm:flex"
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Authentication buttons - Enhanced */}
|
||||
{showAuthButtons && (
|
||||
<div className="flex items-center gap-2 lg:gap-3">
|
||||
<Link to={getLoginUrl()}>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="md"
|
||||
className="hidden sm:inline-flex font-medium hover:bg-[var(--bg-secondary)] transition-all duration-200"
|
||||
>
|
||||
{t('common:header.login')}
|
||||
</Button>
|
||||
</Link>
|
||||
<Link to={getRegisterUrl()}>
|
||||
<Button
|
||||
size="md"
|
||||
className="bg-gradient-to-r from-[var(--color-primary)] to-[var(--color-primary-dark)] hover:opacity-90 text-white font-semibold shadow-lg hover:shadow-xl transition-all duration-200 px-6"
|
||||
>
|
||||
<span className="hidden sm:inline">{t('common:header.start_free')}</span>
|
||||
<span className="sm:hidden">{t('common:header.register')}</span>
|
||||
</Button>
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Mobile theme toggle */}
|
||||
{showThemeToggle && (
|
||||
<ThemeToggle
|
||||
variant="button"
|
||||
size="sm"
|
||||
className="sm:hidden"
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Mobile menu button */}
|
||||
<div className="md:hidden">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="p-2 min-h-[44px] min-w-[44px]"
|
||||
aria-label={isMobileMenuOpen ? t('common:header.close_menu', 'Cerrar menú') : t('common:header.open_menu', 'Abrir menú')}
|
||||
aria-expanded={isMobileMenuOpen}
|
||||
aria-controls="mobile-menu"
|
||||
onClick={() => setIsMobileMenuOpen(!isMobileMenuOpen)}
|
||||
>
|
||||
<svg
|
||||
className={clsx("w-6 h-6 transition-transform duration-300", isMobileMenuOpen && "rotate-90")}
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
{isMobileMenuOpen ? (
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
||||
) : (
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 6h16M4 12h16M4 18h16" />
|
||||
)}
|
||||
</svg>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
@@ -435,7 +435,7 @@ export const PublicHeader = forwardRef<PublicHeaderRef, PublicHeaderProps>(({
|
||||
<polyline points="17 6 23 6 23 12"></polyline>
|
||||
</svg>
|
||||
</div>
|
||||
<h2 className="text-lg font-bold text-[var(--text-primary)]">
|
||||
<h2 className="text-lg font-bold text-[var(--text-primary)] hidden md:block">
|
||||
{t('common:app.name', 'BakeWise')}
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user