website cleanup

This commit is contained in:
2025-12-25 00:19:36 +01:00
parent d78854a4c6
commit 9486455b9e
82 changed files with 1223 additions and 363 deletions

View File

@@ -22,6 +22,7 @@ import Button from '@/components/ui/Button';
import Input from '@/components/ui/Input';
import Heading from '@/components/ui/Heading';
import CountrySelect from '@/components/ui/CountrySelect';
import { useServices } from '@/lib/services/ServiceProvider';
// ============================================================================
// TYPES
@@ -162,6 +163,7 @@ function StepIndicator({ currentStep }: { currentStep: number }) {
export default function OnboardingWizard() {
const router = useRouter();
const fileInputRef = useRef<HTMLInputElement>(null);
const { onboardingService, sessionService } = useServices();
const [step, setStep] = useState<OnboardingStep>(1);
const [loading, setLoading] = useState(false);
const [errors, setErrors] = useState<FormErrors>({});
@@ -276,18 +278,12 @@ export default function OnboardingWizard() {
});
try {
const response = await fetch('/api/avatar/validate-face', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ imageData: photoData }),
});
const result = await response.json();
const result = await onboardingService.validateFacePhoto(photoData);
if (!result.isValid) {
setErrors(prev => ({
...prev,
facePhoto: result.errorMessage || 'Face validation failed'
setErrors(prev => ({
...prev,
facePhoto: result.errorMessage || 'Face validation failed'
}));
setAvatarInfo(prev => ({ ...prev, facePhoto: null, isValidating: false }));
} else {
@@ -312,16 +308,17 @@ export default function OnboardingWizard() {
});
try {
const response = await fetch('/api/avatar/generate', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
facePhotoData: avatarInfo.facePhoto,
suitColor: avatarInfo.suitColor,
}),
});
// Get current user ID from session
const session = await sessionService.getSession();
if (!session?.user?.userId) {
throw new Error('User not authenticated');
}
const result = await response.json();
const result = await onboardingService.generateAvatars(
session.user.userId,
avatarInfo.facePhoto,
avatarInfo.suitColor
);
if (result.success && result.avatarUrls) {
setAvatarInfo(prev => ({
@@ -357,29 +354,23 @@ export default function OnboardingWizard() {
setErrors({});
try {
const selectedAvatarUrl = avatarInfo.generatedAvatars[avatarInfo.selectedAvatarIndex];
const response = await fetch('/api/auth/complete-onboarding', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
firstName: personalInfo.firstName.trim(),
lastName: personalInfo.lastName.trim(),
displayName: personalInfo.displayName.trim(),
country: personalInfo.country,
timezone: personalInfo.timezone || undefined,
avatarUrl: selectedAvatarUrl,
}),
// Note: The current API doesn't support avatarUrl in onboarding
// This would need to be handled separately or the API would need to be updated
const result = await onboardingService.completeOnboarding({
firstName: personalInfo.firstName.trim(),
lastName: personalInfo.lastName.trim(),
displayName: personalInfo.displayName.trim(),
country: personalInfo.country,
timezone: personalInfo.timezone || undefined,
});
const data = await response.json();
if (!response.ok) {
throw new Error(data.error || 'Failed to create profile');
if (result.success) {
// TODO: Handle avatar assignment separately if needed
router.push('/dashboard');
router.refresh();
} else {
throw new Error(result.errorMessage || 'Failed to create profile');
}
router.push('/dashboard');
router.refresh();
} catch (error) {
setErrors({
submit: error instanceof Error ? error.message : 'Failed to create profile',