dropkickJesus999 commited on
Commit
29b0887
·
verified ·
1 Parent(s): 2d2cc60

In the top window, when I pick my custom email, make it show the full email address after domain/custom email is chosen. I'm also getting a different error when trying to send emails. About:srcdoc Failed to send email: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/compat/no-app). Please fix this issue.

Browse files
components/create-account.js CHANGED
@@ -50,11 +50,31 @@ class CustomCreateAccount extends HTMLElement {
50
  <div class="mb-4">
51
  <label class="block mb-2">Custom username (optional):</label>
52
  <input type="text" class="form-input" id="username-input" placeholder="Leave blank for random">
 
53
  </div>
54
  <button id="create-btn" class="btn-neon px-4 py-2 rounded w-full">
55
  <i data-feather="plus"></i> Create Email
56
  </button>
57
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  `;
59
  feather.replace();
60
  this.shadowRoot.getElementById('create-btn').addEventListener('click', async () => {
 
50
  <div class="mb-4">
51
  <label class="block mb-2">Custom username (optional):</label>
52
  <input type="text" class="form-input" id="username-input" placeholder="Leave blank for random">
53
+ <div id="email-preview" class="text-sm mt-1 text-red-400 hidden"></div>
54
  </div>
55
  <button id="create-btn" class="btn-neon px-4 py-2 rounded w-full">
56
  <i data-feather="plus"></i> Create Email
57
  </button>
58
  </div>
59
+ `;
60
+
61
+ // Show email preview when domain or username changes
62
+ const updateEmailPreview = () => {
63
+ const domain = this.shadowRoot.getElementById('domain-select').value;
64
+ const username = this.shadowRoot.getElementById('username-input').value.trim();
65
+ const preview = this.shadowRoot.getElementById('email-preview');
66
+
67
+ if (username) {
68
+ preview.textContent = `${username}@${domain}`;
69
+ preview.classList.remove('hidden');
70
+ } else {
71
+ preview.classList.add('hidden');
72
+ }
73
+ };
74
+
75
+ this.shadowRoot.getElementById('domain-select').addEventListener('change', updateEmailPreview);
76
+ this.shadowRoot.getElementById('username-input').addEventListener('input', updateEmailPreview);
77
+ </div>
78
  `;
79
  feather.replace();
80
  this.shadowRoot.getElementById('create-btn').addEventListener('click', async () => {
components/email-composer.js CHANGED
@@ -61,15 +61,14 @@ class CustomEmailComposer extends HTMLElement {
61
  alert('Please fill all fields');
62
  return;
63
  }
 
 
 
 
 
64
 
65
- try {
66
- const currentUser = firebase.auth().currentUser;
67
- if (!currentUser) {
68
- throw new Error('Not authenticated');
69
- }
70
-
71
- const emailId = await window.sendEmail(userId, {
72
- to,
73
  subject,
74
  body,
75
  from: currentUser.email + " (via eduGHoSt)",
 
61
  alert('Please fill all fields');
62
  return;
63
  }
64
+ try {
65
+ const currentUser = window.auth.currentUser;
66
+ if (!currentUser) {
67
+ throw new Error('Not authenticated');
68
+ }
69
 
70
+ const emailId = await window.sendEmail(userId, {
71
+ to,
 
 
 
 
 
 
72
  subject,
73
  body,
74
  from: currentUser.email + " (via eduGHoSt)",
script.js CHANGED
@@ -9,14 +9,21 @@ const firebaseConfig = {
9
  appId: "1:9876543210:web:abcdef1234567890"
10
  };
11
 
12
- // Initialize Firebase
13
- const app = firebase.initializeApp(firebaseConfig);
 
 
 
 
 
 
14
  const auth = firebase.auth();
15
  const db = firebase.firestore();
16
 
17
  // Make auth and db available globally
18
  window.auth = auth;
19
  window.db = db;
 
20
  // Authentication state listener
21
  auth.onAuthStateChanged((user) => {
22
  if (user) {
 
9
  appId: "1:9876543210:web:abcdef1234567890"
10
  };
11
 
12
+ // Check if Firebase app already exists
13
+ let app;
14
+ if (!firebase.apps.length) {
15
+ app = firebase.initializeApp(firebaseConfig);
16
+ } else {
17
+ app = firebase.app();
18
+ }
19
+
20
  const auth = firebase.auth();
21
  const db = firebase.firestore();
22
 
23
  // Make auth and db available globally
24
  window.auth = auth;
25
  window.db = db;
26
+ window.firebaseApp = app;
27
  // Authentication state listener
28
  auth.onAuthStateChanged((user) => {
29
  if (user) {