Invalid collection reference. Collection references must have an odd number of segments, but profiles/undefined has 2.
const user = await signUpNewUser(auth, email, password);
const docRef = await addDoc(collection(db, `profiles/${user.uid}`), {
nama: form.nama,
createdAt: new Date().getTime().toString(),
});
console.log("Document written with ID: ", docRef.id);
When you call addDoc Firestore generates the ID for the new document for you. If you want to specify the ID yourself (as you do with user.uid), use setDoc instead:
const docRef = await setDoc(collection(db, `profiles/${user.uid}`), {
nama: form.nama,
createdAt: new Date().getTime().toString(),
});
Also see the Firebase documentation on setting a document.