mirror of
https://github.com/shaulascr/ecommerce_serang.git
synced 2025-08-10 09:22:21 +00:00
@ -66,19 +66,19 @@ class MyStoreActivity : AppCompatActivity() {
|
||||
binding.tvStoreName.text = store.storeName
|
||||
binding.tvStoreType.text = store.storeType
|
||||
|
||||
if (store.storeImage.toString().isNotEmpty() && store.storeImage.toString() != "null") {
|
||||
val imageUrl = "$BASE_URL${store.storeImage}"
|
||||
Log.d("MyStoreActivity", "Loading store image from: $imageUrl")
|
||||
|
||||
Glide.with(this)
|
||||
.load(imageUrl)
|
||||
.placeholder(R.drawable.placeholder_image)
|
||||
.error(R.drawable.placeholder_image)
|
||||
.into(binding.ivProfile)
|
||||
} else {
|
||||
Log.d("MyStoreActivity", "No store image available")
|
||||
val imageUrl = when {
|
||||
store.storeImage.toString().isBlank() -> null
|
||||
store.storeImage.toString().startsWith("http") == true -> store.storeImage
|
||||
store.storeImage.toString().startsWith("/") == true -> BASE_URL + store.storeImage.toString().removePrefix("/")
|
||||
else -> BASE_URL + store.storeImage
|
||||
}
|
||||
|
||||
Glide.with(this)
|
||||
.load(imageUrl)
|
||||
.placeholder(R.drawable.placeholder_image)
|
||||
.error(R.drawable.placeholder_image)
|
||||
.into(binding.ivProfile)
|
||||
|
||||
// binding.tvBalance.text = String.format("Rp%,.0f", store.balance.toString())
|
||||
}
|
||||
|
||||
|
@ -112,8 +112,6 @@ class DetailStoreProfileActivity : AppCompatActivity() {
|
||||
} else {
|
||||
enterEditMode()
|
||||
}
|
||||
// val intent = Intent(this, EditStoreProfileActivity::class.java)
|
||||
// startActivityForResult(intent, EDIT_PROFILE_REQUEST_CODE)
|
||||
}
|
||||
|
||||
binding.layoutAddress.setOnClickListener {
|
||||
|
@ -68,16 +68,29 @@ class MyStoreViewModel(private val repository: MyStoreRepository): ViewModel() {
|
||||
) {
|
||||
viewModelScope.launch {
|
||||
try {
|
||||
val store = myStoreProfile.value
|
||||
|
||||
if (store == null) {
|
||||
_errorMessage.postValue("Data toko tidak tersedia")
|
||||
return@launch
|
||||
}
|
||||
|
||||
val response = repository.updateStoreProfile(
|
||||
storeName,
|
||||
"active".toRequestBody(),
|
||||
description,
|
||||
isOnLeave,
|
||||
0.toString().toRequestBody(),
|
||||
0.toString().toRequestBody(),
|
||||
"".toRequestBody(), "".toRequestBody(), "".toRequestBody(), "".toRequestBody(),
|
||||
"".toRequestBody(), "".toRequestBody(), "".toRequestBody(),
|
||||
storeType, storeImage
|
||||
storeName = storeName,
|
||||
storeStatus = "active".toRequestBody(),
|
||||
storeDescription = description,
|
||||
isOnLeave = isOnLeave,
|
||||
cityId = store.cityId.toString().toRequestBody(),
|
||||
provinceId = store.provinceId.toString().toRequestBody(),
|
||||
street = store.street.toRequestBody(),
|
||||
subdistrict = store.subdistrict.toRequestBody(),
|
||||
detail = store.detail.toRequestBody(),
|
||||
postalCode = store.postalCode.toRequestBody(),
|
||||
latitude = store.latitude.toRequestBody(),
|
||||
longitude = store.longitude.toRequestBody(),
|
||||
userPhone = store.phone.toRequestBody(),
|
||||
storeType = storeType,
|
||||
storeimg = storeImage
|
||||
)
|
||||
if (response.isSuccessful) _updateStoreProfileResult.postValue(response.body())
|
||||
else _errorMessage.postValue("Gagal memperbarui profil")
|
||||
|
Reference in New Issue
Block a user