mirror of
https://github.com/shaulascr/ecommerce_serang.git
synced 2025-12-16 16:01:02 +00:00
Compare commits
3 Commits
3d8e82e3b5
...
f373035f8e
| Author | SHA1 | Date | |
|---|---|---|---|
| f373035f8e | |||
| 8d9815d89f | |||
| 1f41b4681f |
@ -29,6 +29,9 @@
|
|||||||
android:theme="@style/Theme.Ecommerce_serang"
|
android:theme="@style/Theme.Ecommerce_serang"
|
||||||
android:usesCleartextTraffic="true"
|
android:usesCleartextTraffic="true"
|
||||||
tools:targetApi="31">
|
tools:targetApi="31">
|
||||||
|
<activity
|
||||||
|
android:name=".ui.auth.ResetPassActivity"
|
||||||
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.profile.mystore.StoreSuspendedActivity"
|
android:name=".ui.profile.mystore.StoreSuspendedActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|||||||
@ -2,30 +2,20 @@ package com.alya.ecommerce_serang.data.api.dto
|
|||||||
|
|
||||||
import com.google.gson.annotations.SerializedName
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
data class City(
|
data class CityResponse(
|
||||||
@SerializedName("city_id")
|
|
||||||
val cityId: String,
|
|
||||||
|
|
||||||
@SerializedName("city_name")
|
@field:SerializedName("cities")
|
||||||
val cityName: String,
|
val cities: List<City>,
|
||||||
|
|
||||||
@SerializedName("province_id")
|
@field:SerializedName("message")
|
||||||
val provinceId: String,
|
val message: String
|
||||||
|
|
||||||
@SerializedName("province")
|
|
||||||
val provinceName: String,
|
|
||||||
|
|
||||||
@SerializedName("type")
|
|
||||||
val type: String,
|
|
||||||
|
|
||||||
@SerializedName("postal_code")
|
|
||||||
val postalCode: String
|
|
||||||
)
|
)
|
||||||
|
|
||||||
data class CityResponse(
|
data class City(
|
||||||
@SerializedName("message")
|
|
||||||
val message: String,
|
|
||||||
|
|
||||||
@SerializedName("cities")
|
@field:SerializedName("city_name")
|
||||||
val data: List<City>
|
val cityName: String,
|
||||||
)
|
|
||||||
|
@field:SerializedName("city_id")
|
||||||
|
val cityId: String
|
||||||
|
)
|
||||||
|
|||||||
@ -0,0 +1,8 @@
|
|||||||
|
package com.alya.ecommerce_serang.data.api.dto
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
|
data class ResetPassReq (
|
||||||
|
@SerializedName("emailOrPhone")
|
||||||
|
val emailOrPhone: String
|
||||||
|
)
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package com.alya.ecommerce_serang.data.api.dto
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
|
data class UpdateAddressReq(
|
||||||
|
@SerializedName("street")
|
||||||
|
val street: String? = "",
|
||||||
|
|
||||||
|
@SerializedName("subdistrict")
|
||||||
|
val subdistrict: String? = "",
|
||||||
|
|
||||||
|
@SerializedName("postal_code")
|
||||||
|
val postalCCode: String? = "",
|
||||||
|
|
||||||
|
@SerializedName("detail")
|
||||||
|
val detail: String? = "",
|
||||||
|
|
||||||
|
@SerializedName("city_id")
|
||||||
|
val cityId: String? = "",
|
||||||
|
|
||||||
|
@SerializedName("province_id")
|
||||||
|
val provId: String? = "",
|
||||||
|
|
||||||
|
@SerializedName("phone")
|
||||||
|
val phone: String? = ""
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.alya.ecommerce_serang.data.api.response.auth
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
|
data class ResetPassResponse(
|
||||||
|
|
||||||
|
@field:SerializedName("message")
|
||||||
|
val message: String
|
||||||
|
)
|
||||||
@ -0,0 +1,69 @@
|
|||||||
|
package com.alya.ecommerce_serang.data.api.response.customer.profile
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
|
data class AddressDetailResponse(
|
||||||
|
|
||||||
|
@field:SerializedName("address")
|
||||||
|
val address: Address,
|
||||||
|
|
||||||
|
@field:SerializedName("message")
|
||||||
|
val message: String
|
||||||
|
)
|
||||||
|
|
||||||
|
data class AddressDetail(
|
||||||
|
|
||||||
|
@field:SerializedName("village_id")
|
||||||
|
val villageId: String,
|
||||||
|
|
||||||
|
@field:SerializedName("is_store_location")
|
||||||
|
val isStoreLocation: Boolean,
|
||||||
|
|
||||||
|
@field:SerializedName("latitude")
|
||||||
|
val latitude: String,
|
||||||
|
|
||||||
|
@field:SerializedName("province_name")
|
||||||
|
val provinceName: String,
|
||||||
|
|
||||||
|
@field:SerializedName("subdistrict_id")
|
||||||
|
val subdistrictId: String,
|
||||||
|
|
||||||
|
@field:SerializedName("city_name")
|
||||||
|
val cityName: String,
|
||||||
|
|
||||||
|
@field:SerializedName("user_id")
|
||||||
|
val userId: Int,
|
||||||
|
|
||||||
|
@field:SerializedName("province_id")
|
||||||
|
val provinceId: String,
|
||||||
|
|
||||||
|
@field:SerializedName("phone")
|
||||||
|
val phone: String,
|
||||||
|
|
||||||
|
@field:SerializedName("street")
|
||||||
|
val street: String,
|
||||||
|
|
||||||
|
@field:SerializedName("subdistrict")
|
||||||
|
val subdistrict: String,
|
||||||
|
|
||||||
|
@field:SerializedName("recipient")
|
||||||
|
val recipient: String,
|
||||||
|
|
||||||
|
@field:SerializedName("id")
|
||||||
|
val id: Int,
|
||||||
|
|
||||||
|
@field:SerializedName("detail")
|
||||||
|
val detail: String,
|
||||||
|
|
||||||
|
@field:SerializedName("village_name")
|
||||||
|
val villageName: String,
|
||||||
|
|
||||||
|
@field:SerializedName("postal_code")
|
||||||
|
val postalCode: String,
|
||||||
|
|
||||||
|
@field:SerializedName("longitude")
|
||||||
|
val longitude: String,
|
||||||
|
|
||||||
|
@field:SerializedName("city_id")
|
||||||
|
val cityId: String
|
||||||
|
)
|
||||||
@ -14,7 +14,7 @@ data class AddressResponse(
|
|||||||
data class AddressesItem(
|
data class AddressesItem(
|
||||||
|
|
||||||
@field:SerializedName("village_id")
|
@field:SerializedName("village_id")
|
||||||
val villageId: String,
|
val villageId: String?,
|
||||||
|
|
||||||
@field:SerializedName("is_store_location")
|
@field:SerializedName("is_store_location")
|
||||||
val isStoreLocation: Boolean,
|
val isStoreLocation: Boolean,
|
||||||
@ -29,7 +29,7 @@ data class AddressesItem(
|
|||||||
val provinceId: String,
|
val provinceId: String,
|
||||||
|
|
||||||
@field:SerializedName("phone")
|
@field:SerializedName("phone")
|
||||||
val phone: String,
|
val phone: String?,
|
||||||
|
|
||||||
@field:SerializedName("street")
|
@field:SerializedName("street")
|
||||||
val street: String,
|
val street: String,
|
||||||
@ -38,7 +38,7 @@ data class AddressesItem(
|
|||||||
val subdistrict: String,
|
val subdistrict: String,
|
||||||
|
|
||||||
@field:SerializedName("recipient")
|
@field:SerializedName("recipient")
|
||||||
val recipient: String,
|
val recipient: String?,
|
||||||
|
|
||||||
@field:SerializedName("id")
|
@field:SerializedName("id")
|
||||||
val id: Int,
|
val id: Int,
|
||||||
|
|||||||
@ -0,0 +1,57 @@
|
|||||||
|
package com.alya.ecommerce_serang.data.api.response.customer.profile
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
|
data class UpdateAddressResponse(
|
||||||
|
|
||||||
|
@field:SerializedName("address")
|
||||||
|
val address: Address,
|
||||||
|
|
||||||
|
@field:SerializedName("message")
|
||||||
|
val message: String
|
||||||
|
)
|
||||||
|
|
||||||
|
data class Address(
|
||||||
|
|
||||||
|
@field:SerializedName("village_id")
|
||||||
|
val villageId: String,
|
||||||
|
|
||||||
|
@field:SerializedName("is_store_location")
|
||||||
|
val isStoreLocation: Boolean,
|
||||||
|
|
||||||
|
@field:SerializedName("latitude")
|
||||||
|
val latitude: String,
|
||||||
|
|
||||||
|
@field:SerializedName("user_id")
|
||||||
|
val userId: Int,
|
||||||
|
|
||||||
|
@field:SerializedName("province_id")
|
||||||
|
val provinceId: String,
|
||||||
|
|
||||||
|
@field:SerializedName("phone")
|
||||||
|
val phone: Any,
|
||||||
|
|
||||||
|
@field:SerializedName("street")
|
||||||
|
val street: String,
|
||||||
|
|
||||||
|
@field:SerializedName("subdistrict")
|
||||||
|
val subdistrict: String,
|
||||||
|
|
||||||
|
@field:SerializedName("recipient")
|
||||||
|
val recipient: Any,
|
||||||
|
|
||||||
|
@field:SerializedName("id")
|
||||||
|
val id: Int,
|
||||||
|
|
||||||
|
@field:SerializedName("detail")
|
||||||
|
val detail: String,
|
||||||
|
|
||||||
|
@field:SerializedName("postal_code")
|
||||||
|
val postalCode: String,
|
||||||
|
|
||||||
|
@field:SerializedName("longitude")
|
||||||
|
val longitude: String,
|
||||||
|
|
||||||
|
@field:SerializedName("city_id")
|
||||||
|
val cityId: String
|
||||||
|
)
|
||||||
@ -19,6 +19,7 @@ import com.alya.ecommerce_serang.data.api.dto.OtpRequest
|
|||||||
import com.alya.ecommerce_serang.data.api.dto.PaymentConfirmRequest
|
import com.alya.ecommerce_serang.data.api.dto.PaymentConfirmRequest
|
||||||
import com.alya.ecommerce_serang.data.api.dto.ProvinceResponse
|
import com.alya.ecommerce_serang.data.api.dto.ProvinceResponse
|
||||||
import com.alya.ecommerce_serang.data.api.dto.RegisterRequest
|
import com.alya.ecommerce_serang.data.api.dto.RegisterRequest
|
||||||
|
import com.alya.ecommerce_serang.data.api.dto.ResetPassReq
|
||||||
import com.alya.ecommerce_serang.data.api.dto.ReviewProductItem
|
import com.alya.ecommerce_serang.data.api.dto.ReviewProductItem
|
||||||
import com.alya.ecommerce_serang.data.api.dto.SearchRequest
|
import com.alya.ecommerce_serang.data.api.dto.SearchRequest
|
||||||
import com.alya.ecommerce_serang.data.api.dto.ShippingServiceRequest
|
import com.alya.ecommerce_serang.data.api.dto.ShippingServiceRequest
|
||||||
@ -36,6 +37,7 @@ import com.alya.ecommerce_serang.data.api.response.auth.LoginResponse
|
|||||||
import com.alya.ecommerce_serang.data.api.response.auth.OtpResponse
|
import com.alya.ecommerce_serang.data.api.response.auth.OtpResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.auth.RegisterResponse
|
import com.alya.ecommerce_serang.data.api.response.auth.RegisterResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.auth.RegisterStoreResponse
|
import com.alya.ecommerce_serang.data.api.response.auth.RegisterStoreResponse
|
||||||
|
import com.alya.ecommerce_serang.data.api.response.auth.ResetPassResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.auth.VerifRegisterResponse
|
import com.alya.ecommerce_serang.data.api.response.auth.VerifRegisterResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.chat.ChatHistoryResponse
|
import com.alya.ecommerce_serang.data.api.response.chat.ChatHistoryResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.chat.ChatListResponse
|
import com.alya.ecommerce_serang.data.api.response.chat.ChatListResponse
|
||||||
@ -65,6 +67,7 @@ import com.alya.ecommerce_serang.data.api.response.customer.profile.AddressRespo
|
|||||||
import com.alya.ecommerce_serang.data.api.response.customer.profile.CreateAddressResponse
|
import com.alya.ecommerce_serang.data.api.response.customer.profile.CreateAddressResponse
|
||||||
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.api.response.customer.profile.ProfileResponse
|
import com.alya.ecommerce_serang.data.api.response.customer.profile.ProfileResponse
|
||||||
|
import com.alya.ecommerce_serang.data.api.response.customer.profile.UpdateAddressResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.order.AddEvidenceResponse
|
import com.alya.ecommerce_serang.data.api.response.order.AddEvidenceResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.order.ComplaintResponse
|
import com.alya.ecommerce_serang.data.api.response.order.ComplaintResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.order.CompletedOrderResponse
|
import com.alya.ecommerce_serang.data.api.response.order.CompletedOrderResponse
|
||||||
@ -391,18 +394,8 @@ interface ApiService {
|
|||||||
@PUT("mystore/edit")
|
@PUT("mystore/edit")
|
||||||
suspend fun updateStoreProfileMultipart(
|
suspend fun updateStoreProfileMultipart(
|
||||||
@Part("store_name") storeName: RequestBody,
|
@Part("store_name") storeName: RequestBody,
|
||||||
@Part("store_status") storeStatus: RequestBody,
|
|
||||||
@Part("store_description") storeDescription: RequestBody,
|
@Part("store_description") storeDescription: RequestBody,
|
||||||
@Part("is_on_leave") isOnLeave: RequestBody,
|
@Part("is_on_leave") isOnLeave: RequestBody,
|
||||||
@Part("city_id") cityId: RequestBody,
|
|
||||||
@Part("province_id") provinceId: RequestBody,
|
|
||||||
@Part("street") street: RequestBody,
|
|
||||||
@Part("subdistrict") subdistrict: RequestBody,
|
|
||||||
@Part("detail") detail: RequestBody,
|
|
||||||
@Part("postal_code") postalCode: RequestBody,
|
|
||||||
@Part("latitude") latitude: RequestBody,
|
|
||||||
@Part("longitude") longitude: RequestBody,
|
|
||||||
@Part("user_phone") userPhone: RequestBody,
|
|
||||||
@Part("store_type_id") storeTypeId: RequestBody,
|
@Part("store_type_id") storeTypeId: RequestBody,
|
||||||
@Part storeimg: MultipartBody.Part?
|
@Part storeimg: MultipartBody.Part?
|
||||||
): Response<StoreDataResponse>
|
): Response<StoreDataResponse>
|
||||||
@ -454,6 +447,12 @@ interface ApiService {
|
|||||||
@Body addressData: HashMap<String, Any?>
|
@Body addressData: HashMap<String, Any?>
|
||||||
): Response<StoreAddressResponse>
|
): Response<StoreAddressResponse>
|
||||||
|
|
||||||
|
@PUT("profile/address/edit/{id}")
|
||||||
|
suspend fun updateAddress(
|
||||||
|
@Path("id") addressId: Int,
|
||||||
|
@Body params: Map<String, @JvmSuppressWildcards Any>
|
||||||
|
): Response<UpdateAddressResponse>
|
||||||
|
|
||||||
@POST("search")
|
@POST("search")
|
||||||
suspend fun saveSearchQuery(
|
suspend fun saveSearchQuery(
|
||||||
@Body searchRequest: SearchRequest
|
@Body searchRequest: SearchRequest
|
||||||
@ -524,4 +523,9 @@ interface ApiService {
|
|||||||
suspend fun getVillages(
|
suspend fun getVillages(
|
||||||
@Path("subdistrictId") subdistrictId: String
|
@Path("subdistrictId") subdistrictId: String
|
||||||
): Response<VillagesResponse>
|
): Response<VillagesResponse>
|
||||||
|
|
||||||
|
@POST("resetpass")
|
||||||
|
suspend fun postResetPass(
|
||||||
|
@Body request: ResetPassReq
|
||||||
|
): Response<ResetPassResponse>
|
||||||
}
|
}
|
||||||
@ -1,131 +1,140 @@
|
|||||||
package com.alya.ecommerce_serang.data.repository
|
package com.alya.ecommerce_serang.data.repository
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.alya.ecommerce_serang.data.api.dto.City
|
import com.alya.ecommerce_serang.data.api.dto.CityResponse
|
||||||
import com.alya.ecommerce_serang.data.api.dto.Province
|
import com.alya.ecommerce_serang.data.api.dto.ProvinceResponse
|
||||||
import com.alya.ecommerce_serang.data.api.dto.StoreAddress
|
import com.alya.ecommerce_serang.data.api.response.customer.order.SubdistrictResponse
|
||||||
|
import com.alya.ecommerce_serang.data.api.response.customer.profile.AddressResponse
|
||||||
|
import com.alya.ecommerce_serang.data.api.response.customer.profile.UpdateAddressResponse
|
||||||
import com.alya.ecommerce_serang.data.api.retrofit.ApiService
|
import com.alya.ecommerce_serang.data.api.retrofit.ApiService
|
||||||
import com.google.gson.Gson
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import org.json.JSONObject
|
import retrofit2.Response
|
||||||
|
|
||||||
class AddressRepository(private val apiService: ApiService) {
|
class AddressRepository(private val apiService: ApiService) {
|
||||||
|
|
||||||
private val TAG = "AddressRepository"
|
private val TAG = "AddressRepository"
|
||||||
|
|
||||||
suspend fun getProvinces(): List<Province> = withContext(Dispatchers.IO) {
|
// suspend fun getProvinces(): List<Province> = withContext(Dispatchers.IO) {
|
||||||
Log.d(TAG, "getProvinces() called")
|
// Log.d(TAG, "getProvinces() called")
|
||||||
try {
|
// try {
|
||||||
val response = apiService.getProvinces()
|
// val response = apiService.getProvinces()
|
||||||
Log.d(TAG, "getProvinces() response: isSuccessful=${response.isSuccessful}, code=${response.code()}")
|
// Log.d(TAG, "getProvinces() response: isSuccessful=${response.isSuccessful}, code=${response.code()}")
|
||||||
|
//
|
||||||
|
// // Log the raw response body for debugging
|
||||||
|
// val rawBody = response.raw().toString()
|
||||||
|
// Log.d(TAG, "Raw response: $rawBody")
|
||||||
|
//
|
||||||
|
// if (response.isSuccessful) {
|
||||||
|
// val responseBody = response.body()
|
||||||
|
// Log.d(TAG, "Response body: ${Gson().toJson(responseBody)}")
|
||||||
|
//
|
||||||
|
// val provinces = responseBody?.data ?: emptyList()
|
||||||
|
// Log.d(TAG, "getProvinces() success, got ${provinces.size} provinces")
|
||||||
|
// return@withContext provinces
|
||||||
|
// } else {
|
||||||
|
// val errorBody = response.errorBody()?.string() ?: "Unknown error"
|
||||||
|
// Log.e(TAG, "getProvinces() error: $errorBody")
|
||||||
|
// throw Exception("API Error (${response.code()}): $errorBody")
|
||||||
|
// }
|
||||||
|
// } catch (e: Exception) {
|
||||||
|
// Log.e(TAG, "Exception in getProvinces()", e)
|
||||||
|
// throw Exception("Network error: ${e.message}")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
// Log the raw response body for debugging
|
// suspend fun getCities(provinceId: String): List<City> = withContext(Dispatchers.IO) {
|
||||||
val rawBody = response.raw().toString()
|
// Log.d(TAG, "getCities() called with provinceId: $provinceId")
|
||||||
Log.d(TAG, "Raw response: $rawBody")
|
// try {
|
||||||
|
// val response = apiService.getCities(provinceId)
|
||||||
|
// Log.d(TAG, "getCities() response: isSuccessful=${response.isSuccessful}, code=${response.code()}")
|
||||||
|
//
|
||||||
|
// if (response.isSuccessful) {
|
||||||
|
// val responseBody = response.body()
|
||||||
|
// Log.d(TAG, "Response body: ${Gson().toJson(responseBody)}")
|
||||||
|
//
|
||||||
|
// val cities = responseBody?.data ?: emptyList()
|
||||||
|
// Log.d(TAG, "getCities() success, got ${cities.size} cities")
|
||||||
|
// return@withContext cities
|
||||||
|
// } else {
|
||||||
|
// val errorBody = response.errorBody()?.string() ?: "Unknown error"
|
||||||
|
// Log.e(TAG, "getCities() error: $errorBody")
|
||||||
|
// throw Exception("API Error (${response.code()}): $errorBody")
|
||||||
|
// }
|
||||||
|
// } catch (e: Exception) {
|
||||||
|
// Log.e(TAG, "Exception in getCities()", e)
|
||||||
|
// throw Exception("Network error: ${e.message}")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
if (response.isSuccessful) {
|
suspend fun getProvinces(): Response<ProvinceResponse> {
|
||||||
val responseBody = response.body()
|
return apiService.getProvinces()
|
||||||
Log.d(TAG, "Response body: ${Gson().toJson(responseBody)}")
|
|
||||||
|
|
||||||
val provinces = responseBody?.data ?: emptyList()
|
|
||||||
Log.d(TAG, "getProvinces() success, got ${provinces.size} provinces")
|
|
||||||
return@withContext provinces
|
|
||||||
} else {
|
|
||||||
val errorBody = response.errorBody()?.string() ?: "Unknown error"
|
|
||||||
Log.e(TAG, "getProvinces() error: $errorBody")
|
|
||||||
throw Exception("API Error (${response.code()}): $errorBody")
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e(TAG, "Exception in getProvinces()", e)
|
|
||||||
throw Exception("Network error: ${e.message}")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getCities(provinceId: String): List<City> = withContext(Dispatchers.IO) {
|
suspend fun getCities(provinceId: String): Response<CityResponse> {
|
||||||
Log.d(TAG, "getCities() called with provinceId: $provinceId")
|
return apiService.getCities(provinceId)
|
||||||
try {
|
|
||||||
val response = apiService.getCities(provinceId)
|
|
||||||
Log.d(TAG, "getCities() response: isSuccessful=${response.isSuccessful}, code=${response.code()}")
|
|
||||||
|
|
||||||
if (response.isSuccessful) {
|
|
||||||
val responseBody = response.body()
|
|
||||||
Log.d(TAG, "Response body: ${Gson().toJson(responseBody)}")
|
|
||||||
|
|
||||||
val cities = responseBody?.data ?: emptyList()
|
|
||||||
Log.d(TAG, "getCities() success, got ${cities.size} cities")
|
|
||||||
return@withContext cities
|
|
||||||
} else {
|
|
||||||
val errorBody = response.errorBody()?.string() ?: "Unknown error"
|
|
||||||
Log.e(TAG, "getCities() error: $errorBody")
|
|
||||||
throw Exception("API Error (${response.code()}): $errorBody")
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e(TAG, "Exception in getCities()", e)
|
|
||||||
throw Exception("Network error: ${e.message}")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getStoreAddress(): StoreAddress? = withContext(Dispatchers.IO) {
|
// suspend fun getStoreAddress(): StoreAddress? = withContext(Dispatchers.IO) {
|
||||||
Log.d(TAG, "getStoreAddress() called")
|
// Log.d(TAG, "getStoreAddress() called")
|
||||||
try {
|
// try {
|
||||||
val response = apiService.getStoreAddress()
|
// val response = apiService.getStoreAddress()
|
||||||
Log.d(TAG, "getStoreAddress() response: isSuccessful=${response.isSuccessful}, code=${response.code()}")
|
// Log.d(TAG, "getStoreAddress() response: isSuccessful=${response.isSuccessful}, code=${response.code()}")
|
||||||
|
//
|
||||||
if (response.isSuccessful) {
|
// if (response.isSuccessful) {
|
||||||
val responseBody = response.body()
|
// val responseBody = response.body()
|
||||||
val rawJson = Gson().toJson(responseBody)
|
// val rawJson = Gson().toJson(responseBody)
|
||||||
Log.d(TAG, "Response body: $rawJson")
|
// Log.d(TAG, "Response body: $rawJson")
|
||||||
|
//
|
||||||
val address = responseBody?.data
|
// val address = responseBody?.data
|
||||||
Log.d(TAG, "getStoreAddress() success, address: $address")
|
// Log.d(TAG, "getStoreAddress() success, address: $address")
|
||||||
|
//
|
||||||
// Convert numeric strings to proper types if needed
|
// // Convert numeric strings to proper types if needed
|
||||||
address?.let {
|
// address?.let {
|
||||||
// Handle city_id if it's a number
|
// // Handle city_id if it's a number
|
||||||
if (it.cityId.isBlank() && rawJson.contains("city_id")) {
|
// if (it.cityId.isBlank() && rawJson.contains("city_id")) {
|
||||||
try {
|
// try {
|
||||||
val cityId = JSONObject(rawJson).getJSONObject("store").optInt("city_id", 0)
|
// val cityId = JSONObject(rawJson).getJSONObject("store").optInt("city_id", 0)
|
||||||
if (cityId > 0) {
|
// if (cityId > 0) {
|
||||||
it.javaClass.getDeclaredField("cityId").apply {
|
// it.javaClass.getDeclaredField("cityId").apply {
|
||||||
isAccessible = true
|
// isAccessible = true
|
||||||
set(it, cityId.toString())
|
// set(it, cityId.toString())
|
||||||
}
|
// }
|
||||||
Log.d(TAG, "Updated cityId to: ${it.cityId}")
|
// Log.d(TAG, "Updated cityId to: ${it.cityId}")
|
||||||
}
|
// }
|
||||||
} catch (e: Exception) {
|
// } catch (e: Exception) {
|
||||||
Log.e(TAG, "Error parsing city_id", e)
|
// Log.e(TAG, "Error parsing city_id", e)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// Handle province_id if it's a number
|
// // Handle province_id if it's a number
|
||||||
if (it.provinceId.isBlank() && rawJson.contains("province_id")) {
|
// if (it.provinceId.isBlank() && rawJson.contains("province_id")) {
|
||||||
try {
|
// try {
|
||||||
val provinceId = JSONObject(rawJson).getJSONObject("store").optInt("province_id", 0)
|
// val provinceId = JSONObject(rawJson).getJSONObject("store").optInt("province_id", 0)
|
||||||
if (provinceId > 0) {
|
// if (provinceId > 0) {
|
||||||
it.javaClass.getDeclaredField("provinceId").apply {
|
// it.javaClass.getDeclaredField("provinceId").apply {
|
||||||
isAccessible = true
|
// isAccessible = true
|
||||||
set(it, provinceId.toString())
|
// set(it, provinceId.toString())
|
||||||
}
|
// }
|
||||||
Log.d(TAG, "Updated provinceId to: ${it.provinceId}")
|
// Log.d(TAG, "Updated provinceId to: ${it.provinceId}")
|
||||||
}
|
// }
|
||||||
} catch (e: Exception) {
|
// } catch (e: Exception) {
|
||||||
Log.e(TAG, "Error parsing province_id", e)
|
// Log.e(TAG, "Error parsing province_id", e)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return@withContext address
|
// return@withContext address
|
||||||
} else {
|
// } else {
|
||||||
val errorBody = response.errorBody()?.string() ?: "Unknown error"
|
// val errorBody = response.errorBody()?.string() ?: "Unknown error"
|
||||||
Log.e(TAG, "getStoreAddress() error: $errorBody")
|
// Log.e(TAG, "getStoreAddress() error: $errorBody")
|
||||||
throw Exception("API Error (${response.code()}): $errorBody")
|
// throw Exception("API Error (${response.code()}): $errorBody")
|
||||||
}
|
// }
|
||||||
} catch (e: Exception) {
|
// } catch (e: Exception) {
|
||||||
Log.e(TAG, "Exception in getStoreAddress()", e)
|
// Log.e(TAG, "Exception in getStoreAddress()", e)
|
||||||
throw Exception("Network error: ${e.message}")
|
// throw Exception("Network error: ${e.message}")
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
suspend fun saveStoreAddress(
|
suspend fun saveStoreAddress(
|
||||||
provinceId: String,
|
provinceId: String,
|
||||||
@ -171,4 +180,17 @@ class AddressRepository(private val apiService: ApiService) {
|
|||||||
throw Exception("Network error: ${e.message}")
|
throw Exception("Network error: ${e.message}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun getStoreAddress(): Response<AddressResponse> {
|
||||||
|
return apiService.getAddress()
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun updateAddress(addressId: Int, params: Map<String, Any>): Response<UpdateAddressResponse> {
|
||||||
|
return apiService.updateAddress(addressId, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun getListSubdistrict(cityId : String): SubdistrictResponse? {
|
||||||
|
val response = apiService.getSubdistrict(cityId)
|
||||||
|
return if (response.isSuccessful) response.body() else null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -53,48 +53,49 @@ class MyStoreRepository(private val apiService: ApiService) {
|
|||||||
|
|
||||||
suspend fun updateStoreProfile(
|
suspend fun updateStoreProfile(
|
||||||
storeName: RequestBody,
|
storeName: RequestBody,
|
||||||
storeStatus: RequestBody,
|
|
||||||
storeDescription: RequestBody,
|
storeDescription: RequestBody,
|
||||||
isOnLeave: RequestBody,
|
isOnLeave: RequestBody,
|
||||||
cityId: RequestBody,
|
|
||||||
provinceId: RequestBody,
|
|
||||||
street: RequestBody,
|
|
||||||
subdistrict: RequestBody,
|
|
||||||
detail: RequestBody,
|
|
||||||
postalCode: RequestBody,
|
|
||||||
latitude: RequestBody,
|
|
||||||
longitude: RequestBody,
|
|
||||||
userPhone: RequestBody,
|
|
||||||
storeType: RequestBody,
|
storeType: RequestBody,
|
||||||
storeimg: MultipartBody.Part?
|
storeimg: MultipartBody.Part?
|
||||||
): Response<StoreDataResponse> {
|
): Response<StoreDataResponse>? {
|
||||||
return apiService.updateStoreProfileMultipart(
|
|
||||||
storeName, storeStatus, storeDescription, isOnLeave, cityId, provinceId,
|
return try {
|
||||||
street, subdistrict, detail, postalCode, latitude, longitude, userPhone, storeType, storeimg
|
Log.d(TAG, "storeName: $storeName")
|
||||||
)
|
Log.d(TAG, "storeDescription: $storeDescription")
|
||||||
|
Log.d(TAG, "isOnLeave: $isOnLeave")
|
||||||
|
Log.d(TAG, "storeType: $storeType")
|
||||||
|
Log.d(TAG, "storeimg: ${storeimg?.headers}")
|
||||||
|
|
||||||
|
apiService.updateStoreProfileMultipart(
|
||||||
|
storeName, storeDescription, isOnLeave, storeType, storeimg
|
||||||
|
)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e(TAG, "Error updating store profile", e)
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getSellList(status: String): Result<OrderListResponse> {
|
suspend fun getSellList(status: String): Result<OrderListResponse> {
|
||||||
return try {
|
return try {
|
||||||
Log.d("SellsRepository", "Add Evidence : $status")
|
Log.d(TAG, "Add Evidence : $status")
|
||||||
val response = apiService.getSellList(status)
|
val response = apiService.getSellList(status)
|
||||||
|
|
||||||
if (response.isSuccessful) {
|
if (response.isSuccessful) {
|
||||||
val allListSell = response.body()
|
val allListSell = response.body()
|
||||||
if (allListSell != null) {
|
if (allListSell != null) {
|
||||||
Log.d("SellsRepository", "Add Evidence successfully: ${allListSell.message}")
|
Log.d(TAG, "Add Evidence successfully: ${allListSell.message}")
|
||||||
Result.Success(allListSell)
|
Result.Success(allListSell)
|
||||||
} else {
|
} else {
|
||||||
Log.e("SellsRepository", "Response body was null")
|
Log.e(TAG, "Response body was null")
|
||||||
Result.Error(Exception("Empty response from server"))
|
Result.Error(Exception("Empty response from server"))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val errorBody = response.errorBody()?.string() ?: "Unknown error"
|
val errorBody = response.errorBody()?.string() ?: "Unknown error"
|
||||||
Log.e("SellsRepository", "Error Add Evidence : $errorBody")
|
Log.e(TAG, "Error Add Evidence : $errorBody")
|
||||||
Result.Error(Exception(errorBody))
|
Result.Error(Exception(errorBody))
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("SellsRepository", "Exception Add Evidence ", e)
|
Log.e(TAG, "Exception Add Evidence ", e)
|
||||||
Result.Error(e)
|
Result.Error(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,7 +120,7 @@ class MyStoreRepository(private val apiService: ApiService) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("MyStoreRepository", "Error fetching balance", e)
|
Log.e(TAG, "Error fetching balance", e)
|
||||||
Result.Error(e)
|
Result.Error(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,11 +134,15 @@ class MyStoreRepository(private val apiService: ApiService) {
|
|||||||
throw Exception("Failed to fetch store products: ${response.message()}")
|
throw Exception("Failed to fetch store products: ${response.message()}")
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("ProductRepository", "Error fetching store products", e)
|
Log.e(TAG, "Error fetching store products", e)
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private var TAG = "MyStoreRepository"
|
||||||
|
}
|
||||||
|
|
||||||
// private fun fetchBalance() {
|
// private fun fetchBalance() {
|
||||||
// showLoading(true)
|
// showLoading(true)
|
||||||
// lifecycleScope.launch {
|
// lifecycleScope.launch {
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import com.alya.ecommerce_serang.data.api.dto.FcmReq
|
|||||||
import com.alya.ecommerce_serang.data.api.dto.LoginRequest
|
import com.alya.ecommerce_serang.data.api.dto.LoginRequest
|
||||||
import com.alya.ecommerce_serang.data.api.dto.OtpRequest
|
import com.alya.ecommerce_serang.data.api.dto.OtpRequest
|
||||||
import com.alya.ecommerce_serang.data.api.dto.RegisterRequest
|
import com.alya.ecommerce_serang.data.api.dto.RegisterRequest
|
||||||
|
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.FcmTokenResponse
|
import com.alya.ecommerce_serang.data.api.response.auth.FcmTokenResponse
|
||||||
@ -18,6 +19,7 @@ import com.alya.ecommerce_serang.data.api.response.auth.NotifstoreItem
|
|||||||
import com.alya.ecommerce_serang.data.api.response.auth.OtpResponse
|
import com.alya.ecommerce_serang.data.api.response.auth.OtpResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.auth.RegisterResponse
|
import com.alya.ecommerce_serang.data.api.response.auth.RegisterResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.auth.RegisterStoreResponse
|
import com.alya.ecommerce_serang.data.api.response.auth.RegisterStoreResponse
|
||||||
|
import com.alya.ecommerce_serang.data.api.response.auth.ResetPassResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.auth.VerifRegisterResponse
|
import com.alya.ecommerce_serang.data.api.response.auth.VerifRegisterResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.customer.order.ListCityResponse
|
import com.alya.ecommerce_serang.data.api.response.customer.order.ListCityResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.customer.order.ListProvinceResponse
|
import com.alya.ecommerce_serang.data.api.response.customer.order.ListProvinceResponse
|
||||||
@ -490,6 +492,30 @@ class UserRepository(private val apiService: ApiService) {
|
|||||||
Result.Error(e)
|
Result.Error(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun resetPassword(request: ResetPassReq): Result<ResetPassResponse>{
|
||||||
|
return try {
|
||||||
|
val response = apiService.postResetPass(request)
|
||||||
|
|
||||||
|
if (response.isSuccessful){
|
||||||
|
val resetPassResponse = response.body()
|
||||||
|
if (resetPassResponse != null) {
|
||||||
|
Result.Success(resetPassResponse)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Result.Error(Exception("Empty response from server"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
val errorBody = response.errorBody()?.string() ?: "Unknown error"
|
||||||
|
Log.e(TAG, "Error RESET PASS address: $errorBody")
|
||||||
|
Result.Error(Exception(errorBody))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e: Exception){
|
||||||
|
Result.Error(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
companion object{
|
companion object{
|
||||||
private const val TAG = "UserRepository"
|
private const val TAG = "UserRepository"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,6 +82,11 @@ class LoginActivity : AppCompatActivity() {
|
|||||||
startActivity(Intent(this, RegisterActivity::class.java))
|
startActivity(Intent(this, RegisterActivity::class.java))
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.tvForgetPassword.setOnClickListener {
|
||||||
|
startActivity(Intent(this, ResetPassActivity::class.java))
|
||||||
|
finish()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun observeLoginState() {
|
private fun observeLoginState() {
|
||||||
|
|||||||
@ -0,0 +1,123 @@
|
|||||||
|
package com.alya.ecommerce_serang.ui.auth
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.activity.viewModels
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import com.alya.ecommerce_serang.data.api.retrofit.ApiConfig
|
||||||
|
import com.alya.ecommerce_serang.data.repository.Result
|
||||||
|
import com.alya.ecommerce_serang.data.repository.UserRepository
|
||||||
|
import com.alya.ecommerce_serang.databinding.ActivityResetPassBinding
|
||||||
|
import com.alya.ecommerce_serang.utils.BaseViewModelFactory
|
||||||
|
import com.alya.ecommerce_serang.utils.viewmodel.LoginViewModel
|
||||||
|
|
||||||
|
class ResetPassActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
private val TAG = "ResetPassActivity"
|
||||||
|
private lateinit var binding: ActivityResetPassBinding
|
||||||
|
|
||||||
|
private val loginViewModel: LoginViewModel by viewModels{
|
||||||
|
BaseViewModelFactory {
|
||||||
|
val apiService = ApiConfig.getUnauthenticatedApiService()
|
||||||
|
val userRepository = UserRepository(apiService)
|
||||||
|
LoginViewModel(userRepository, this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
binding = ActivityResetPassBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
|
// enableEdgeToEdge()
|
||||||
|
|
||||||
|
setupToolbar()
|
||||||
|
setupUI()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupToolbar(){
|
||||||
|
binding.headerResetPass.headerLeftIcon.setOnClickListener{
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
binding.headerResetPass.headerTitle.text = "Lupa Password"
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupUI(){
|
||||||
|
binding.btnReset.setOnClickListener {
|
||||||
|
val email = binding.etEmail.text.toString().trim()
|
||||||
|
if (email.isNotEmpty()) {
|
||||||
|
loginViewModel.resetPassword(email)
|
||||||
|
} else {
|
||||||
|
binding.etEmail.error = "Masukkan Email Anda"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun observeResetPassword() {
|
||||||
|
loginViewModel.resetPasswordState.observe(this) { result ->
|
||||||
|
when (result) {
|
||||||
|
is com.alya.ecommerce_serang.data.repository.Result.Loading -> {
|
||||||
|
showLoading(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
is com.alya.ecommerce_serang.data.repository.Result.Success -> {
|
||||||
|
showLoading(false)
|
||||||
|
handleSuccess("Silahkan cek email anda untuk melihat password anda.")
|
||||||
|
Log.d(TAG, "Success rest password: ${result.data.message}")
|
||||||
|
}
|
||||||
|
|
||||||
|
is Result.Error -> {
|
||||||
|
showLoading(false)
|
||||||
|
handleError("Email anda salah atau tidak ditemukan.")
|
||||||
|
Log.e(TAG, "Error reset password ${result.exception.message}")
|
||||||
|
}
|
||||||
|
|
||||||
|
null -> {
|
||||||
|
// Initial state
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showLoading(isLoading: Boolean) {
|
||||||
|
if (isLoading) {
|
||||||
|
binding.progressBar.visibility = View.VISIBLE
|
||||||
|
binding.btnReset.isEnabled = false
|
||||||
|
binding.etEmail.isEnabled = false
|
||||||
|
} else {
|
||||||
|
binding.progressBar.visibility = View.GONE
|
||||||
|
binding.btnReset.isEnabled = true
|
||||||
|
binding.etEmail.isEnabled = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleSuccess(message: String) {
|
||||||
|
Toast.makeText(this, message, Toast.LENGTH_LONG).show()
|
||||||
|
|
||||||
|
// Show success dialog and navigate back to login
|
||||||
|
AlertDialog.Builder(this)
|
||||||
|
.setTitle("Berhasil Ubah Password")
|
||||||
|
.setMessage(message)
|
||||||
|
.setPositiveButton("OK") { _, _ ->
|
||||||
|
// Navigate back to login activity
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
.setCancelable(false)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleError(errorMessage: String) {
|
||||||
|
Toast.makeText(this, "Error: $errorMessage", Toast.LENGTH_LONG).show()
|
||||||
|
|
||||||
|
// Optionally show error dialog
|
||||||
|
AlertDialog.Builder(this)
|
||||||
|
.setTitle("Gagal Ubah Password")
|
||||||
|
.setMessage(errorMessage)
|
||||||
|
.setPositiveButton("OK", null)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -238,7 +238,8 @@ class RegisterStep3Fragment : Fragment() {
|
|||||||
|
|
||||||
binding.autoCompleteKecamatan.setOnItemClickListener{ _, _, position, _ ->
|
binding.autoCompleteKecamatan.setOnItemClickListener{ _, _, position, _ ->
|
||||||
val subdistrictId = subdistrictAdapter.getSubdistrictId(position)
|
val subdistrictId = subdistrictAdapter.getSubdistrictId(position)
|
||||||
Log.d(TAG, "Subdistrict selected at position $position, ID: $subdistrictId")
|
val subdistictName = subdistrictAdapter.getSubdistrictName(position)
|
||||||
|
Log.d(TAG, "Subdistrict selected at position $position, ID: $subdistrictId, name: $subdistictName")
|
||||||
|
|
||||||
subdistrictId?.let { id ->
|
subdistrictId?.let { id ->
|
||||||
Log.d(TAG, "Selected subdistrict ID set to: $id")
|
Log.d(TAG, "Selected subdistrict ID set to: $id")
|
||||||
@ -246,6 +247,11 @@ class RegisterStep3Fragment : Fragment() {
|
|||||||
registerViewModel.getVillages(id)
|
registerViewModel.getVillages(id)
|
||||||
binding.autoCompleteDesa.text.clear()
|
binding.autoCompleteDesa.text.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
subdistictName?.let { name ->
|
||||||
|
Log.d(TAG, "Selected name subdistrict set to: $name")
|
||||||
|
registerViewModel.subdistrictName = name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.autoCompleteDesa.setOnItemClickListener{ _, _, position, _ ->
|
binding.autoCompleteDesa.setOnItemClickListener{ _, _, position, _ ->
|
||||||
@ -375,7 +381,7 @@ class RegisterStep3Fragment : Fragment() {
|
|||||||
|
|
||||||
val provinceId = registerViewModel.selectedProvinceId?.toInt() ?: 0
|
val provinceId = registerViewModel.selectedProvinceId?.toInt() ?: 0
|
||||||
val cityId = registerViewModel.selectedCityId.toString()
|
val cityId = registerViewModel.selectedCityId.toString()
|
||||||
val subDistrict = registerViewModel.selectedSubdistrict.toString()
|
val subDistrict = registerViewModel.subdistrictName.toString()
|
||||||
// val postalCode = registerViewModel.selectedPostalCode.toString()
|
// val postalCode = registerViewModel.selectedPostalCode.toString()
|
||||||
|
|
||||||
val villageId = registerViewModel.selectedVillages ?: ""
|
val villageId = registerViewModel.selectedVillages ?: ""
|
||||||
@ -423,7 +429,7 @@ class RegisterStep3Fragment : Fragment() {
|
|||||||
|
|
||||||
val provinceId = registerViewModel.selectedProvinceId
|
val provinceId = registerViewModel.selectedProvinceId
|
||||||
val cityId = registerViewModel.selectedCityId
|
val cityId = registerViewModel.selectedCityId
|
||||||
val subDistrict = registerViewModel.selectedSubdistrict.toString()
|
val subDistrict = registerViewModel.selectedSubdistrict
|
||||||
val postalCode = registerViewModel.selectedPostalCode
|
val postalCode = registerViewModel.selectedPostalCode
|
||||||
|
|
||||||
Log.d(TAG, "Validating - Street: $street, SubDistrict: $subDistrict, PostalCode: $postalCode")
|
Log.d(TAG, "Validating - Street: $street, SubDistrict: $subDistrict, PostalCode: $postalCode")
|
||||||
@ -462,6 +468,12 @@ class RegisterStep3Fragment : Fragment() {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (subDistrict == null) {
|
||||||
|
showError("Pilih kota/kabupaten terlebih dahulu")
|
||||||
|
binding.autoCompleteKecamatan.requestFocus()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -119,6 +119,7 @@ class AddressActivity : AppCompatActivity() {
|
|||||||
val intent = Intent()
|
val intent = Intent()
|
||||||
intent.putExtra(EXTRA_ADDRESS_ID, addressId)
|
intent.putExtra(EXTRA_ADDRESS_ID, addressId)
|
||||||
setResult(RESULT_OK, intent)
|
setResult(RESULT_OK, intent)
|
||||||
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
@ -21,6 +21,8 @@ class AddressViewModel(private val repository: OrderRepository): ViewModel() {
|
|||||||
val response = repository.getAddress()
|
val response = repository.getAddress()
|
||||||
response?.let {
|
response?.let {
|
||||||
_addresses.value = it.addresses
|
_addresses.value = it.addresses
|
||||||
|
?.filter { address -> address.isStoreLocation == false }
|
||||||
|
?: emptyList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,6 +74,10 @@ class SubdsitrictAdapter(
|
|||||||
fun getSubdistrictId(position: Int): String? {
|
fun getSubdistrictId(position: Int): String? {
|
||||||
return cities.getOrNull(position)?.subdistrictId?.toString()
|
return cities.getOrNull(position)?.subdistrictId?.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getSubdistrictName(position: Int): String? {
|
||||||
|
return cities.getOrNull(position)?.subdistrictName?.toString()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class VillagesAdapter(
|
class VillagesAdapter(
|
||||||
|
|||||||
@ -485,7 +485,7 @@ class RegisterStoreActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Hide progress bar if it was showing
|
// Hide progress bar if it was showing
|
||||||
binding.storeTypeProgressBar.visibility = View.GONE
|
binding.bankNameProgressBar.visibility = View.GONE
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Invalid bank name for position: $position")
|
Log.e(TAG, "Invalid bank name for position: $position")
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package com.alya.ecommerce_serang.ui.profile.mystore.profile.address
|
package com.alya.ecommerce_serang.ui.profile.mystore.profile.address
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@ -14,13 +13,16 @@ import com.alya.ecommerce_serang.BuildConfig
|
|||||||
import com.alya.ecommerce_serang.R
|
import com.alya.ecommerce_serang.R
|
||||||
import com.alya.ecommerce_serang.data.api.dto.City
|
import com.alya.ecommerce_serang.data.api.dto.City
|
||||||
import com.alya.ecommerce_serang.data.api.dto.Province
|
import com.alya.ecommerce_serang.data.api.dto.Province
|
||||||
|
import com.alya.ecommerce_serang.data.api.response.customer.order.SubdistrictsItem
|
||||||
|
import com.alya.ecommerce_serang.data.api.response.customer.profile.AddressesItem
|
||||||
import com.alya.ecommerce_serang.data.api.retrofit.ApiConfig
|
import com.alya.ecommerce_serang.data.api.retrofit.ApiConfig
|
||||||
import com.alya.ecommerce_serang.data.api.retrofit.ApiService
|
import com.alya.ecommerce_serang.data.api.retrofit.ApiService
|
||||||
import com.alya.ecommerce_serang.data.repository.AddressRepository
|
import com.alya.ecommerce_serang.data.repository.AddressRepository
|
||||||
|
import com.alya.ecommerce_serang.data.repository.Result
|
||||||
import com.alya.ecommerce_serang.databinding.ActivityDetailStoreAddressBinding
|
import com.alya.ecommerce_serang.databinding.ActivityDetailStoreAddressBinding
|
||||||
import com.alya.ecommerce_serang.utils.viewmodel.AddressViewModel
|
|
||||||
import com.alya.ecommerce_serang.utils.BaseViewModelFactory
|
import com.alya.ecommerce_serang.utils.BaseViewModelFactory
|
||||||
import com.alya.ecommerce_serang.utils.SessionManager
|
import com.alya.ecommerce_serang.utils.SessionManager
|
||||||
|
import com.alya.ecommerce_serang.utils.viewmodel.AddressViewModel
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
|
||||||
class DetailStoreAddressActivity : AppCompatActivity() {
|
class DetailStoreAddressActivity : AppCompatActivity() {
|
||||||
@ -30,10 +32,15 @@ class DetailStoreAddressActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
private var selectedProvinceId: String? = null
|
private var selectedProvinceId: String? = null
|
||||||
private var selectedCityId: String? = null
|
private var selectedCityId: String? = null
|
||||||
|
private var selectedSubdistrict: String? = null
|
||||||
private var provinces: List<Province> = emptyList()
|
private var provinces: List<Province> = emptyList()
|
||||||
private var cities: List<City> = emptyList()
|
private var cities: List<City> = emptyList()
|
||||||
|
private var subdistrict: List<SubdistrictsItem> = emptyList()
|
||||||
|
private var currentAddress: AddressesItem? = null
|
||||||
|
|
||||||
private val TAG = "StoreAddressActivity"
|
// private lateinit var subdistrictAdapter: SubdsitrictAdapter
|
||||||
|
|
||||||
|
private val TAG = "DetailStoreAddressActivity"
|
||||||
|
|
||||||
private val viewModel: AddressViewModel by viewModels {
|
private val viewModel: AddressViewModel by viewModels {
|
||||||
BaseViewModelFactory {
|
BaseViewModelFactory {
|
||||||
@ -58,13 +65,15 @@ class DetailStoreAddressActivity : AppCompatActivity() {
|
|||||||
binding.tvError.visibility = View.GONE
|
binding.tvError.visibility = View.GONE
|
||||||
|
|
||||||
// Set up header title
|
// Set up header title
|
||||||
binding.header.headerTitle.text = "Atur Alamat Toko"
|
binding.headerAddressStore.headerTitle.text = "Atur Alamat Toko"
|
||||||
|
|
||||||
// Set up back button
|
// Set up back button
|
||||||
binding.header.headerLeftIcon.setOnClickListener {
|
binding.headerAddressStore.headerLeftIcon.setOnClickListener {
|
||||||
onBackPressedDispatcher.onBackPressed()
|
onBackPressedDispatcher.onBackPressed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// subdistrictAdapter = SubdsitrictAdapter(this)
|
||||||
|
|
||||||
setupSpinners()
|
setupSpinners()
|
||||||
setupObservers()
|
setupObservers()
|
||||||
setupSaveButton()
|
setupSaveButton()
|
||||||
@ -113,11 +122,26 @@ class DetailStoreAddressActivity : AppCompatActivity() {
|
|||||||
binding.spinnerCity.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
binding.spinnerCity.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||||
selectedCityId = if (position > 0) cities[position - 1].cityId else null
|
selectedCityId = if (position > 0) cities[position - 1].cityId else null
|
||||||
|
|
||||||
|
viewModel.getSubdistrict(selectedCityId.toString())
|
||||||
|
|
||||||
checkAllFieldsFilled()
|
checkAllFieldsFilled()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNothingSelected(p0: AdapterView<*>?) {}
|
override fun onNothingSelected(p0: AdapterView<*>?) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.spinnerSubdistrict.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
|
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||||
|
selectedSubdistrict = if (position > 0) subdistrict[position - 1].subdistrictName else null
|
||||||
|
|
||||||
|
checkAllFieldsFilled()
|
||||||
|
|
||||||
|
}
|
||||||
|
override fun onNothingSelected(p0: AdapterView<*>?) {}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupObservers() {
|
private fun setupObservers() {
|
||||||
@ -176,19 +200,58 @@ class DetailStoreAddressActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viewModel.subdistrictState.observe(this) { result ->
|
||||||
|
when (result) {
|
||||||
|
is com.alya.ecommerce_serang.data.repository.Result.Loading -> {
|
||||||
|
showSubLoading(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
is com.alya.ecommerce_serang.data.repository.Result.Success -> {
|
||||||
|
showSubLoading(false)
|
||||||
|
|
||||||
|
subdistrict = result.data
|
||||||
|
val subdistrictNames = mutableListOf("Pilih Kecamatan")
|
||||||
|
subdistrictNames.addAll(result.data.map { it.subdistrictName })
|
||||||
|
|
||||||
|
val adapter = ArrayAdapter(
|
||||||
|
this,
|
||||||
|
android.R.layout.simple_spinner_item,
|
||||||
|
subdistrictNames
|
||||||
|
)
|
||||||
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||||
|
binding.spinnerSubdistrict.adapter = adapter
|
||||||
|
|
||||||
|
// Compare by name, since stored value is the subdistrict name
|
||||||
|
viewModel.storeAddress.value?.let { address ->
|
||||||
|
val index = subdistrict.indexOfFirst { it.subdistrictName == address.subdistrict }
|
||||||
|
if (index != -1) {
|
||||||
|
binding.spinnerSubdistrict.setSelection(index + 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
is Result.Error -> {
|
||||||
|
showSubLoading(false)
|
||||||
|
Log.e(TAG, "Error: ${result.exception.message}", result.exception)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Observe store address data
|
// Observe store address data
|
||||||
viewModel.storeAddress.observe(this) { address ->
|
viewModel.storeAddress.observe(this) { address ->
|
||||||
|
currentAddress = address
|
||||||
Log.d(TAG, "Received store address: $address")
|
Log.d(TAG, "Received store address: $address")
|
||||||
address?.let {
|
address?.let {
|
||||||
// Set the fields
|
// Set the fields
|
||||||
binding.edtStreet.setText(it.street)
|
binding.edtStreet.setText(it.street)
|
||||||
binding.edtSubdistrict.setText(it.subdistrict)
|
// binding.edtSubdistrict.setText(it.subdistrict)
|
||||||
binding.edtDetailAddress.setText(it.detail ?: "")
|
binding.edtDetailAddress.setText(it.detail ?: "")
|
||||||
binding.edtPostalCode.setText(it.postalCode)
|
binding.edtPostalCode.setText(it.postalCode)
|
||||||
binding.edtLatitude.setText(it.latitude.toString())
|
binding.edtLatitude.setText(it.latitude.toString())
|
||||||
binding.edtLongitude.setText(it.longitude.toString())
|
binding.edtLongitude.setText(it.longitude.toString())
|
||||||
selectedProvinceId = it.provinceId
|
selectedProvinceId = it.provinceId
|
||||||
selectedCityId = it.cityId
|
selectedCityId = it.cityId
|
||||||
|
selectedSubdistrict = it.subdistrict
|
||||||
|
|
||||||
// Find province index and select it after provinces are loaded
|
// Find province index and select it after provinces are loaded
|
||||||
if (provinces.isNotEmpty()) {
|
if (provinces.isNotEmpty()) {
|
||||||
@ -214,11 +277,12 @@ class DetailStoreAddressActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Observe save success
|
// Observe save success
|
||||||
viewModel.saveSuccess.observe(this) {
|
viewModel.saveSuccess.observe(this) { success ->
|
||||||
if (it) {
|
if (success) {
|
||||||
Toast.makeText(this, "Alamat berhasil disimpan", Toast.LENGTH_SHORT).show()
|
Log.d(TAG, "Address updated successfully")
|
||||||
setResult(Activity.RESULT_OK)
|
|
||||||
finish()
|
finish()
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "Failed to update address")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -226,14 +290,15 @@ class DetailStoreAddressActivity : AppCompatActivity() {
|
|||||||
private fun setupSaveButton() {
|
private fun setupSaveButton() {
|
||||||
binding.btnSaveAddress.setOnClickListener {
|
binding.btnSaveAddress.setOnClickListener {
|
||||||
val street = binding.edtStreet.text.toString()
|
val street = binding.edtStreet.text.toString()
|
||||||
val subdistrict = binding.edtSubdistrict.text.toString()
|
|
||||||
val detail = binding.edtDetailAddress.text.toString()
|
val detail = binding.edtDetailAddress.text.toString()
|
||||||
val postalCode = binding.edtPostalCode.text.toString()
|
val postalCode = binding.edtPostalCode.text.toString()
|
||||||
val latitude = binding.edtLatitude.text.toString().toDoubleOrNull() ?: 0.0
|
val latitude = binding.edtLatitude.text.toString()
|
||||||
val longitude = binding.edtLongitude.text.toString().toDoubleOrNull() ?: 0.0
|
val longitude = binding.edtLongitude.text.toString()
|
||||||
|
|
||||||
val city = cities.find { it.cityId == selectedCityId }
|
val city = cities.find { it.cityId == selectedCityId }
|
||||||
val province = provinces.find { it.provinceId == selectedProvinceId }
|
val province = provinces.find { it.provinceId == selectedProvinceId }
|
||||||
|
val subdistrictName = subdistrict.find { it.subdistrictName == selectedSubdistrict }?.subdistrictName.toString()
|
||||||
|
Log.d(TAG, "Subdistrict name: $subdistrictName")
|
||||||
|
|
||||||
// Validate required fields
|
// Validate required fields
|
||||||
if (selectedProvinceId.isNullOrEmpty() || city == null || street.isEmpty() || subdistrict.isEmpty() || postalCode.isEmpty()) {
|
if (selectedProvinceId.isNullOrEmpty() || city == null || street.isEmpty() || subdistrict.isEmpty() || postalCode.isEmpty()) {
|
||||||
@ -241,19 +306,35 @@ class DetailStoreAddressActivity : AppCompatActivity() {
|
|||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save address
|
val oldAddress = currentAddress ?: return@setOnClickListener
|
||||||
viewModel.saveStoreAddress(
|
val newAddress = oldAddress.copy(
|
||||||
provinceId = selectedProvinceId!!,
|
provinceId = selectedProvinceId!!,
|
||||||
provinceName = province?.provinceName ?: "",
|
|
||||||
cityId = city.cityId,
|
cityId = city.cityId,
|
||||||
cityName = city.cityName,
|
|
||||||
street = street,
|
street = street,
|
||||||
subdistrict = subdistrict,
|
subdistrict = subdistrictName,
|
||||||
detail = detail,
|
detail = detail,
|
||||||
postalCode = postalCode,
|
postalCode = postalCode,
|
||||||
latitude = latitude,
|
latitude = latitude,
|
||||||
longitude = longitude
|
longitude = longitude,
|
||||||
|
phone = oldAddress.phone,
|
||||||
|
recipient = oldAddress.recipient ?: "",
|
||||||
|
isStoreLocation = oldAddress.isStoreLocation,
|
||||||
|
villageId = oldAddress.villageId
|
||||||
)
|
)
|
||||||
|
viewModel.saveStoreAddress(oldAddress, newAddress)
|
||||||
|
// Save address
|
||||||
|
// viewModel.saveStoreAddress(
|
||||||
|
// provinceId = selectedProvinceId!!,
|
||||||
|
// provinceName = province?.provinceName ?: "",
|
||||||
|
// cityId = city.cityId,
|
||||||
|
// cityName = city.cityName,
|
||||||
|
// street = street,
|
||||||
|
// subdistrict = subdistrict,
|
||||||
|
// detail = detail,
|
||||||
|
// postalCode = postalCode,
|
||||||
|
// latitude = latitude,
|
||||||
|
// longitude = longitude
|
||||||
|
// )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,15 +345,14 @@ class DetailStoreAddressActivity : AppCompatActivity() {
|
|||||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}
|
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}
|
||||||
}
|
}
|
||||||
binding.edtStreet.addTextChangedListener(watcher)
|
binding.edtStreet.addTextChangedListener(watcher)
|
||||||
binding.edtSubdistrict.addTextChangedListener(watcher)
|
|
||||||
binding.edtPostalCode.addTextChangedListener(watcher)
|
binding.edtPostalCode.addTextChangedListener(watcher)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkAllFieldsFilled() {
|
private fun checkAllFieldsFilled() {
|
||||||
val allValid = !selectedProvinceId.isNullOrEmpty()
|
val allValid = !selectedProvinceId.isNullOrEmpty()
|
||||||
&& !selectedCityId.isNullOrEmpty()
|
&& !selectedCityId.isNullOrEmpty()
|
||||||
|
&& !selectedSubdistrict.isNullOrEmpty()
|
||||||
&& binding.edtStreet.text.isNotBlank()
|
&& binding.edtStreet.text.isNotBlank()
|
||||||
&& binding.edtSubdistrict.text.isNotBlank()
|
|
||||||
&& binding.edtPostalCode.text.isNotBlank()
|
&& binding.edtPostalCode.text.isNotBlank()
|
||||||
|
|
||||||
binding.btnSaveAddress.let {
|
binding.btnSaveAddress.let {
|
||||||
@ -284,6 +364,7 @@ class DetailStoreAddressActivity : AppCompatActivity() {
|
|||||||
it.isEnabled = false
|
it.isEnabled = false
|
||||||
it.setBackgroundResource(R.drawable.bg_button_disabled)
|
it.setBackgroundResource(R.drawable.bg_button_disabled)
|
||||||
it.setTextColor(getColor(R.color.black_300))
|
it.setTextColor(getColor(R.color.black_300))
|
||||||
|
Toast.makeText(this, "Periksa dan lenkapi alamat anda", Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -298,6 +379,12 @@ class DetailStoreAddressActivity : AppCompatActivity() {
|
|||||||
binding.spinnerCity.visibility = if (isLoading) View.GONE else View.VISIBLE
|
binding.spinnerCity.visibility = if (isLoading) View.GONE else View.VISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showSubLoading(isLoading: Boolean) {
|
||||||
|
binding.subdistrictProgressBar.visibility = if (isLoading) View.VISIBLE else View.GONE
|
||||||
|
binding.spinnerSubdistrict.visibility = if (isLoading) View.GONE else View.VISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun showError(message: String) {
|
private fun showError(message: String) {
|
||||||
binding.progressBar.visibility = View.GONE
|
binding.progressBar.visibility = View.GONE
|
||||||
binding.tvError.visibility = View.VISIBLE
|
binding.tvError.visibility = View.VISIBLE
|
||||||
|
|||||||
@ -6,9 +6,12 @@ import android.net.Uri
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.widget.AdapterView
|
||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
|
import android.widget.ProgressBar
|
||||||
|
import android.widget.Spinner
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
@ -18,6 +21,7 @@ import com.alya.ecommerce_serang.data.api.dto.PaymentInfo
|
|||||||
import com.alya.ecommerce_serang.data.api.retrofit.ApiConfig
|
import com.alya.ecommerce_serang.data.api.retrofit.ApiConfig
|
||||||
import com.alya.ecommerce_serang.data.repository.PaymentInfoRepository
|
import com.alya.ecommerce_serang.data.repository.PaymentInfoRepository
|
||||||
import com.alya.ecommerce_serang.databinding.ActivityPaymentInfoBinding
|
import com.alya.ecommerce_serang.databinding.ActivityPaymentInfoBinding
|
||||||
|
import com.alya.ecommerce_serang.ui.order.address.BankAdapter
|
||||||
import com.alya.ecommerce_serang.utils.BaseViewModelFactory
|
import com.alya.ecommerce_serang.utils.BaseViewModelFactory
|
||||||
import com.alya.ecommerce_serang.utils.SessionManager
|
import com.alya.ecommerce_serang.utils.SessionManager
|
||||||
import com.alya.ecommerce_serang.utils.UriToFileConverter
|
import com.alya.ecommerce_serang.utils.UriToFileConverter
|
||||||
@ -32,6 +36,7 @@ class PaymentInfoActivity : AppCompatActivity() {
|
|||||||
private lateinit var sessionManager: SessionManager
|
private lateinit var sessionManager: SessionManager
|
||||||
private var selectedQrisImageUri: Uri? = null
|
private var selectedQrisImageUri: Uri? = null
|
||||||
private var selectedQrisImageFile: File? = null
|
private var selectedQrisImageFile: File? = null
|
||||||
|
private lateinit var bankAdapter: BankAdapter
|
||||||
|
|
||||||
// Store form data between dialog reopenings
|
// Store form data between dialog reopenings
|
||||||
private var savedBankName: String = ""
|
private var savedBankName: String = ""
|
||||||
@ -95,6 +100,7 @@ class PaymentInfoActivity : AppCompatActivity() {
|
|||||||
onBackPressedDispatcher.onBackPressed()
|
onBackPressedDispatcher.onBackPressed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bankAdapter = BankAdapter(this)
|
||||||
setupRecyclerView()
|
setupRecyclerView()
|
||||||
setupObservers()
|
setupObservers()
|
||||||
|
|
||||||
@ -173,10 +179,47 @@ class PaymentInfoActivity : AppCompatActivity() {
|
|||||||
builder.setView(dialogView)
|
builder.setView(dialogView)
|
||||||
|
|
||||||
val dialog = builder.create()
|
val dialog = builder.create()
|
||||||
|
val spinnerBankName = dialogView.findViewById<Spinner>(R.id.spinner_bank_name)
|
||||||
|
val progressBarBank = dialogView.findViewById<ProgressBar>(R.id.bank_name_progress_bar)
|
||||||
|
|
||||||
|
spinnerBankName.adapter = bankAdapter
|
||||||
|
spinnerBankName.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
|
override fun onItemSelected(
|
||||||
|
parent: AdapterView<*>?,
|
||||||
|
view: View?,
|
||||||
|
position: Int,
|
||||||
|
id: Long
|
||||||
|
) {
|
||||||
|
Log.d(TAG, "Bank selected at position: $position")
|
||||||
|
val bankName = bankAdapter.getBankName(position)
|
||||||
|
if (bankName != null) {
|
||||||
|
Log.d(TAG, "Setting bank name: $bankName")
|
||||||
|
viewModel.bankName.value = bankName
|
||||||
|
viewModel.selectedBankName = bankName
|
||||||
|
|
||||||
|
// Optional: Log the selected bank details
|
||||||
|
val selectedBank = bankAdapter.getBankItem(position)
|
||||||
|
selectedBank?.let {
|
||||||
|
Log.d(TAG, "Selected bank: ${it.bankName} (Code: ${it.bankCode})")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hide progress bar if it was showing
|
||||||
|
progressBarBank.visibility = View.GONE
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "Invalid bank name for position: $position")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||||
|
Log.d(TAG, "No bank selected")
|
||||||
|
viewModel.selectedBankName = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get references to views in the dialog
|
// Get references to views in the dialog
|
||||||
val btnAddQris = dialogView.findViewById<Button>(R.id.btn_add_qris)
|
val btnAddQris = dialogView.findViewById<Button>(R.id.btn_add_qris)
|
||||||
val bankNameEditText = dialogView.findViewById<EditText>(R.id.edt_bank_name)
|
// val spinnerBankName = dialogView.findViewById<Spinner>(R.id.spinner_bank_name)
|
||||||
val bankNumberEditText = dialogView.findViewById<EditText>(R.id.edt_bank_number)
|
val bankNumberEditText = dialogView.findViewById<EditText>(R.id.edt_bank_number)
|
||||||
val accountNameEditText = dialogView.findViewById<EditText>(R.id.edt_account_name)
|
val accountNameEditText = dialogView.findViewById<EditText>(R.id.edt_account_name)
|
||||||
val qrisPreview = dialogView.findViewById<ImageView>(R.id.iv_qris_preview)
|
val qrisPreview = dialogView.findViewById<ImageView>(R.id.iv_qris_preview)
|
||||||
@ -185,7 +228,10 @@ class PaymentInfoActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
// When reopening, restore the previously entered values
|
// When reopening, restore the previously entered values
|
||||||
if (isReopened) {
|
if (isReopened) {
|
||||||
bankNameEditText.setText(savedBankName)
|
val savedPosition = bankAdapter.findPositionByName(savedBankName)
|
||||||
|
if (savedPosition >= 0) {
|
||||||
|
spinnerBankName.setSelection(savedPosition)
|
||||||
|
}
|
||||||
bankNumberEditText.setText(savedBankNumber)
|
bankNumberEditText.setText(savedBankNumber)
|
||||||
accountNameEditText.setText(savedAccountName)
|
accountNameEditText.setText(savedAccountName)
|
||||||
|
|
||||||
@ -199,7 +245,7 @@ class PaymentInfoActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
btnAddQris.setOnClickListener {
|
btnAddQris.setOnClickListener {
|
||||||
// Save the current values before dismissing
|
// Save the current values before dismissing
|
||||||
savedBankName = bankNameEditText.text.toString().trim()
|
savedBankName = viewModel.selectedBankName ?: ""
|
||||||
savedBankNumber = bankNumberEditText.text.toString().trim()
|
savedBankNumber = bankNumberEditText.text.toString().trim()
|
||||||
savedAccountName = accountNameEditText.text.toString().trim()
|
savedAccountName = accountNameEditText.text.toString().trim()
|
||||||
|
|
||||||
@ -212,13 +258,13 @@ class PaymentInfoActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
btnSave.setOnClickListener {
|
btnSave.setOnClickListener {
|
||||||
val bankName = bankNameEditText.text.toString().trim()
|
val bankName = viewModel.selectedBankName ?: ""
|
||||||
val bankNumber = bankNumberEditText.text.toString().trim()
|
val bankNumber = bankNumberEditText.text.toString().trim()
|
||||||
val accountName = accountNameEditText.text.toString().trim()
|
val accountName = accountNameEditText.text.toString().trim()
|
||||||
|
|
||||||
// Validation
|
// Validation
|
||||||
if (bankName.isEmpty()) {
|
if (bankName.isEmpty()) {
|
||||||
showSnackbar("Nama bank tidak boleh kosong")
|
showSnackbar("Pilih nama bank terlebih dahulu")
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,8 +7,10 @@ import androidx.lifecycle.ViewModel
|
|||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.alya.ecommerce_serang.data.api.dto.City
|
import com.alya.ecommerce_serang.data.api.dto.City
|
||||||
import com.alya.ecommerce_serang.data.api.dto.Province
|
import com.alya.ecommerce_serang.data.api.dto.Province
|
||||||
import com.alya.ecommerce_serang.data.api.dto.StoreAddress
|
import com.alya.ecommerce_serang.data.api.response.customer.order.SubdistrictsItem
|
||||||
|
import com.alya.ecommerce_serang.data.api.response.customer.profile.AddressesItem
|
||||||
import com.alya.ecommerce_serang.data.repository.AddressRepository
|
import com.alya.ecommerce_serang.data.repository.AddressRepository
|
||||||
|
import com.alya.ecommerce_serang.data.repository.Result
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class AddressViewModel(private val addressRepository: AddressRepository) : ViewModel() {
|
class AddressViewModel(private val addressRepository: AddressRepository) : ViewModel() {
|
||||||
@ -21,8 +23,8 @@ class AddressViewModel(private val addressRepository: AddressRepository) : ViewM
|
|||||||
private val _cities = MutableLiveData<List<City>>()
|
private val _cities = MutableLiveData<List<City>>()
|
||||||
val cities: LiveData<List<City>> = _cities
|
val cities: LiveData<List<City>> = _cities
|
||||||
|
|
||||||
private val _storeAddress = MutableLiveData<StoreAddress?>()
|
private val _storeAddress = MutableLiveData<AddressesItem?>()
|
||||||
val storeAddress: LiveData<StoreAddress?> = _storeAddress
|
val storeAddress: LiveData<AddressesItem?> get() = _storeAddress
|
||||||
|
|
||||||
private val _isLoading = MutableLiveData<Boolean>()
|
private val _isLoading = MutableLiveData<Boolean>()
|
||||||
val isLoading: LiveData<Boolean> = _isLoading
|
val isLoading: LiveData<Boolean> = _isLoading
|
||||||
@ -31,99 +33,249 @@ class AddressViewModel(private val addressRepository: AddressRepository) : ViewM
|
|||||||
val errorMessage: LiveData<String> = _errorMessage
|
val errorMessage: LiveData<String> = _errorMessage
|
||||||
|
|
||||||
private val _saveSuccess = MutableLiveData<Boolean>()
|
private val _saveSuccess = MutableLiveData<Boolean>()
|
||||||
val saveSuccess: LiveData<Boolean> = _saveSuccess
|
val saveSuccess: LiveData<Boolean> get() = _saveSuccess
|
||||||
|
|
||||||
|
private val _subdistrictState = MutableLiveData<Result<List<SubdistrictsItem>>>()
|
||||||
|
val subdistrictState: LiveData<Result<List<SubdistrictsItem>>> = _subdistrictState
|
||||||
|
|
||||||
|
|
||||||
|
var selectedSubdistrict: String? = null
|
||||||
|
val subdistrict = MutableLiveData<String>()
|
||||||
|
|
||||||
fun fetchProvinces() {
|
fun fetchProvinces() {
|
||||||
Log.d(TAG, "fetchProvinces() called")
|
|
||||||
_isLoading.value = true
|
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
Log.d(TAG, "Calling addressRepository.getProvinces()")
|
|
||||||
val response = addressRepository.getProvinces()
|
val response = addressRepository.getProvinces()
|
||||||
Log.d(TAG, "Received provinces response: ${response.size} provinces")
|
if (response.isSuccessful) {
|
||||||
_provinces.value = response
|
_provinces.value = response.body()?.data ?: emptyList()
|
||||||
_isLoading.value = false
|
} else {
|
||||||
|
Log.e("EditAddressVM", "Failed to get provinces: ${response.message()}")
|
||||||
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(TAG, "Error fetching provinces", e)
|
Log.e("EditAddressVM", "Error getting provinces: ${e.message}")
|
||||||
_errorMessage.value = "Failed to load provinces: ${e.message}"
|
|
||||||
_isLoading.value = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun fetchCities(provinceId: String) {
|
fun fetchCities(provinceId: String) {
|
||||||
Log.d(TAG, "fetchCities() called with provinceId: $provinceId")
|
|
||||||
_isLoading.value = true
|
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
Log.d(TAG, "Calling addressRepository.getCities()")
|
|
||||||
val response = addressRepository.getCities(provinceId)
|
val response = addressRepository.getCities(provinceId)
|
||||||
Log.d(TAG, "Received cities response: ${response.size} cities")
|
if (response.isSuccessful) {
|
||||||
_cities.value = response
|
_cities.value = response.body()?.cities ?: emptyList()
|
||||||
_isLoading.value = false
|
} else {
|
||||||
|
Log.e("EditAddressVM", "Failed to get cities: ${response.message()}")
|
||||||
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(TAG, "Error fetching cities", e)
|
Log.e("EditAddressVM", "Error getting cities: ${e.message}")
|
||||||
_errorMessage.value = "Failed to load cities: ${e.message}"
|
|
||||||
_isLoading.value = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getSubdistrict(cityId: String) {
|
||||||
|
_subdistrictState.value = Result.Loading
|
||||||
|
viewModelScope.launch {
|
||||||
|
try {
|
||||||
|
|
||||||
|
selectedSubdistrict = cityId
|
||||||
|
val result = addressRepository.getListSubdistrict(cityId)
|
||||||
|
result?.let {
|
||||||
|
_subdistrictState.postValue(Result.Success(it.subdistricts))
|
||||||
|
Log.d(TAG, "Cities loaded for province $cityId: ${it.subdistricts.size}")
|
||||||
|
} ?: run {
|
||||||
|
_subdistrictState.postValue(Result.Error(Exception("Failed to load cities")))
|
||||||
|
Log.e(TAG, "City result was null for province $cityId")
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
_subdistrictState.postValue(Result.Error(Exception(e.message ?: "Error loading cities")))
|
||||||
|
Log.e(TAG, "Error fetching cities for province $cityId", e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// fun fetchProvinces() {
|
||||||
|
// Log.d(TAG, "fetchProvinces() called")
|
||||||
|
// _isLoading.value = true
|
||||||
|
// viewModelScope.launch {
|
||||||
|
// try {
|
||||||
|
// Log.d(TAG, "Calling addressRepository.getProvinces()")
|
||||||
|
// val response = addressRepository.getProvinces()
|
||||||
|
// Log.d(TAG, "Received provinces response: ${response.size} provinces")
|
||||||
|
// _provinces.value = response
|
||||||
|
// _isLoading.value = false
|
||||||
|
// } catch (e: Exception) {
|
||||||
|
// Log.e(TAG, "Error fetching provinces", e)
|
||||||
|
// _errorMessage.value = "Failed to load provinces: ${e.message}"
|
||||||
|
// _isLoading.value = false
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// fun fetchCities(provinceId: String) {
|
||||||
|
// Log.d(TAG, "fetchCities() called with provinceId: $provinceId")
|
||||||
|
// _isLoading.value = true
|
||||||
|
// viewModelScope.launch {
|
||||||
|
// try {
|
||||||
|
// selecte
|
||||||
|
// Log.d(TAG, "Calling addressRepository.getCities()")
|
||||||
|
// val response = addressRepository.getCities(provinceId)
|
||||||
|
// Log.d(TAG, "Received cities response: ${response.size} cities")
|
||||||
|
// _cities.value = response
|
||||||
|
// _isLoading.value = false
|
||||||
|
// } catch (e: Exception) {
|
||||||
|
// Log.e(TAG, "Error fetching cities", e)
|
||||||
|
// _errorMessage.value = "Failed to load cities: ${e.message}"
|
||||||
|
// _isLoading.value = false
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// fun fetchStoreAddress() {
|
||||||
|
// Log.d(TAG, "fetchStoreAddress() called")
|
||||||
|
// _isLoading.value = true
|
||||||
|
// viewModelScope.launch {
|
||||||
|
// try {
|
||||||
|
// Log.d(TAG, "Calling addressRepository.getStoreAddress()")
|
||||||
|
// val response = addressRepository.getStoreAddress()
|
||||||
|
// Log.d(TAG, "Received store address response: $response")
|
||||||
|
// _storeAddress.value = response
|
||||||
|
// _isLoading.value = false
|
||||||
|
// } catch (e: Exception) {
|
||||||
|
// Log.e(TAG, "Error fetching store address", e)
|
||||||
|
// _errorMessage.value = "Failed to load store address: ${e.message}"
|
||||||
|
// _isLoading.value = false
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// fun fetchStoreAddress() {
|
||||||
|
// viewModelScope.launch {
|
||||||
|
// try {
|
||||||
|
// val response = addressRepository.getStoreAddress()
|
||||||
|
// if (response.isSuccessful) {
|
||||||
|
// val storeAddress = response.body()?.addresses
|
||||||
|
// ?.firstOrNull { it.isStoreLocation == true }
|
||||||
|
//
|
||||||
|
// if (storeAddress != null) {
|
||||||
|
// _storeAddress.value = storeAddress
|
||||||
|
// } else {
|
||||||
|
// Log.d("EditAddressVM", "No store address found")
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// Log.e("EditAddressVM", "Failed to get addresses: ${response.message()}")
|
||||||
|
// }
|
||||||
|
// } catch (e: Exception) {
|
||||||
|
// Log.e("EditAddressVM", "Error: ${e.message}")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
fun fetchStoreAddress() {
|
fun fetchStoreAddress() {
|
||||||
Log.d(TAG, "fetchStoreAddress() called")
|
|
||||||
_isLoading.value = true
|
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
Log.d(TAG, "Calling addressRepository.getStoreAddress()")
|
|
||||||
val response = addressRepository.getStoreAddress()
|
val response = addressRepository.getStoreAddress()
|
||||||
Log.d(TAG, "Received store address response: $response")
|
if (response.isSuccessful) {
|
||||||
_storeAddress.value = response
|
val storeAddress = response.body()?.addresses
|
||||||
_isLoading.value = false
|
?.firstOrNull { it.isStoreLocation == true }
|
||||||
|
|
||||||
|
if (storeAddress != null) {
|
||||||
|
_storeAddress.value = storeAddress
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "No store address found")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "Failed to get addresses: ${response.message()}")
|
||||||
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(TAG, "Error fetching store address", e)
|
Log.e(TAG, "Error: ${e.message}")
|
||||||
_errorMessage.value = "Failed to load store address: ${e.message}"
|
|
||||||
_isLoading.value = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveStoreAddress(
|
// fun saveStoreAddress(
|
||||||
provinceId: String,
|
// provinceId: String,
|
||||||
provinceName: String,
|
// provinceName: String,
|
||||||
cityId: String,
|
// cityId: String,
|
||||||
cityName: String,
|
// cityName: String,
|
||||||
street: String,
|
// street: String,
|
||||||
subdistrict: String,
|
// subdistrict: String,
|
||||||
detail: String,
|
// detail: String,
|
||||||
postalCode: String,
|
// postalCode: String,
|
||||||
latitude: Double,
|
// latitude: Double,
|
||||||
longitude: Double
|
// longitude: Double
|
||||||
) {
|
// ) {
|
||||||
Log.d(TAG, "saveStoreAddress() called with provinceId: $provinceId, cityId: $cityId")
|
// Log.d(TAG, "saveStoreAddress() called with provinceId: $provinceId, cityId: $cityId")
|
||||||
_isLoading.value = true
|
// _isLoading.value = true
|
||||||
|
// viewModelScope.launch {
|
||||||
|
// try {
|
||||||
|
// Log.d(TAG, "Calling addressRepository.saveStoreAddress()")
|
||||||
|
// val success = addressRepository.saveStoreAddress(
|
||||||
|
// provinceId = provinceId,
|
||||||
|
// provinceName = provinceName,
|
||||||
|
// cityId = cityId,
|
||||||
|
// cityName = cityName,
|
||||||
|
// street = street,
|
||||||
|
// subdistrict = subdistrict,
|
||||||
|
// detail = detail,
|
||||||
|
// postalCode = postalCode,
|
||||||
|
// latitude = latitude,
|
||||||
|
// longitude = longitude
|
||||||
|
// )
|
||||||
|
// Log.d(TAG, "Save store address result: $success")
|
||||||
|
// _saveSuccess.value = success
|
||||||
|
// _isLoading.value = false
|
||||||
|
// } catch (e: Exception) {
|
||||||
|
// Log.e(TAG, "Error saving store address", e)
|
||||||
|
// _errorMessage.value = "Failed to save address: ${e.message}"
|
||||||
|
// _isLoading.value = false
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
fun saveStoreAddress(oldAddress: AddressesItem, newAddress: AddressesItem) {
|
||||||
|
val params = buildUpdateBody(oldAddress, newAddress)
|
||||||
|
if (params.isEmpty()) {
|
||||||
|
Log.d(TAG, "No changes detected")
|
||||||
|
_saveSuccess.value = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
Log.d(TAG, "Calling addressRepository.saveStoreAddress()")
|
val response = addressRepository.updateAddress(oldAddress.id, params)
|
||||||
val success = addressRepository.saveStoreAddress(
|
_saveSuccess.value = response.isSuccessful
|
||||||
provinceId = provinceId,
|
|
||||||
provinceName = provinceName,
|
|
||||||
cityId = cityId,
|
|
||||||
cityName = cityName,
|
|
||||||
street = street,
|
|
||||||
subdistrict = subdistrict,
|
|
||||||
detail = detail,
|
|
||||||
postalCode = postalCode,
|
|
||||||
latitude = latitude,
|
|
||||||
longitude = longitude
|
|
||||||
)
|
|
||||||
Log.d(TAG, "Save store address result: $success")
|
|
||||||
_saveSuccess.value = success
|
|
||||||
_isLoading.value = false
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(TAG, "Error saving store address", e)
|
Log.e(TAG, "Error: ${e.message}")
|
||||||
_errorMessage.value = "Failed to save address: ${e.message}"
|
_saveSuccess.value = false
|
||||||
_isLoading.value = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun buildUpdateBody(oldAddress: AddressesItem, newAddress: AddressesItem): Map<String, Any> {
|
||||||
|
|
||||||
|
val params = mutableMapOf<String, Any>()
|
||||||
|
|
||||||
|
fun addIfChanged(key: String, oldValue: Any?, newValue: Any?) {
|
||||||
|
if (newValue != null && newValue != oldValue) {
|
||||||
|
params[key] = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addIfChanged("street", oldAddress.street, newAddress.street)
|
||||||
|
addIfChanged("province_id", oldAddress.provinceId, newAddress.provinceId)
|
||||||
|
addIfChanged("detail", oldAddress.detail, newAddress.detail)
|
||||||
|
addIfChanged("subdistrict", oldAddress.subdistrict, newAddress.subdistrict)
|
||||||
|
addIfChanged("city_id", oldAddress.cityId, newAddress.cityId)
|
||||||
|
addIfChanged("village_id", oldAddress.villageId, newAddress.villageId)
|
||||||
|
addIfChanged("postal_code", oldAddress.postalCode, newAddress.postalCode)
|
||||||
|
addIfChanged("phone", oldAddress.phone, newAddress.phone)
|
||||||
|
addIfChanged("recipient", oldAddress.recipient, newAddress.recipient)
|
||||||
|
addIfChanged("latitude", oldAddress.latitude, newAddress.latitude)
|
||||||
|
addIfChanged("longitude", oldAddress.longitude, newAddress.longitude)
|
||||||
|
addIfChanged("is_store_location", oldAddress.isStoreLocation, newAddress.isStoreLocation)
|
||||||
|
|
||||||
|
return params
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -7,8 +7,10 @@ import androidx.lifecycle.MutableLiveData
|
|||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.alya.ecommerce_serang.data.api.dto.FcmReq
|
import com.alya.ecommerce_serang.data.api.dto.FcmReq
|
||||||
|
import com.alya.ecommerce_serang.data.api.dto.ResetPassReq
|
||||||
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.LoginResponse
|
import com.alya.ecommerce_serang.data.api.response.auth.LoginResponse
|
||||||
|
import com.alya.ecommerce_serang.data.api.response.auth.ResetPassResponse
|
||||||
import com.alya.ecommerce_serang.data.api.retrofit.ApiConfig
|
import com.alya.ecommerce_serang.data.api.retrofit.ApiConfig
|
||||||
import com.alya.ecommerce_serang.data.api.retrofit.ApiService
|
import com.alya.ecommerce_serang.data.api.retrofit.ApiService
|
||||||
import com.alya.ecommerce_serang.data.repository.Result
|
import com.alya.ecommerce_serang.data.repository.Result
|
||||||
@ -27,6 +29,10 @@ class LoginViewModel(private val repository: UserRepository, private val context
|
|||||||
private val _message = MutableLiveData<String>()
|
private val _message = MutableLiveData<String>()
|
||||||
val message: LiveData<String> = _message
|
val message: LiveData<String> = _message
|
||||||
|
|
||||||
|
private val _resetPasswordState = MutableLiveData<Result<ResetPassResponse>?>()
|
||||||
|
val resetPasswordState: LiveData<Result<ResetPassResponse>?> = _resetPasswordState
|
||||||
|
|
||||||
|
|
||||||
private val sessionManager by lazy { SessionManager(context) }
|
private val sessionManager by lazy { SessionManager(context) }
|
||||||
|
|
||||||
private fun getAuthenticatedApiService(): ApiService {
|
private fun getAuthenticatedApiService(): ApiService {
|
||||||
@ -69,4 +75,19 @@ class LoginViewModel(private val repository: UserRepository, private val context
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun resetPassword(email: String) {
|
||||||
|
viewModelScope.launch {
|
||||||
|
_resetPasswordState.value = Result.Loading
|
||||||
|
|
||||||
|
val request = ResetPassReq(emailOrPhone = email)
|
||||||
|
val result = repository.resetPassword(request)
|
||||||
|
|
||||||
|
_resetPasswordState.value = result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clearState() {
|
||||||
|
_resetPasswordState.value = null
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -21,6 +21,8 @@ import java.text.NumberFormat
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
class MyStoreViewModel(private val repository: MyStoreRepository): ViewModel() {
|
class MyStoreViewModel(private val repository: MyStoreRepository): ViewModel() {
|
||||||
|
private var TAG = "MyStoreViewModel"
|
||||||
|
|
||||||
private val _myStoreProfile = MutableLiveData<Store?>()
|
private val _myStoreProfile = MutableLiveData<Store?>()
|
||||||
val myStoreProfile: LiveData<Store?> = _myStoreProfile
|
val myStoreProfile: LiveData<Store?> = _myStoreProfile
|
||||||
|
|
||||||
@ -84,30 +86,40 @@ class MyStoreViewModel(private val repository: MyStoreRepository): ViewModel() {
|
|||||||
|
|
||||||
if (store == null) {
|
if (store == null) {
|
||||||
_errorMessage.postValue("Data toko tidak tersedia")
|
_errorMessage.postValue("Data toko tidak tersedia")
|
||||||
|
Log.e(TAG, "Store data is null")
|
||||||
return@launch
|
return@launch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.d("UpdateStoreProfileVM", "Calling repository with params:")
|
||||||
|
Log.d("UpdateStoreProfileVM", "storeName: $storeName")
|
||||||
|
Log.d("UpdateStoreProfileVM", "description: $description")
|
||||||
|
Log.d("UpdateStoreProfileVM", "isOnLeave: $isOnLeave")
|
||||||
|
Log.d("UpdateStoreProfileVM", "storeType: $storeType")
|
||||||
|
Log.d("UpdateStoreProfileVM", "storeImage: ${storeImage?.headers}")
|
||||||
|
|
||||||
val response = repository.updateStoreProfile(
|
val response = repository.updateStoreProfile(
|
||||||
storeName = storeName,
|
storeName = storeName,
|
||||||
storeStatus = "active".toRequestBody(),
|
|
||||||
storeDescription = description,
|
storeDescription = description,
|
||||||
isOnLeave = isOnLeave,
|
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,
|
storeType = storeType,
|
||||||
storeimg = storeImage
|
storeimg = storeImage
|
||||||
)
|
)
|
||||||
if (response.isSuccessful) _updateStoreProfileResult.postValue(response.body())
|
|
||||||
else _errorMessage.postValue("Gagal memperbarui profil")
|
if (response != null) {
|
||||||
|
if (response.isSuccessful) {
|
||||||
|
_updateStoreProfileResult.postValue(response.body())
|
||||||
|
Log.d(TAG, "Update successful: ${response.body()}")
|
||||||
|
} else {
|
||||||
|
_errorMessage.postValue("Gagal memperbarui profil")
|
||||||
|
Log.e(TAG, "Update failed: ${response.errorBody()?.string()}")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_errorMessage.postValue("Terjadi kesalahan jaringan atau server")
|
||||||
|
Log.e(TAG, "Repository returned null response")
|
||||||
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
_errorMessage.postValue(e.message ?: "Unexpected error")
|
_errorMessage.postValue(e.message ?: "Unexpected error")
|
||||||
|
Log.e(TAG, "Exception updating store profile", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,13 +132,13 @@ class MyStoreViewModel(private val repository: MyStoreRepository): ViewModel() {
|
|||||||
result.data.orders.size ?: 0
|
result.data.orders.size ?: 0
|
||||||
}
|
}
|
||||||
is Result.Error -> {
|
is Result.Error -> {
|
||||||
Log.e("SellsViewModel", "Error getting orders count: ${result.exception.message}")
|
Log.e(TAG, "Error getting orders count: ${result.exception.message}")
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
is Result.Loading -> 0
|
is Result.Loading -> 0
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("SellsViewModel", "Exception getting orders count", e)
|
Log.e(TAG, "Exception getting orders count", e)
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,7 +150,7 @@ class MyStoreViewModel(private val repository: MyStoreRepository): ViewModel() {
|
|||||||
|
|
||||||
statuses.forEach { status ->
|
statuses.forEach { status ->
|
||||||
counts[status] = getTotalOrdersByStatus(status)
|
counts[status] = getTotalOrdersByStatus(status)
|
||||||
Log.d("SellsViewModel", "Status: $status, countOrder=${counts[status]}")
|
Log.d(TAG, "Status: $status, countOrder=${counts[status]}")
|
||||||
}
|
}
|
||||||
|
|
||||||
return counts
|
return counts
|
||||||
|
|||||||
@ -30,6 +30,9 @@ class PaymentInfoViewModel(private val repository: PaymentInfoRepository) : View
|
|||||||
private val _deletePaymentSuccess = MutableLiveData<Boolean>()
|
private val _deletePaymentSuccess = MutableLiveData<Boolean>()
|
||||||
val deletePaymentSuccess: LiveData<Boolean> = _deletePaymentSuccess
|
val deletePaymentSuccess: LiveData<Boolean> = _deletePaymentSuccess
|
||||||
|
|
||||||
|
var selectedBankName: String? = null
|
||||||
|
val bankName = MutableLiveData<String>()
|
||||||
|
|
||||||
fun getPaymentInfo() {
|
fun getPaymentInfo() {
|
||||||
_isLoading.value = true
|
_isLoading.value = true
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import androidx.lifecycle.ViewModel
|
|||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.alya.ecommerce_serang.data.api.dto.CreateAddressRequest
|
import com.alya.ecommerce_serang.data.api.dto.CreateAddressRequest
|
||||||
import com.alya.ecommerce_serang.data.api.dto.RegisterRequest
|
import com.alya.ecommerce_serang.data.api.dto.RegisterRequest
|
||||||
|
import com.alya.ecommerce_serang.data.api.dto.ResetPassReq
|
||||||
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.LoginResponse
|
import com.alya.ecommerce_serang.data.api.response.auth.LoginResponse
|
||||||
import com.alya.ecommerce_serang.data.api.response.auth.OtpResponse
|
import com.alya.ecommerce_serang.data.api.response.auth.OtpResponse
|
||||||
@ -71,6 +72,7 @@ class RegisterViewModel(private val repository: UserRepository, private val orde
|
|||||||
var selectedProvinceId: Int? = null
|
var selectedProvinceId: Int? = null
|
||||||
var selectedCityId: String? = null
|
var selectedCityId: String? = null
|
||||||
var selectedSubdistrict: String? = null
|
var selectedSubdistrict: String? = null
|
||||||
|
var subdistrictName: String? = null
|
||||||
var selectedVillages: String? = null
|
var selectedVillages: String? = null
|
||||||
var selectedPostalCode: String? = null
|
var selectedPostalCode: String? = null
|
||||||
|
|
||||||
@ -382,6 +384,10 @@ class RegisterViewModel(private val repository: UserRepository, private val orde
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun resetPass(request: ResetPassReq){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "RegisterViewModel"
|
private const val TAG = "RegisterViewModel"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
tools:context=".ui.profile.mystore.profile.address.DetailStoreAddressActivity">
|
tools:context=".ui.profile.mystore.profile.address.DetailStoreAddressActivity">
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/header"
|
android:id="@+id/header_address_store"
|
||||||
layout="@layout/header" />
|
layout="@layout/header" />
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
@ -154,6 +154,58 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Kecamatan -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginBottom="24dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Kecamatan"
|
||||||
|
style="@style/body_medium"
|
||||||
|
android:layout_marginEnd="4dp"/>
|
||||||
|
|
||||||
|
<!-- Spinner Dropdown dengan Chevron -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:background="@drawable/bg_text_field"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:layout_marginTop="10dp">
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/spinner_subdistrict"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:padding="8dp"
|
||||||
|
style="@style/body_small"
|
||||||
|
android:background="@null"/>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/subdistrict_progress_bar"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
<!-- Chevron Down Icon -->
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="16dp"
|
||||||
|
android:layout_height="16dp"
|
||||||
|
android:src="@drawable/ic_down"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:contentDescription="Chevron Down" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
<!-- Jalan -->
|
<!-- Jalan -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -180,32 +232,6 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- Kecamatan -->
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_marginBottom="24dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Kecamatan"
|
|
||||||
style="@style/body_medium"
|
|
||||||
android:layout_marginEnd="4dp"/>
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/edt_subdistrict"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="@drawable/bg_text_field"
|
|
||||||
android:padding="8dp"
|
|
||||||
style="@style/body_small"
|
|
||||||
android:hint="Isi nama kecamatan di sini"
|
|
||||||
android:layout_marginTop="10dp"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<!-- Kode Pos -->
|
<!-- Kode Pos -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -301,7 +327,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_marginEnd="8dp">
|
android:layout_marginEnd="8dp"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -327,7 +354,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_marginStart="8dp">
|
android:layout_marginStart="8dp"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|||||||
@ -98,7 +98,7 @@
|
|||||||
android:textAlignment="textEnd"
|
android:textAlignment="textEnd"
|
||||||
android:textColor="@android:color/holo_red_light"
|
android:textColor="@android:color/holo_red_light"
|
||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="16dp"
|
||||||
android:visibility="gone"
|
android:layout_marginTop="8dp"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/til_login_password" />
|
app:layout_constraintTop_toBottomOf="@id/til_login_password" />
|
||||||
|
|||||||
47
app/src/main/res/layout/activity_reset_pass.xml
Normal file
47
app/src/main/res/layout/activity_reset_pass.xml
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:gravity="top">
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/header_reset_pass"
|
||||||
|
layout="@layout/header" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Masukkan alamat email anda. Periksa email anda untuk mendapatkan password baru"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:layout_marginVertical="24dp"/>
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="16dp">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/et_email"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="Co: 123@gmail.com"
|
||||||
|
android:inputType="textEmailAddress" />
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_reset"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Kirim Password Baru"
|
||||||
|
android:layout_marginBottom="16dp" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progress_bar"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@ -14,18 +14,39 @@
|
|||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:layout_marginBottom="16dp" />
|
android:layout_marginBottom="16dp" />
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="8dp"
|
android:orientation="horizontal"
|
||||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
|
android:background="@drawable/bg_text_field"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:layout_marginTop="10dp">
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
<Spinner
|
||||||
android:id="@+id/edt_bank_name"
|
android:id="@+id/spinner_bank_name"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="Nama Bank" />
|
android:layout_weight="1"
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
android:padding="8dp"
|
||||||
|
style="@style/body_small"
|
||||||
|
android:background="@null"/>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/bank_name_progress_bar"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:padding="4dp"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
<!-- Chevron Down Icon -->
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="16dp"
|
||||||
|
android:layout_height="16dp"
|
||||||
|
android:src="@drawable/ic_down"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:contentDescription="Chevron Down" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@ -245,6 +245,19 @@
|
|||||||
android:textColor="@color/blue1"
|
android:textColor="@color/blue1"
|
||||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"/>
|
style="@style/Widget.MaterialComponents.Button.OutlinedButton"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/checkbox_approve"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Saya telah membaca dan menyetujui Syarat dan Ketentuan aplikasi" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<!-- Register Button -->
|
<!-- Register Button -->
|
||||||
|
|||||||
@ -37,6 +37,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:src="@drawable/baseline_edit_24"
|
android:src="@drawable/baseline_edit_24"
|
||||||
android:layout_marginHorizontal="16dp"
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:visibility="gone"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"/>
|
app:layout_constraintTop_toTopOf="parent"/>
|
||||||
<TextView
|
<TextView
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
[versions]
|
[versions]
|
||||||
agp = "8.12.0"
|
agp = "8.9.2"
|
||||||
glide = "4.16.0"
|
glide = "4.16.0"
|
||||||
gson = "2.11.0"
|
gson = "2.11.0"
|
||||||
hiltAndroid = "2.56.2" # Updated from 2.44 for better compatibility
|
hiltAndroid = "2.56.2" # Updated from 2.44 for better compatibility
|
||||||
|
|||||||
Reference in New Issue
Block a user