1
1
import { initializeApp } from 'firebase/app' ;
2
- import {
3
- collection ,
4
- deleteDoc ,
5
- doc ,
6
- getDoc ,
7
- getDocs ,
8
- getFirestore ,
9
- query ,
10
- setDoc ,
11
- updateDoc ,
12
- where ,
13
- writeBatch ,
14
- } from 'firebase/firestore' ;
2
+ import { deleteDoc , doc , getDoc , getFirestore , setDoc , updateDoc } from 'firebase/firestore' ;
15
3
import { SessionProps , UserData } from '../../types' ;
16
4
17
5
// Firebase config and initialization
@@ -103,20 +91,6 @@ export async function deleteUser({ context, user, sub }: SessionProps) {
103
91
await deleteDoc ( ref ) ;
104
92
}
105
93
106
- export async function deleteStoreUsers ( { context, sub } : SessionProps ) {
107
- const contextString = context ?? sub ;
108
- const storeHash = contextString ?. split ( '/' ) [ 1 ] || '' ;
109
- const storeUsersRef = query ( collection ( db , 'storeUsers' ) , where ( 'storeHash' , '==' , storeHash ) ) ;
110
- const storeUsers = await getDocs ( storeUsersRef ) ;
111
- const batch = writeBatch ( db ) ;
112
-
113
- storeUsers . docs . forEach ( doc => {
114
- batch . delete ( doc . ref ) ;
115
- } ) ;
116
-
117
- await batch . commit ( ) ;
118
- }
119
-
120
94
export async function hasStoreUser ( storeHash : string , userId : string ) {
121
95
if ( ! storeHash || ! userId ) return false ;
122
96
@@ -133,9 +107,7 @@ export async function getStoreToken(storeHash: string) {
133
107
return storeDoc . data ( ) ?. accessToken ?? null ;
134
108
}
135
109
136
- export async function deleteStore ( { context, sub } : SessionProps ) {
137
- const contextString = context ?? sub ;
138
- const storeHash = contextString ?. split ( '/' ) [ 1 ] || '' ;
110
+ export async function deleteStore ( { store_hash : storeHash } : SessionProps ) {
139
111
const ref = doc ( db , 'store' , storeHash ) ;
140
112
141
113
await deleteDoc ( ref ) ;
0 commit comments