import { ISystemServiceClient } from './SystemServiceClientPb'
import { LoginRequest } from './System_pb'

export function useLogin() {
    const echoService = new ISystemServiceClient('http://192.168.30.188:6565', null, null)
    const loginRequest = new LoginRequest()
    
    const login = () => {
        const headers = {
            'Authorization': 'token',
            'Timestamp': '10086'
        }

        const call = echoService.loginIn(loginRequest, headers, (err, response) => {
            if (err) {
                console.error('Error:', err.message)
            } else {
                console.log('Response:', response.getMessage())
            }
        })

        call.on('status', (status) => {
            console.log('status', status)
        })
    }

    return {
        loginRequest,
        login
    }
}