mirror of
https://github.com/shaulascr/ecommerce_serang.git
synced 2025-12-15 23:51:01 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@ -0,0 +1,24 @@
|
|||||||
|
package com.alya.ecommerce_serang.data.api.response.auth
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
|
data class DeleteFCMResponse(
|
||||||
|
|
||||||
|
@field:SerializedName("message")
|
||||||
|
val message: String,
|
||||||
|
|
||||||
|
@field:SerializedName("user")
|
||||||
|
val user: UserFCM
|
||||||
|
)
|
||||||
|
|
||||||
|
data class UserFCM(
|
||||||
|
|
||||||
|
@field:SerializedName("name")
|
||||||
|
val name: String,
|
||||||
|
|
||||||
|
@field:SerializedName("id")
|
||||||
|
val id: Int,
|
||||||
|
|
||||||
|
@field:SerializedName("email")
|
||||||
|
val email: String
|
||||||
|
)
|
||||||
@ -27,6 +27,7 @@ import com.alya.ecommerce_serang.data.api.dto.UpdateCart
|
|||||||
import com.alya.ecommerce_serang.data.api.dto.UpdateChatRequest
|
import com.alya.ecommerce_serang.data.api.dto.UpdateChatRequest
|
||||||
import com.alya.ecommerce_serang.data.api.dto.VerifRegisReq
|
import com.alya.ecommerce_serang.data.api.dto.VerifRegisReq
|
||||||
import com.alya.ecommerce_serang.data.api.response.auth.ChangePassResponse
|
import com.alya.ecommerce_serang.data.api.response.auth.ChangePassResponse
|
||||||
|
import com.alya.ecommerce_serang.data.api.response.auth.DeleteFCMResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.auth.FcmTokenResponse
|
import com.alya.ecommerce_serang.data.api.response.auth.FcmTokenResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.auth.HasStoreResponse
|
import com.alya.ecommerce_serang.data.api.response.auth.HasStoreResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.auth.ListNotifResponse
|
import com.alya.ecommerce_serang.data.api.response.auth.ListNotifResponse
|
||||||
@ -106,6 +107,10 @@ interface ApiService {
|
|||||||
@Body verifRegisReq: VerifRegisReq
|
@Body verifRegisReq: VerifRegisReq
|
||||||
):VerifRegisterResponse
|
):VerifRegisterResponse
|
||||||
|
|
||||||
|
@PUT("deletefcm")
|
||||||
|
suspend fun deleteFCMToken (
|
||||||
|
): DeleteFCMResponse
|
||||||
|
|
||||||
@Multipart
|
@Multipart
|
||||||
@POST("registerstore")
|
@POST("registerstore")
|
||||||
suspend fun registerStore(
|
suspend fun registerStore(
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import com.alya.ecommerce_serang.data.api.dto.ResetPassReq
|
|||||||
import com.alya.ecommerce_serang.data.api.dto.UserProfile
|
import com.alya.ecommerce_serang.data.api.dto.UserProfile
|
||||||
import com.alya.ecommerce_serang.data.api.dto.VerifRegisReq
|
import com.alya.ecommerce_serang.data.api.dto.VerifRegisReq
|
||||||
import com.alya.ecommerce_serang.data.api.response.auth.ChangePassResponse
|
import com.alya.ecommerce_serang.data.api.response.auth.ChangePassResponse
|
||||||
|
import com.alya.ecommerce_serang.data.api.response.auth.DeleteFCMResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.auth.FcmTokenResponse
|
import com.alya.ecommerce_serang.data.api.response.auth.FcmTokenResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.auth.HasStoreResponse
|
import com.alya.ecommerce_serang.data.api.response.auth.HasStoreResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.auth.ListStoreTypeResponse
|
import com.alya.ecommerce_serang.data.api.response.auth.ListStoreTypeResponse
|
||||||
@ -541,6 +542,10 @@ class UserRepository(private val apiService: ApiService) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun deleteFCMToken(): DeleteFCMResponse{
|
||||||
|
return apiService.deleteFCMToken()
|
||||||
|
}
|
||||||
|
|
||||||
companion object{
|
companion object{
|
||||||
private const val TAG = "UserRepository"
|
private const val TAG = "UserRepository"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -224,6 +224,7 @@ class ProfileFragment : Fragment() {
|
|||||||
delay(500)
|
delay(500)
|
||||||
loadingDialog.dismiss()
|
loadingDialog.dismiss()
|
||||||
sessionManager.clearAll()
|
sessionManager.clearAll()
|
||||||
|
viewModel.deleteFCM()
|
||||||
val intent = Intent(requireContext(), LoginActivity::class.java)
|
val intent = Intent(requireContext(), LoginActivity::class.java)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
requireActivity().finish()
|
requireActivity().finish()
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import androidx.lifecycle.ViewModel
|
|||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.alya.ecommerce_serang.data.api.dto.UserProfile
|
import com.alya.ecommerce_serang.data.api.dto.UserProfile
|
||||||
import com.alya.ecommerce_serang.data.api.response.auth.ChangePassResponse
|
import com.alya.ecommerce_serang.data.api.response.auth.ChangePassResponse
|
||||||
|
import com.alya.ecommerce_serang.data.api.response.auth.DeleteFCMResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.auth.HasStoreResponse
|
import com.alya.ecommerce_serang.data.api.response.auth.HasStoreResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.customer.profile.EditProfileResponse
|
import com.alya.ecommerce_serang.data.api.response.customer.profile.EditProfileResponse
|
||||||
import com.alya.ecommerce_serang.data.repository.Result
|
import com.alya.ecommerce_serang.data.repository.Result
|
||||||
@ -27,6 +28,10 @@ class ProfileViewModel(private val userRepository: UserRepository) : ViewModel()
|
|||||||
|
|
||||||
private val _checkStore = MutableLiveData<Boolean>()
|
private val _checkStore = MutableLiveData<Boolean>()
|
||||||
val checkStore: LiveData<Boolean> = _checkStore
|
val checkStore: LiveData<Boolean> = _checkStore
|
||||||
|
|
||||||
|
private val _deleteFCMT = MutableLiveData<String>()
|
||||||
|
val deleteFCMT: LiveData<String> = _deleteFCMT
|
||||||
|
|
||||||
val changePasswordResult = MutableLiveData<Result<ChangePassResponse>>()
|
val changePasswordResult = MutableLiveData<Result<ChangePassResponse>>()
|
||||||
private val _logout = MutableLiveData<Boolean>()
|
private val _logout = MutableLiveData<Boolean>()
|
||||||
val logout : LiveData<Boolean> = _logout
|
val logout : LiveData<Boolean> = _logout
|
||||||
@ -61,7 +66,25 @@ class ProfileViewModel(private val userRepository: UserRepository) : ViewModel()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun deleteFCM(){
|
||||||
|
viewModelScope.launch {
|
||||||
|
try {
|
||||||
|
// Call the repository function to request OTP
|
||||||
|
val response: DeleteFCMResponse = userRepository.deleteFCMToken()
|
||||||
|
|
||||||
|
// Log and store success message
|
||||||
|
Log.d("ProfileViewModel", "Has store: ${response.message}")
|
||||||
|
_deleteFCMT.postValue(response.message) // Store the message for UI feedback
|
||||||
|
|
||||||
|
} catch (exception: Exception) {
|
||||||
|
// Handle any errors and update state
|
||||||
|
_deleteFCMT.postValue(exception.message)
|
||||||
|
|
||||||
|
// Log the error for debugging
|
||||||
|
Log.e(":ProfileViewModel", "Error:", exception)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun editProfileDirect(
|
fun editProfileDirect(
|
||||||
context: Context,
|
context: Context,
|
||||||
|
|||||||
Reference in New Issue
Block a user