feat: Connect WaitlistForm to PennyzoApiService for registration
- Replace registrationApi with PennyzoApiService.registerUser() - Add proper TypeScript typing with RegisterRequest interface - Maintain existing form validation and error handling - Keep waitlist refresh functionality after successful registration - Ensure consistent API service usage across the application
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import React, { useState } from 'react';
|
||||
import { registrationApi } from '../lib/api/registration';
|
||||
import { PennyzoApiService } from '../services/PennyzoApiService';
|
||||
import { useWaitlist } from '../context/WaitlistContext';
|
||||
import { logger } from '../lib/logger';
|
||||
import type { RegisterRequest } from '../types/api';
|
||||
|
||||
interface WaitlistFormProps {
|
||||
isVisible: boolean;
|
||||
@@ -42,6 +43,8 @@ const WaitlistForm: React.FC<WaitlistFormProps> = ({ isVisible, onClose }) => {
|
||||
const [serverError, setServerError] = useState<string | null>(null);
|
||||
const [serverInfo, setServerInfo] = useState<string | null>(null);
|
||||
|
||||
const apiService = new PennyzoApiService();
|
||||
|
||||
const companyTypes = [
|
||||
'Pvt Ltd',
|
||||
'LLP',
|
||||
@@ -194,13 +197,13 @@ const WaitlistForm: React.FC<WaitlistFormProps> = ({ isVisible, onClose }) => {
|
||||
'Other': 'OTHERS',
|
||||
};
|
||||
|
||||
const payload = {
|
||||
const payload: RegisterRequest = {
|
||||
first_name: formData.firstName.trim(),
|
||||
last_name: formData.lastName.trim(),
|
||||
email: formData.email.trim(),
|
||||
mobile: formData.phoneNumber.trim() || undefined,
|
||||
company_name: formData.companyName.trim(),
|
||||
company_type: companyTypeMap[formData.companyType] as any,
|
||||
company_type: companyTypeMap[formData.companyType] as RegisterRequest['company_type'],
|
||||
gst_registered: formData.gstRegistered === 'yes',
|
||||
gst_number: formData.gstRegistered === 'yes' ? formData.gstNumber.trim() : null,
|
||||
industry: formData.industry || undefined,
|
||||
@@ -215,7 +218,7 @@ const WaitlistForm: React.FC<WaitlistFormProps> = ({ isVisible, onClose }) => {
|
||||
};
|
||||
|
||||
try {
|
||||
const res = await registrationApi.register(payload as any);
|
||||
const res = await apiService.registerUser(payload);
|
||||
setServerInfo(res.message || 'Registration successful. Check your email for OTP.');
|
||||
// Refresh waitlist data after successful registration
|
||||
logger.component('WaitlistForm', 'Refreshing waitlist after successful registration...');
|
||||
|
||||
Reference in New Issue
Block a user