mirror of
https://github.com/shaulascr/ecommerce_serang.git
synced 2025-08-13 10:42:21 +00:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # app/build.gradle.kts
This commit is contained in:
@ -17,6 +17,18 @@
|
|||||||
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.profile.mystore.profile.payment_info.DetailPaymentInfoActivity"
|
||||||
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name=".ui.profile.mystore.profile.payment_info.PaymentInfoActivity"
|
||||||
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name=".ui.profile.mystore.profile.address.StoreAddressActivity"
|
||||||
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name=".ui.profile.mystore.product.ProductActivity"
|
||||||
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.product.ReviewProductActivity"
|
android:name=".ui.product.ReviewProductActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
@ -39,10 +51,10 @@
|
|||||||
android:name=".ui.profile.mystore.product.AddProductActivity"
|
android:name=".ui.profile.mystore.product.AddProductActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.profile.mystore.profile.EditStoreProfileActivity"
|
android:name=".ui.profile.mystore.profile.DetailStoreProfileActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.profile.mystore.TokoSayaActivity"
|
android:name=".ui.profile.mystore.MyStoreActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.product.DetailProductActivity"
|
android:name=".ui.product.DetailProductActivity"
|
||||||
@ -64,7 +76,7 @@
|
|||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.MainActivity"
|
android:name=".ui.MainActivity"
|
||||||
android:exported="false"></activity>
|
android:exported="false" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -0,0 +1,102 @@
|
|||||||
|
package com.alya.ecommerce_serang.data.api.dto
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
|
data class Store(
|
||||||
|
|
||||||
|
@field:SerializedName("approval_reason")
|
||||||
|
val approvalReason: String,
|
||||||
|
|
||||||
|
@field:SerializedName("store_status")
|
||||||
|
val storeStatus: String,
|
||||||
|
|
||||||
|
@field:SerializedName("sppirt")
|
||||||
|
val sppirt: String,
|
||||||
|
|
||||||
|
@field:SerializedName("user_name")
|
||||||
|
val userName: String,
|
||||||
|
|
||||||
|
@field:SerializedName("nib")
|
||||||
|
val nib: String,
|
||||||
|
|
||||||
|
@field:SerializedName("latitude")
|
||||||
|
val latitude: String,
|
||||||
|
|
||||||
|
@field:SerializedName("store_type_id")
|
||||||
|
val storeTypeId: Int,
|
||||||
|
|
||||||
|
@field:SerializedName("balance")
|
||||||
|
val balance: String,
|
||||||
|
|
||||||
|
@field:SerializedName("street")
|
||||||
|
val street: String,
|
||||||
|
|
||||||
|
@field:SerializedName("store_name")
|
||||||
|
val storeName: String,
|
||||||
|
|
||||||
|
@field:SerializedName("user_phone")
|
||||||
|
val userPhone: String,
|
||||||
|
|
||||||
|
@field:SerializedName("halal")
|
||||||
|
val halal: String,
|
||||||
|
|
||||||
|
@field:SerializedName("id")
|
||||||
|
val id: Int,
|
||||||
|
|
||||||
|
@field:SerializedName("email")
|
||||||
|
val email: String,
|
||||||
|
|
||||||
|
@field:SerializedName("store_image")
|
||||||
|
val storeImage: Any,
|
||||||
|
|
||||||
|
@field:SerializedName("longitude")
|
||||||
|
val longitude: String,
|
||||||
|
|
||||||
|
@field:SerializedName("store_id")
|
||||||
|
val storeId: Int,
|
||||||
|
|
||||||
|
@field:SerializedName("is_store_location")
|
||||||
|
val isStoreLocation: Boolean,
|
||||||
|
|
||||||
|
@field:SerializedName("ktp")
|
||||||
|
val ktp: String,
|
||||||
|
|
||||||
|
@field:SerializedName("approval_status")
|
||||||
|
val approvalStatus: String,
|
||||||
|
|
||||||
|
@field:SerializedName("npwp")
|
||||||
|
val npwp: String,
|
||||||
|
|
||||||
|
@field:SerializedName("store_type")
|
||||||
|
val storeType: String,
|
||||||
|
|
||||||
|
@field:SerializedName("is_on_leave")
|
||||||
|
val isOnLeave: Boolean,
|
||||||
|
|
||||||
|
@field:SerializedName("user_id")
|
||||||
|
val userId: Int,
|
||||||
|
|
||||||
|
@field:SerializedName("province_id")
|
||||||
|
val provinceId: Int,
|
||||||
|
|
||||||
|
@field:SerializedName("phone")
|
||||||
|
val phone: String,
|
||||||
|
|
||||||
|
@field:SerializedName("subdistrict")
|
||||||
|
val subdistrict: String,
|
||||||
|
|
||||||
|
@field:SerializedName("recipient")
|
||||||
|
val recipient: String,
|
||||||
|
|
||||||
|
@field:SerializedName("detail")
|
||||||
|
val detail: String,
|
||||||
|
|
||||||
|
@field:SerializedName("postal_code")
|
||||||
|
val postalCode: String,
|
||||||
|
|
||||||
|
@field:SerializedName("store_description")
|
||||||
|
val storeDescription: String,
|
||||||
|
|
||||||
|
@field:SerializedName("city_id")
|
||||||
|
val cityId: Int
|
||||||
|
)
|
@ -1,5 +1,6 @@
|
|||||||
package com.alya.ecommerce_serang.data.api.response
|
package com.alya.ecommerce_serang.data.api.response
|
||||||
|
|
||||||
|
import com.alya.ecommerce_serang.data.api.dto.Store
|
||||||
import com.google.gson.annotations.SerializedName
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
data class StoreResponse(
|
data class StoreResponse(
|
||||||
@ -17,105 +18,6 @@ data class StoreResponse(
|
|||||||
val message: String
|
val message: String
|
||||||
)
|
)
|
||||||
|
|
||||||
data class Store(
|
|
||||||
|
|
||||||
@field:SerializedName("approval_reason")
|
|
||||||
val approvalReason: String,
|
|
||||||
|
|
||||||
@field:SerializedName("store_status")
|
|
||||||
val storeStatus: String,
|
|
||||||
|
|
||||||
@field:SerializedName("sppirt")
|
|
||||||
val sppirt: String,
|
|
||||||
|
|
||||||
@field:SerializedName("user_name")
|
|
||||||
val userName: String,
|
|
||||||
|
|
||||||
@field:SerializedName("nib")
|
|
||||||
val nib: String,
|
|
||||||
|
|
||||||
@field:SerializedName("latitude")
|
|
||||||
val latitude: String,
|
|
||||||
|
|
||||||
@field:SerializedName("store_type_id")
|
|
||||||
val storeTypeId: Int,
|
|
||||||
|
|
||||||
@field:SerializedName("balance")
|
|
||||||
val balance: String,
|
|
||||||
|
|
||||||
@field:SerializedName("street")
|
|
||||||
val street: String,
|
|
||||||
|
|
||||||
@field:SerializedName("store_name")
|
|
||||||
val storeName: String,
|
|
||||||
|
|
||||||
@field:SerializedName("user_phone")
|
|
||||||
val userPhone: String,
|
|
||||||
|
|
||||||
@field:SerializedName("halal")
|
|
||||||
val halal: String,
|
|
||||||
|
|
||||||
@field:SerializedName("id")
|
|
||||||
val id: Int,
|
|
||||||
|
|
||||||
@field:SerializedName("email")
|
|
||||||
val email: String,
|
|
||||||
|
|
||||||
@field:SerializedName("store_image")
|
|
||||||
val storeImage: Any,
|
|
||||||
|
|
||||||
@field:SerializedName("longitude")
|
|
||||||
val longitude: String,
|
|
||||||
|
|
||||||
@field:SerializedName("store_id")
|
|
||||||
val storeId: Int,
|
|
||||||
|
|
||||||
@field:SerializedName("is_store_location")
|
|
||||||
val isStoreLocation: Boolean,
|
|
||||||
|
|
||||||
@field:SerializedName("ktp")
|
|
||||||
val ktp: String,
|
|
||||||
|
|
||||||
@field:SerializedName("approval_status")
|
|
||||||
val approvalStatus: String,
|
|
||||||
|
|
||||||
@field:SerializedName("npwp")
|
|
||||||
val npwp: String,
|
|
||||||
|
|
||||||
@field:SerializedName("store_type")
|
|
||||||
val storeType: String,
|
|
||||||
|
|
||||||
@field:SerializedName("is_on_leave")
|
|
||||||
val isOnLeave: Boolean,
|
|
||||||
|
|
||||||
@field:SerializedName("user_id")
|
|
||||||
val userId: Int,
|
|
||||||
|
|
||||||
@field:SerializedName("province_id")
|
|
||||||
val provinceId: Int,
|
|
||||||
|
|
||||||
@field:SerializedName("phone")
|
|
||||||
val phone: String,
|
|
||||||
|
|
||||||
@field:SerializedName("subdistrict")
|
|
||||||
val subdistrict: String,
|
|
||||||
|
|
||||||
@field:SerializedName("recipient")
|
|
||||||
val recipient: String,
|
|
||||||
|
|
||||||
@field:SerializedName("detail")
|
|
||||||
val detail: String,
|
|
||||||
|
|
||||||
@field:SerializedName("postal_code")
|
|
||||||
val postalCode: String,
|
|
||||||
|
|
||||||
@field:SerializedName("store_description")
|
|
||||||
val storeDescription: String,
|
|
||||||
|
|
||||||
@field:SerializedName("city_id")
|
|
||||||
val cityId: Int
|
|
||||||
)
|
|
||||||
|
|
||||||
data class ShippingItem(
|
data class ShippingItem(
|
||||||
|
|
||||||
@field:SerializedName("courier")
|
@field:SerializedName("courier")
|
||||||
|
@ -63,5 +63,5 @@ interface ApiService {
|
|||||||
|
|
||||||
|
|
||||||
@GET("mystore")
|
@GET("mystore")
|
||||||
fun getStore (): Call<StoreResponse>
|
suspend fun getStore (): Response<StoreResponse>
|
||||||
}
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.alya.ecommerce_serang.data.repository
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
|
import com.alya.ecommerce_serang.data.api.dto.Store
|
||||||
|
import com.alya.ecommerce_serang.data.api.response.StoreResponse
|
||||||
|
import com.alya.ecommerce_serang.data.api.retrofit.ApiService
|
||||||
|
import retrofit2.HttpException
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
|
class MyStoreRepository(private val apiService: ApiService) {
|
||||||
|
suspend fun fetchMyStoreProfile(): Result<Store?> {
|
||||||
|
return try {
|
||||||
|
val response = apiService.getStore()
|
||||||
|
|
||||||
|
if (response.isSuccessful) {
|
||||||
|
val storeResponse: StoreResponse? = response.body()
|
||||||
|
Result.Success(storeResponse?.store) // ✅ Return Success with Store data
|
||||||
|
} else {
|
||||||
|
val errorMessage = response.errorBody()?.string() ?: "Unknown API error"
|
||||||
|
Log.e("MyStoreRepository", "Error: $errorMessage")
|
||||||
|
Result.Error(HttpException(response)) // ✅ Wrap API error in Result.Error
|
||||||
|
}
|
||||||
|
} catch (e: IOException) {
|
||||||
|
Log.e("MyStoreRepository", "Network error: ${e.message}")
|
||||||
|
Result.Error(e) // ✅ Handle network-related errors
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("MyStoreRepository", "Unexpected error: ${e.message}")
|
||||||
|
Result.Error(e) // ✅ Handle unexpected errors
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,9 +4,9 @@ import androidx.lifecycle.LiveData
|
|||||||
import androidx.lifecycle.MutableLiveData
|
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.Store
|
||||||
import com.alya.ecommerce_serang.data.api.response.Product
|
import com.alya.ecommerce_serang.data.api.response.Product
|
||||||
import com.alya.ecommerce_serang.data.api.response.ReviewsItem
|
import com.alya.ecommerce_serang.data.api.response.ReviewsItem
|
||||||
import com.alya.ecommerce_serang.data.api.response.Store
|
|
||||||
import com.alya.ecommerce_serang.data.repository.ProductRepository
|
import com.alya.ecommerce_serang.data.repository.ProductRepository
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import com.alya.ecommerce_serang.data.api.dto.UserProfile
|
|||||||
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.UserRepository
|
import com.alya.ecommerce_serang.data.repository.UserRepository
|
||||||
import com.alya.ecommerce_serang.databinding.FragmentProfileBinding
|
import com.alya.ecommerce_serang.databinding.FragmentProfileBinding
|
||||||
import com.alya.ecommerce_serang.ui.profile.mystore.TokoSayaActivity
|
import com.alya.ecommerce_serang.ui.profile.mystore.MyStoreActivity
|
||||||
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.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
@ -54,7 +54,7 @@ class ProfileFragment : Fragment() {
|
|||||||
viewModel.loadUserProfile()
|
viewModel.loadUserProfile()
|
||||||
|
|
||||||
binding.cardBukaToko.setOnClickListener{
|
binding.cardBukaToko.setOnClickListener{
|
||||||
val intentBuka = Intent(requireContext(), TokoSayaActivity::class.java)
|
val intentBuka = Intent(requireContext(), MyStoreActivity::class.java)
|
||||||
startActivity(intentBuka)
|
startActivity(intentBuka)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,131 @@
|
|||||||
|
package com.alya.ecommerce_serang.ui.profile.mystore
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.activity.enableEdgeToEdge
|
||||||
|
import androidx.activity.viewModels
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import com.alya.ecommerce_serang.data.api.dto.Store
|
||||||
|
import com.alya.ecommerce_serang.data.api.retrofit.ApiConfig
|
||||||
|
import com.alya.ecommerce_serang.data.api.retrofit.ApiService
|
||||||
|
import com.alya.ecommerce_serang.data.repository.MyStoreRepository
|
||||||
|
import com.alya.ecommerce_serang.databinding.ActivityMyStoreBinding
|
||||||
|
import com.alya.ecommerce_serang.ui.chat.ChatFragment
|
||||||
|
import com.alya.ecommerce_serang.ui.profile.mystore.balance.BalanceActivity
|
||||||
|
import com.alya.ecommerce_serang.ui.profile.mystore.product.ProductActivity
|
||||||
|
import com.alya.ecommerce_serang.ui.profile.mystore.profile.DetailStoreProfileActivity
|
||||||
|
import com.alya.ecommerce_serang.ui.profile.mystore.review.ReviewFragment
|
||||||
|
import com.alya.ecommerce_serang.ui.profile.mystore.sells.all_sells.AllSellsFragment
|
||||||
|
import com.alya.ecommerce_serang.ui.profile.mystore.sells.order.OrderFragment
|
||||||
|
import com.alya.ecommerce_serang.ui.profile.mystore.sells.payment.PaymentFragment
|
||||||
|
import com.alya.ecommerce_serang.ui.profile.mystore.sells.shipment.ShipmentFragment
|
||||||
|
import com.alya.ecommerce_serang.utils.BaseViewModelFactory
|
||||||
|
import com.alya.ecommerce_serang.utils.SessionManager
|
||||||
|
import com.bumptech.glide.Glide
|
||||||
|
import kotlin.getValue
|
||||||
|
|
||||||
|
class MyStoreActivity : AppCompatActivity() {
|
||||||
|
private lateinit var binding: ActivityMyStoreBinding
|
||||||
|
private lateinit var apiService: ApiService
|
||||||
|
private lateinit var sessionManager: SessionManager
|
||||||
|
|
||||||
|
private val viewModel: MyStoreViewModel by viewModels {
|
||||||
|
BaseViewModelFactory {
|
||||||
|
val apiService = ApiConfig.getApiService(sessionManager)
|
||||||
|
val myStoreRepository = MyStoreRepository(apiService)
|
||||||
|
MyStoreViewModel(myStoreRepository)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
binding = ActivityMyStoreBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
|
|
||||||
|
sessionManager = SessionManager(this)
|
||||||
|
apiService = ApiConfig.getApiService(sessionManager)
|
||||||
|
|
||||||
|
enableEdgeToEdge()
|
||||||
|
|
||||||
|
viewModel.loadMyStore()
|
||||||
|
|
||||||
|
viewModel.myStoreProfile.observe(this){ user ->
|
||||||
|
user?.let { myStoreProfileOverview(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
viewModel.errorMessage.observe(this) { error ->
|
||||||
|
Toast.makeText(this, error, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
setUpClickListeners()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun myStoreProfileOverview(store: Store){
|
||||||
|
|
||||||
|
binding.tvStoreName.setText(store.storeName.toString())
|
||||||
|
binding.tvStoreType.setText(store.storeType.toString())
|
||||||
|
|
||||||
|
store.storeImage.let {
|
||||||
|
Glide.with(this)
|
||||||
|
.load(it)
|
||||||
|
.into(binding.ivProfile)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpClickListeners() {
|
||||||
|
binding.btnEditProfile.setOnClickListener {
|
||||||
|
startActivity(Intent(this, DetailStoreProfileActivity::class.java))
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.layoutBalance.setOnClickListener {
|
||||||
|
startActivity(Intent(this, BalanceActivity::class.java))
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.tvHistory.setOnClickListener {
|
||||||
|
supportFragmentManager.beginTransaction()
|
||||||
|
.replace(android.R.id.content, AllSellsFragment())
|
||||||
|
.addToBackStack(null)
|
||||||
|
.commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.layoutPerluTagihan.setOnClickListener {
|
||||||
|
supportFragmentManager.beginTransaction()
|
||||||
|
.replace(android.R.id.content, OrderFragment())
|
||||||
|
.addToBackStack(null)
|
||||||
|
.commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.layoutPembayaran.setOnClickListener {
|
||||||
|
supportFragmentManager.beginTransaction()
|
||||||
|
.replace(android.R.id.content, PaymentFragment())
|
||||||
|
.addToBackStack(null)
|
||||||
|
.commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.layoutPerluDikirim.setOnClickListener {
|
||||||
|
supportFragmentManager.beginTransaction()
|
||||||
|
.replace(android.R.id.content, ShipmentFragment())
|
||||||
|
.addToBackStack(null)
|
||||||
|
.commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.layoutProductMenu.setOnClickListener {
|
||||||
|
startActivity(Intent(this, ProductActivity::class.java))
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.layoutReview.setOnClickListener {
|
||||||
|
supportFragmentManager.beginTransaction()
|
||||||
|
.replace(android.R.id.content, ReviewFragment())
|
||||||
|
.addToBackStack(null)
|
||||||
|
.commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.layoutInbox.setOnClickListener {
|
||||||
|
supportFragmentManager.beginTransaction()
|
||||||
|
.replace(android.R.id.content, ChatFragment())
|
||||||
|
.addToBackStack(null)
|
||||||
|
.commit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.alya.ecommerce_serang.ui.profile.mystore
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import com.alya.ecommerce_serang.data.api.dto.Store
|
||||||
|
import com.alya.ecommerce_serang.data.repository.MyStoreRepository
|
||||||
|
import com.alya.ecommerce_serang.data.repository.Result
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
class MyStoreViewModel(private val myStoreRepository: MyStoreRepository): ViewModel() {
|
||||||
|
private val _myStoreProfile = MutableLiveData<Store?>()
|
||||||
|
val myStoreProfile: LiveData<Store?> = _myStoreProfile
|
||||||
|
|
||||||
|
private val _errorMessage = MutableLiveData<String>()
|
||||||
|
val errorMessage : LiveData<String> = _errorMessage
|
||||||
|
|
||||||
|
fun loadMyStore(){
|
||||||
|
viewModelScope.launch {
|
||||||
|
when (val result = myStoreRepository.fetchMyStoreProfile()){
|
||||||
|
is Result.Success -> _myStoreProfile.postValue(result.data)
|
||||||
|
is Result.Error -> _errorMessage.postValue(result.exception.message ?: "Unknown Error")
|
||||||
|
is Result.Loading -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.alya.ecommerce_serang.ui.profile.mystore
|
package com.alya.ecommerce_serang.ui.profile.mystore.product
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.activity.enableEdgeToEdge
|
import androidx.activity.enableEdgeToEdge
|
||||||
@ -7,11 +7,11 @@ import androidx.core.view.ViewCompat
|
|||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import com.alya.ecommerce_serang.R
|
import com.alya.ecommerce_serang.R
|
||||||
|
|
||||||
class TokoSayaActivity : AppCompatActivity() {
|
class ProductActivity : AppCompatActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
setContentView(R.layout.activity_toko_saya)
|
setContentView(R.layout.activity_product)
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
|
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
|
||||||
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
@ -0,0 +1,60 @@
|
|||||||
|
package com.alya.ecommerce_serang.ui.profile.mystore.profile
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.activity.enableEdgeToEdge
|
||||||
|
import androidx.activity.viewModels
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import com.alya.ecommerce_serang.data.api.dto.Store
|
||||||
|
import com.alya.ecommerce_serang.data.api.retrofit.ApiConfig
|
||||||
|
import com.alya.ecommerce_serang.data.api.retrofit.ApiService
|
||||||
|
import com.alya.ecommerce_serang.data.repository.MyStoreRepository
|
||||||
|
import com.alya.ecommerce_serang.databinding.ActivityDetailStoreProfileBinding
|
||||||
|
import com.alya.ecommerce_serang.ui.profile.mystore.MyStoreViewModel
|
||||||
|
import com.alya.ecommerce_serang.utils.BaseViewModelFactory
|
||||||
|
import com.alya.ecommerce_serang.utils.SessionManager
|
||||||
|
import com.bumptech.glide.Glide
|
||||||
|
import kotlin.getValue
|
||||||
|
|
||||||
|
class DetailStoreProfileActivity : AppCompatActivity() {
|
||||||
|
private lateinit var binding: ActivityDetailStoreProfileBinding
|
||||||
|
private lateinit var apiService: ApiService
|
||||||
|
private lateinit var sessionManager: SessionManager
|
||||||
|
|
||||||
|
private val viewModel: MyStoreViewModel by viewModels {
|
||||||
|
BaseViewModelFactory {
|
||||||
|
val apiService = ApiConfig.getApiService(sessionManager)
|
||||||
|
val myStoreRepository = MyStoreRepository(apiService)
|
||||||
|
MyStoreViewModel(myStoreRepository)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
binding = ActivityDetailStoreProfileBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
|
|
||||||
|
sessionManager = SessionManager(this)
|
||||||
|
apiService = ApiConfig.getApiService(sessionManager)
|
||||||
|
|
||||||
|
enableEdgeToEdge()
|
||||||
|
|
||||||
|
viewModel.loadMyStore()
|
||||||
|
|
||||||
|
viewModel.myStoreProfile.observe(this){ user ->
|
||||||
|
user?.let { updateStoreProfile(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
viewModel.errorMessage.observe(this) { error ->
|
||||||
|
Toast.makeText(this, error, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateStoreProfile(store: Store){
|
||||||
|
|
||||||
|
binding.edtNamaToko.setText(store.storeName.toString())
|
||||||
|
binding.edtJenisToko.setText(store.storeType.toString())
|
||||||
|
binding.edtDeskripsiToko.setText(store.storeDescription.toString())
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.alya.ecommerce_serang.ui.profile.mystore.profile
|
package com.alya.ecommerce_serang.ui.profile.mystore.profile.address
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.activity.enableEdgeToEdge
|
import androidx.activity.enableEdgeToEdge
|
||||||
@ -7,11 +7,11 @@ import androidx.core.view.ViewCompat
|
|||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import com.alya.ecommerce_serang.R
|
import com.alya.ecommerce_serang.R
|
||||||
|
|
||||||
class EditStoreProfileActivity : AppCompatActivity() {
|
class StoreAddressActivity : AppCompatActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
setContentView(R.layout.activity_edit_store_profile)
|
setContentView(R.layout.activity_store_address)
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
|
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
|
||||||
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.alya.ecommerce_serang.ui.profile.mystore.profile.payment_info
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.activity.enableEdgeToEdge
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
import com.alya.ecommerce_serang.R
|
||||||
|
|
||||||
|
class DetailPaymentInfoActivity : AppCompatActivity() {
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
enableEdgeToEdge()
|
||||||
|
setContentView(R.layout.activity_detail_payment_info)
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
|
||||||
|
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
||||||
|
insets
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.alya.ecommerce_serang.ui.profile.mystore.profile.payment_info
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.activity.enableEdgeToEdge
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
import com.alya.ecommerce_serang.R
|
||||||
|
|
||||||
|
class PaymentInfoActivity : AppCompatActivity() {
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
enableEdgeToEdge()
|
||||||
|
setContentView(R.layout.activity_payment_info)
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
|
||||||
|
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
||||||
|
insets
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.alya.ecommerce_serang.ui.profile.mystore.profile.shipping_service
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.activity.enableEdgeToEdge
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
import com.alya.ecommerce_serang.R
|
||||||
|
|
||||||
|
class ShippingServiceActivity : AppCompatActivity() {
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
enableEdgeToEdge()
|
||||||
|
setContentView(R.layout.activity_shipping_service)
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
|
||||||
|
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
||||||
|
insets
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.alya.ecommerce_serang.ui.profile.mystore.review
|
||||||
|
|
||||||
|
import androidx.fragment.app.viewModels
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import com.alya.ecommerce_serang.R
|
||||||
|
|
||||||
|
class ReviewFragment : Fragment() {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance() = ReviewFragment()
|
||||||
|
}
|
||||||
|
|
||||||
|
private val viewModel: ReviewViewModel by viewModels()
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
// TODO: Use the ViewModel
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View {
|
||||||
|
return inflater.inflate(R.layout.fragment_review, container, false)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.alya.ecommerce_serang.ui.profile.mystore.review
|
||||||
|
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
|
||||||
|
class ReviewViewModel : ViewModel() {
|
||||||
|
// TODO: Implement the ViewModel
|
||||||
|
}
|
@ -1,50 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:id="@+id/main"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
tools:context=".ui.profile.mystore.TokoSayaActivity">
|
|
||||||
|
|
||||||
<include layout="@layout/header" />
|
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="1">
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:id="@+id/layout_profile"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="143dp"
|
|
||||||
android:paddingHorizontal="@dimen/horizontal_safe_area"
|
|
||||||
android:paddingVertical="@dimen/vertical_safe_area">
|
|
||||||
|
|
||||||
<com.google.android.material.imageview.ShapeableImageView
|
|
||||||
android:id="@+id/iv_profile"
|
|
||||||
android:layout_width="72dp"
|
|
||||||
android:layout_height="72dp"
|
|
||||||
android:src="@drawable/placeholder_image"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:shapeAppearanceOverlay="@style/circular_image"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tv_store_name"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Nama Toko"
|
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
style="@style/body_large"
|
|
||||||
android:textFontWeight="700"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:layout_constraintStart_toEndOf="@id/iv_profile"/>
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
11
app/src/main/res/layout/activity_detail_payment_info.xml
Normal file
11
app/src/main/res/layout/activity_detail_payment_info.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/main"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".ui.profile.mystore.profile.payment_info.DetailPaymentInfoActivity">
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -6,7 +6,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".ui.profile.mystore.profile.EditStoreProfileActivity">
|
tools:context=".ui.profile.mystore.profile.DetailStoreProfileActivity">
|
||||||
|
|
||||||
<include layout="@layout/header" />
|
<include layout="@layout/header" />
|
||||||
|
|
@ -6,7 +6,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".ui.profile.mystore.TokoSayaActivity">
|
tools:context=".ui.profile.mystore.MyStoreActivity">
|
||||||
|
|
||||||
<include layout="@layout/header" />
|
<include layout="@layout/header" />
|
||||||
|
|
10
app/src/main/res/layout/activity_payment_info.xml
Normal file
10
app/src/main/res/layout/activity_payment_info.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/main"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".ui.profile.mystore.profile.payment_info.PaymentInfoActivity">
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
10
app/src/main/res/layout/activity_product.xml
Normal file
10
app/src/main/res/layout/activity_product.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/main"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".ui.profile.mystore.product.ProductActivity">
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
10
app/src/main/res/layout/activity_shipping_service.xml
Normal file
10
app/src/main/res/layout/activity_shipping_service.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/main"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".ui.profile.mystore.profile.shipping_service.ShippingServiceActivity">
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
10
app/src/main/res/layout/activity_store_address.xml
Normal file
10
app/src/main/res/layout/activity_store_address.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/main"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".ui.profile.mystore.profile.address.StoreAddressActivity">
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
13
app/src/main/res/layout/fragment_review.xml
Normal file
13
app/src/main/res/layout/fragment_review.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".ui.profile.mystore.review.ReviewFragment">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="Hello" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
Reference in New Issue
Block a user