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