File size: 2,133 Bytes
3543748
 
 
8035a7f
 
 
 
 
 
 
 
 
 
 
 
 
3543748
8035a7f
3543748
 
8035a7f
 
 
 
 
 
3543748
8035a7f
 
 
 
 
 
3543748
 
8035a7f
 
 
3543748
8035a7f
 
3543748
8035a7f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3543748
8035a7f
3543748
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
<!DOCTYPE html>
<html>
<head>
  <title>Firebase Test</title>
  <style>
    body { font-family: sans-serif; padding: 2rem; background: #f5f5f5; }
    .log { background: #1a1a1a; color: #fff; padding: 1rem; border-radius: 8px; margin-top: 1rem; font-size: 0.9rem; line-height: 2; }
    .ok  { color: #4ade80; }
    .err { color: #f87171; }
  </style>
</head>
<body>
  <h2>Firebase Connection Test</h2>
  <p>Check results below:</p>
  <div class="log" id="log">Running...</div>

  <script type="module">
    import { initializeApp }                      from "https://www.gstatic.com/firebasejs/10.12.0/firebase-app.js";
    import { getFirestore, doc, setDoc, getDoc } from "https://www.gstatic.com/firebasejs/10.12.0/firebase-firestore.js";

    const log = (msg, ok = true) => {
      const div = document.getElementById('log');
      div.innerHTML += `<div class="${ok ? 'ok' : 'err'}">${msg}</div>`;
    };
    document.getElementById('log').innerHTML = '';

    const firebaseConfig = {
      apiKey:            "AIzaSyAvcYiLnzwJjtYY9jO6Ax_vcfs8Kl2WsqM",
      authDomain:        "internal-ai-support-portal.firebaseapp.com",
      projectId:         "internal-ai-support-portal",
      storageBucket:     "internal-ai-support-portal.firebasestorage.app",
      messagingSenderId: "568502815360",
      appId:             "1:568502815360:web:2f02eae536cd883a037465"
    };

    try {
      const app = initializeApp(firebaseConfig);
      log("βœ… Firebase app initialized");

      const db = getFirestore(app);
      log("βœ… Firestore connected");

      // Write test
      await setDoc(doc(db, "test", "ping"), {
        message: "Firebase works!",
        time: new Date().toISOString()
      });
      log("βœ… Write success β€” document written to Firestore");

      // Read test
      const snap = await getDoc(doc(db, "test", "ping"));
      if (snap.exists()) {
        log("βœ… Read success β€” data: " + JSON.stringify(snap.data()));
      } else {
        log("❌ Read failed β€” document not found", false);
      }

    } catch (e) {
      log("❌ Error: " + e.message, false);
    }
  </script>
</body>
</html>