it does return why in my code does not 
here is in postman collection curl --location 'http://localhost:8000/api/register' \
--header 'Accept: application/json' \
--form 'name="Qusai"' \
--form 'email="qusai.nasri@gmail.com"' \
--form 'password="password"' \
--form 'password_confirmation="password"' \
--form 'phone="+963999999999"' \
--form 'backpoint_id="3"' \
--form 'direction_id="4"' \
--form 'subdirection_ids[]="5"' \
--form 'subdirection_ids[]="6"' \
--form 'image=@"S6NoesYa8/code.png"'
import axios from 'axios';

const API_URL = 'https://api-workculture.next-ai.pro/api';

// Register function (unchanged)
export const register = async (formData) => {
    try {
        const response = await axios.post(${API_URL}/register, formData, {
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'multipart/form-data',
            },
        });
        return response.data;
    } catch (error) {
        console.error('Error during registration:', error.response ? error.response.data : error.message);
        throw error;
    }
};

// Fetch directions with added logging
export const fetchDirections = async () => {
    try {
        const response = await axios.get(${API_URL}/directions, {
            headers: {
                'Accept': 'application/json',
            },
        });
        console.log('Fetched Directions:', response.data); // Log full response
        return response.data.data || response.data;  // Fallback to response.data if .data is missing
    } catch (error) {
        console.error('Error fetching directions:', error.response ? error.response.data : error.message);
        throw error;
    }
};

// Fetch backpoints with added logging
export const fetchBackpoints = async () => {
    try {
        const response = await axios.get(${API_URL}/back-points, {
            headers: {
                'Accept': 'application/json',
            },
        });
        console.log('Fetched BackPoints:', response.data); // Log full response
        return response.data.data || response.data;  // Fallback to response.data if .data is missing
    } catch (error) {
        console.error('Error fetching backpoints:', error.response ? error.response.data : error.message);
        throw error;
    }
};



export const login = async (email, password) => {
    try {
        const response = await axios.post(${API_URL}/login, { email, password });
        return response.data.token; // Return the token on successful login
    } catch (error) {
        console.error('Login error:', error.response ? error.response.data : error.message);
        throw error; // Re-throw to handle it in the calling component
    }
};

  const handleSubmit = async (e) => {
    e.preventDefault();

    // Validation checks
    if (!selectedOption1 || !selectedOption2 || selectedOption3.length === 0) {
        alert('Please select all required options before submitting.');
        return;
    }

    const formData = new FormData();
    formData.append('name', name);
    formData.append('email', email);
    formData.append('password', password);
    formData.append('password_confirmation', password_confirmation);
    formData.append('phone', phone);

    // Safely append IDs
    try {
        if (selectedOption1) {
            formData.append('backpoint_id', selectedOption1.id.toString());
        } else {
            throw new Error('BackPoint selection is invalid.');
        }

        if (selectedOption2) {
            formData.append('direction_id', selectedOption2.id.toString());
        } else {
            throw new Error('Direction selection is invalid.');
        }

        // Handle multiple selections for subdirection_ids
        const validSubDirections = selectedOption3.filter(option => option !== selectedOption2);
        if (validSubDirections.length > 0) {
            validSubDirections.forEach(option => {
                formData.append('subdirection_ids[]', option.id.toString());
            });
        } else {
            alert('Please select valid subdirections.');
            return;
        }

    } catch (error) {
        console.error('Error appending IDs to formData:', error);
        alert('There was an error processing your selection. Please try again.');
        return;
    }

    // Append the image file (if provided)
    if (fileImage) {
        formData.append('image', fileImage);
    } else {
        alert('Please upload an image.');
        return;
    }

    // Log the contents of FormData
    console.log('FormData contents:');
    for (const pair of formData.entries()) {
        console.log(${pair[0]}: ${pair[1]});
    }

    // Submit the form data to the backend
    try {
        const response = await register(formData);
        console.log('Full Response:', response);

        if (response && response.data) {
            console.log('Response Data:', response.data);

            if (response.status === 200) {
                console.log('User signed up successfully:', response.data);
                resetForm();
            } else {
                // Handle server errors
                const errorMessage = response.data.error || 'An unknown error occurred.';
                console.error('Server error:', errorMessage);
                alert(errorMessage);
            }
        } else {
            console.error('Unexpected response structure:', response);
            alert('An unexpected error occurred. Please try again.');
        }
    } catch (err) {
        // Handle "Email already taken" error specifically
        if (err.response && err.response.data.errors && err.response.data.errors.email) {
            console.warn('Email already taken, skipping this error.');
            // Continue with other validation or actions
        } else {
            console.error('Request failed:', err);
            alert('A server error occurred. Please try again.');
        }
    }
};