File size: 3,524 Bytes
f2dc0dc
635ad5b
 
 
 
 
28591dd
 
635ad5b
 
28591dd
635ad5b
28591dd
ec83112
28591dd
 
 
 
1e3da22
28591dd
 
1e3da22
28591dd
 
1e3da22
28591dd
 
1e3da22
af04085
28591dd
 
 
 
 
af04085
28591dd
 
1e3da22
28591dd
 
 
1e3da22
28591dd
 
 
af04085
28591dd
 
af04085
 
28591dd
 
 
 
 
 
 
 
af04085
28591dd
635ad5b
af04085
28591dd
 
 
 
1e3da22
28591dd
635ad5b
 
28591dd
635ad5b
 
 
1e3da22
28591dd
 
 
 
ec83112
28591dd
ec83112
 
 
28591dd
ec83112
 
635ad5b
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login - Biryani Hub</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
</head>
<body>

    <div class="container">
        <h2>Welcome to Biryani Hub 🍽️ 🍗</h2>

        <!-- Voice Input Section -->
        <div class="voice-section">
            <label for="name">Your Name</label>
            <input type="text" id="name" placeholder="Your name will appear here..." disabled>

            <label for="email">Your Email</label>
            <input type="email" id="voice-email" placeholder="Your email will appear here..." disabled>

            <label for="phone">Your Mobile Number</label>
            <input type="text" id="voice-phone" placeholder="Your mobile number will appear here..." disabled>

            <p><span class="listening">Listening 🎙️...</span></p>
            <button onclick="startVoiceRecognition()">Start Voice Recognition</button>
        </div>

        <!-- Login Section -->
        <div class="login-section">
            <h2>Login to Biryani Hub</h2>
            <label for="login-email">Email</label>
            <input type="email" id="login-email" placeholder="Enter your email">

            <label for="login-phone">Phone Number</label>
            <input type="text" id="login-phone" placeholder="Enter your phone number">

            <button onclick="login()">Login</button>
        </div>
    </div>

    <script>
        // Initialize Speech Recognition (for voice assistance)
        var recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();

        // Start Voice Recognition when button is clicked
        function startVoiceRecognition() {
            recognition.start();
            recognition.onresult = function(event) {
                let transcript = event.results[0][0].transcript;

                if (document.activeElement.id === "name") {
                    document.getElementById("name").value = transcript;
                } else if (document.activeElement.id === "voice-email") {
                    document.getElementById("voice-email").value = transcript;
                } else if (document.activeElement.id === "voice-phone") {
                    document.getElementById("voice-phone").value = transcript;
                }
            }
        }

        // Login function (manual)
        function login() {
            let email = document.getElementById('login-email').value;
            let phone = document.getElementById('login-phone').value;

            fetch('/login', {
                method: 'POST',
                headers: { 'Content-Type': 'application/json' },
                body: JSON.stringify({ email: email, phone_number: phone })
            })
            .then(response => response.json())
            .then(data => {
                if (data.success) {
                    localStorage.setItem('userName', data.user.Name);
                    localStorage.setItem('userEmail', email);
                    localStorage.setItem('userPhone', phone);
                    window.location.href = "/dashboard";  
                } else {
                    alert('Invalid credentials! Please contact admin to register in Salesforce.');
                }
            })
            .catch(error => {
                alert('Error logging in!');
            });
        }
    </script>
</body>
</html>