File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,23 @@ function displayUserCard(data, containerID) {
2121 level . className = 'absolute top-2 right-3 mt-2 mr-2 text-sm text-gray-400' ;
2222 level . textContent = `Level: ${ data . level } ` ;
2323
24+ const del = document . createElement ( 'button' ) ;
25+ del . className = 'bg-red-600 text-sm absolute bottom-4 right-20 mt-2 mr-2 px-4 py-2 rounded-md hover:bg-red-700 duration-300' ;
26+ del . textContent = 'Remove' ;
27+ del . onclick = function ( ) {
28+ const userRef = db . collection ( "Users" ) . doc ( auth . currentUser . uid ) ;
29+ userRef . update ( {
30+ connections : firebase . firestore . FieldValue . arrayRemove ( data . senderId )
31+ } ) . then ( ( ) => {
32+ console . log ( "User removed from connections successfully!" ) ;
33+ card . remove ( ) ;
34+ }
35+ ) . catch ( ( error ) => {
36+ console . error ( "Error removing user from connections: " , error ) ;
37+ }
38+ ) ;
39+ }
40+
2441 const button = document . createElement ( 'button' ) ;
2542 button . className = 'bg-blue-600 text-sm absolute bottom-4 right-3 mt-2 mr-2 px-4 py-2 rounded-md hover:bg-blue-700 duration-300' ;
2643 button . textContent = 'Chat' ;
@@ -51,6 +68,7 @@ function displayUserCard(data, containerID) {
5168 div . appendChild ( p ) ;
5269
5370 card . appendChild ( level ) ;
71+ card . appendChild ( del ) ;
5472 card . appendChild ( button ) ;
5573 card . appendChild ( img ) ;
5674 card . appendChild ( div ) ;
You can’t perform that action at this time.
0 commit comments