update sells

This commit is contained in:
Gracia
2025-04-24 01:21:37 +07:00
parent 181106eaf5
commit d8dda02d69
37 changed files with 652 additions and 276 deletions

View File

@ -0,0 +1,59 @@
package com.alya.ecommerce_serang.data.api.dto
import com.alya.ecommerce_serang.data.api.response.store.orders.Address
import com.alya.ecommerce_serang.data.api.response.store.orders.OrderItemsItem
import com.alya.ecommerce_serang.data.api.response.store.orders.Payment
import com.alya.ecommerce_serang.data.api.response.store.orders.Shipment
import com.alya.ecommerce_serang.data.api.response.store.orders.Voucher
import com.google.gson.annotations.SerializedName
data class OrdersItem(
@field:SerializedName("address")
val address: Address? = null,
@field:SerializedName("shipment")
val shipment: Shipment? = null,
@field:SerializedName("voucher")
val voucher: Voucher? = null,
@field:SerializedName("address_id")
val addressId: Int? = null,
@field:SerializedName("is_negotiable")
val isNegotiable: Boolean? = null,
@field:SerializedName("created_at")
val createdAt: String? = null,
@field:SerializedName("payment_method_id")
val paymentMethodId: Int? = null,
@field:SerializedName("updated_at")
val updatedAt: String? = null,
@field:SerializedName("user_id")
val userId: Int? = null,
@field:SerializedName("total_amount")
val totalAmount: String? = null,
@field:SerializedName("voucher_id")
val voucherId: Any? = null,
@field:SerializedName("payment")
val payment: Payment? = null,
@field:SerializedName("order_id")
val orderId: Int? = null,
@field:SerializedName("username")
val username: String? = null,
@field:SerializedName("status")
val status: String? = null,
@field:SerializedName("order_items")
val orderItems: List<OrderItemsItem?>? = null
)

View File

@ -0,0 +1,36 @@
package com.alya.ecommerce_serang.data.api.dto
import com.google.gson.annotations.SerializedName
data class UpdatedOrder(
@field:SerializedName("payment_method_id")
val paymentMethodId: Int? = null,
@field:SerializedName("updated_at")
val updatedAt: String? = null,
@field:SerializedName("total_amount")
val totalAmount: String? = null,
@field:SerializedName("user_id")
val userId: Int? = null,
@field:SerializedName("address_id")
val addressId: Int? = null,
@field:SerializedName("is_negotiable")
val isNegotiable: Boolean? = null,
@field:SerializedName("created_at")
val createdAt: String? = null,
@field:SerializedName("voucher_id")
val voucherId: Any? = null,
@field:SerializedName("id")
val id: Int? = null,
@field:SerializedName("status")
val status: String? = null
)

View File

@ -13,36 +13,3 @@ data class KonfirmasiTagihanResponse(
@field:SerializedName("updatedItems")
val updatedItems: List<Any?>? = null
)
data class UpdatedOrder(
@field:SerializedName("payment_method_id")
val paymentMethodId: Int? = null,
@field:SerializedName("updated_at")
val updatedAt: String? = null,
@field:SerializedName("total_amount")
val totalAmount: String? = null,
@field:SerializedName("user_id")
val userId: Int? = null,
@field:SerializedName("address_id")
val addressId: Int? = null,
@field:SerializedName("is_negotiable")
val isNegotiable: Boolean? = null,
@field:SerializedName("created_at")
val createdAt: String? = null,
@field:SerializedName("voucher_id")
val voucherId: Any? = null,
@field:SerializedName("id")
val id: Int? = null,
@field:SerializedName("status")
val status: String? = null
)

View File

@ -1,5 +1,6 @@
package com.alya.ecommerce_serang.data.api.response.store.orders
import com.alya.ecommerce_serang.data.api.dto.OrdersItem
import com.google.gson.annotations.SerializedName
data class OrderListResponse(
@ -115,54 +116,3 @@ data class Payment(
@field:SerializedName("payment_id")
val paymentId: Any? = null
)
data class OrdersItem(
@field:SerializedName("address")
val address: Address? = null,
@field:SerializedName("shipment")
val shipment: Shipment? = null,
@field:SerializedName("voucher")
val voucher: Voucher? = null,
@field:SerializedName("address_id")
val addressId: Int? = null,
@field:SerializedName("is_negotiable")
val isNegotiable: Boolean? = null,
@field:SerializedName("created_at")
val createdAt: String? = null,
@field:SerializedName("payment_method_id")
val paymentMethodId: Int? = null,
@field:SerializedName("updated_at")
val updatedAt: String? = null,
@field:SerializedName("user_id")
val userId: Int? = null,
@field:SerializedName("total_amount")
val totalAmount: String? = null,
@field:SerializedName("voucher_id")
val voucherId: Any? = null,
@field:SerializedName("payment")
val payment: Payment? = null,
@field:SerializedName("order_id")
val orderId: Int? = null,
@field:SerializedName("username")
val username: String? = null,
@field:SerializedName("status")
val status: String? = null,
@field:SerializedName("order_items")
val orderItems: List<OrderItemsItem?>? = null
)

View File

@ -32,6 +32,7 @@ import com.alya.ecommerce_serang.data.api.response.customer.product.StoreRespons
import com.alya.ecommerce_serang.data.api.response.customer.profile.AddressResponse
import com.alya.ecommerce_serang.data.api.response.customer.profile.CreateAddressResponse
import com.alya.ecommerce_serang.data.api.response.customer.profile.ProfileResponse
import com.alya.ecommerce_serang.data.api.response.store.orders.OrderListResponse
import com.alya.ecommerce_serang.data.api.response.store.product.DeleteProductResponse
import com.alya.ecommerce_serang.data.api.response.store.product.UpdateProductResponse
import retrofit2.Call
@ -171,4 +172,12 @@ interface ApiService {
@GET("provinces")
suspend fun getListProv(
): Response<ListProvinceResponse>
@GET("mystore/orders")
suspend fun getAllOrders(): Response<OrderListResponse>
@GET("mystore/orders/{status}")
suspend fun getOrdersByStatus(
@Query("status") status: String
): Response<OrderListResponse>
}

View File

@ -5,6 +5,8 @@ import com.alya.ecommerce_serang.data.api.dto.CourierCostRequest
import com.alya.ecommerce_serang.data.api.dto.CreateAddressRequest
import com.alya.ecommerce_serang.data.api.dto.OrderRequest
import com.alya.ecommerce_serang.data.api.dto.OrderRequestBuy
import com.alya.ecommerce_serang.data.api.dto.OrdersItem
import com.alya.ecommerce_serang.data.api.dto.ProductsItem
import com.alya.ecommerce_serang.data.api.response.customer.cart.DataItem
import com.alya.ecommerce_serang.data.api.response.customer.order.CourierCostResponse
import com.alya.ecommerce_serang.data.api.response.customer.order.CreateOrderResponse
@ -207,4 +209,33 @@ class OrderRepository(private val apiService: ApiService) {
return if (response.isSuccessful) response.body() else null
}
suspend fun fetchSells(): List<OrdersItem?> {
return try {
val response = apiService.getAllOrders() // Replace with the actual method from your ApiService
if (response.isSuccessful) {
response.body()?.orders ?: emptyList() // Assuming the response body has 'orders'
} else {
Log.e("OrderRepository", "Error fetching all sells. Code: ${response.code()}")
emptyList()
}
} catch (e: Exception) {
Log.e("OrderRepository", "Exception fetching sells", e)
emptyList()
}
}
suspend fun fetchOrdersByStatus(status: String): List<OrdersItem?> {
return try {
val response = apiService.getOrdersByStatus(status) // Replace with actual method for status-based fetch
if (response.isSuccessful) {
response.body()?.orders?.filterNotNull() ?: emptyList() // Assuming the response body has 'orders'
} else {
Log.e("OrderRepository", "Error fetching orders by status ($status). Code: ${response.code()}")
emptyList()
}
} catch (e: Exception) {
Log.e("OrderRepository", "Exception fetching orders by status", e)
emptyList()
}
}
}

View File

@ -64,8 +64,8 @@ class MyStoreActivity : AppCompatActivity() {
private fun myStoreProfileOverview(store: Store){
binding.tvStoreName.setText(store.storeName.toString())
binding.tvStoreType.setText(store.storeType.toString())
binding.tvStoreName.text = store.storeName
binding.tvStoreType.text = store.storeType
store.storeImage.let {
Glide.with(this)

View File

@ -169,30 +169,30 @@ class StoreProductDetailActivity : AppCompatActivity() {
}
}
private fun populateForm(product: Product) {
binding.edtNamaProduk.setText(product.name)
binding.edtDeskripsiProduk.setText(product.description)
binding.edtHargaProduk.setText(product.price.toString())
binding.edtStokProduk.setText(product.stock.toString())
binding.edtMinOrder.setText(product.minOrder.toString())
binding.edtBeratProduk.setText(product.weight.toString())
binding.switchIsPreOrder.isChecked = product.isPreOrder ?: false
binding.switchIsActive.isChecked = product.status == "active"
binding.spinnerKondisiProduk.setSelection(if (product.condition == "Baru") 0 else 1)
private fun populateForm(product: Product?) {
binding.edtNamaProduk.setText(product?.name)
binding.edtDeskripsiProduk.setText(product?.description)
binding.edtHargaProduk.setText(product?.price.toString())
binding.edtStokProduk.setText(product?.stock.toString())
binding.edtMinOrder.setText(product?.minOrder.toString())
binding.edtBeratProduk.setText(product?.weight.toString())
binding.switchIsPreOrder.isChecked = product?.isPreOrder ?: false
binding.switchIsActive.isChecked = product?.status == "active"
binding.spinnerKondisiProduk.setSelection(if (product?.condition == "Baru") 0 else 1)
product.categoryId?.let {
product?.categoryId?.let {
binding.spinnerKategoriProduk.setSelection(categoryList.indexOfFirst { it.id == product.categoryId })
}
Glide.with(this).load(product.image).into(binding.ivPreviewFoto)
Glide.with(this).load(product?.image).into(binding.ivPreviewFoto)
binding.switcherFotoProduk.showNext()
product.sppirt?.let {
product?.sppirt?.let {
binding.tvSppirtName.text = getFileName(it.toUri())
binding.switcherSppirt.showNext()
}
product.halal?.let {
product?.halal?.let {
binding.tvHalalName.text = getFileName(it.toUri())
binding.switcherHalal.showNext()
}

View File

@ -3,6 +3,7 @@ package com.alya.ecommerce_serang.ui.profile.mystore.sells
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.alya.ecommerce_serang.R
import com.alya.ecommerce_serang.ui.profile.mystore.sells.all_sells.AllSellsFragment
class SellsActivity : AppCompatActivity() {
@ -11,7 +12,7 @@ class SellsActivity : AppCompatActivity() {
setContentView(R.layout.activity_sells)
if (savedInstanceState == null) {
supportFragmentManager.beginTransaction()
.replace(R.id.sells_fragment_container, SellsFragment())
.replace(R.id.sells_fragment_container, AllSellsFragment())
.commit()
}
}

View File

@ -24,7 +24,7 @@ class SellsFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewModel = ViewModelProvider(this).get(SellsViewModel::class.java)
viewModel = ViewModelProvider(this)[SellsViewModel::class.java]
val tabs = listOf(
"Semua Pesanan", "Perlu Tagihan", "Konfirmasi Pembayaran",

View File

@ -6,7 +6,7 @@ import com.alya.ecommerce_serang.ui.profile.mystore.sells.all_sells.AllSellsFrag
import com.alya.ecommerce_serang.ui.profile.mystore.sells.cancellation.CancellationFragment
import com.alya.ecommerce_serang.ui.profile.mystore.sells.failed_payment.FailedPaymentFragment
import com.alya.ecommerce_serang.ui.profile.mystore.sells.failed_shipment.FailedShipmentFragment
import com.alya.ecommerce_serang.ui.profile.mystore.sells.finished.FinishedFragment
import com.alya.ecommerce_serang.ui.profile.mystore.sells.completed.CompletedFragment
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
@ -24,7 +24,7 @@ class SellsPagerAdapter(fragment: Fragment, private val itemCount: Int) :
2 -> PaymentFragment()
3 -> ShipmentFragment()
4 -> ShippedFragment()
5 -> FinishedFragment()
5 -> CompletedFragment()
6 -> CancellationFragment()
7 -> FailedPaymentFragment()
8 -> FailedShipmentFragment()

View File

@ -5,14 +5,37 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.alya.ecommerce_serang.R
import com.alya.ecommerce_serang.databinding.FragmentAllSellsBinding
import com.alya.ecommerce_serang.utils.viewmodel.SellsViewModel
class AllSellsFragment : Fragment() {
private lateinit var viewModel: SellsViewModel
private lateinit var binding: FragmentAllSellsBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_all_sells, container, false)
binding = FragmentAllSellsBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewModel = ViewModelProvider(this).get(SellsViewModel::class.java)
// val adapter = SellsAdapter()
// binding.rvAllSells.layoutManager = LinearLayoutManager(context)
// binding.rvAllSells.adapter = adapter
//
// viewModel.loadAllSells()
// viewModel.sellsList.observe(viewLifecycleOwner, Observer { sells ->
// adapter.submitList(sells)
// })
}
}

View File

@ -5,14 +5,37 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.alya.ecommerce_serang.R
import com.alya.ecommerce_serang.databinding.FragmentCancellationBinding
import com.alya.ecommerce_serang.utils.viewmodel.SellsViewModel
class CancellationFragment : Fragment() {
private lateinit var viewModel: SellsViewModel
private lateinit var binding: FragmentCancellationBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_cancellation, container, false)
binding = FragmentCancellationBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewModel = ViewModelProvider(this).get(SellsViewModel::class.java)
// val adapter = SellsAdapter()
// binding.rvCancellation.layoutManager = LinearLayoutManager(context)
// binding.rvCancellation.adapter = adapter
//
// viewModel.loadOrdersByStatus("cancelled")
// viewModel.sellsList.observe(viewLifecycleOwner, Observer { cancellations ->
// adapter.submitList(cancellations)
// })
}
}

View File

@ -0,0 +1,41 @@
package com.alya.ecommerce_serang.ui.profile.mystore.sells.completed
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.alya.ecommerce_serang.R
import com.alya.ecommerce_serang.databinding.FragmentCompletedBinding
import com.alya.ecommerce_serang.utils.viewmodel.SellsViewModel
class CompletedFragment : Fragment() {
private lateinit var viewModel: SellsViewModel
private lateinit var binding: FragmentCompletedBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentCompletedBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewModel = ViewModelProvider(this).get(SellsViewModel::class.java)
// val adapter = SellsAdapter()
// binding.rvCompleted.layoutManager = LinearLayoutManager(context)
// binding.rvCompleted.adapter = adapter
//
// viewModel.loadOrdersByStatus("delivered")
// viewModel.sellsList.observe(viewLifecycleOwner, Observer { completed ->
// adapter.submitList(completed)
// })
}
}

View File

@ -6,14 +6,37 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.alya.ecommerce_serang.R
import com.alya.ecommerce_serang.databinding.FragmentFailedPaymentBinding
import com.alya.ecommerce_serang.utils.viewmodel.SellsViewModel
class FailedPaymentFragment : Fragment() {
private lateinit var viewModel: SellsViewModel
private lateinit var binding: FragmentFailedPaymentBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_failed_payment, container, false)
binding = FragmentFailedPaymentBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewModel = ViewModelProvider(this).get(SellsViewModel::class.java)
// val adapter = SellsAdapter()
// binding.rvFailedPayment.layoutManager = LinearLayoutManager(context)
// binding.rvFailedPayment.adapter = adapter
//
// viewModel.loadOrdersByStatus("failedPayment")
// viewModel.sellsList.observe(viewLifecycleOwner, Observer { failedPayments ->
// adapter.submitList(failedPayments)
// })
}
}

View File

@ -5,14 +5,37 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.alya.ecommerce_serang.R
import com.alya.ecommerce_serang.databinding.FragmentFailedShipmentBinding
import com.alya.ecommerce_serang.utils.viewmodel.SellsViewModel
class FailedShipmentFragment : Fragment() {
private lateinit var viewModel: SellsViewModel
private lateinit var binding: FragmentFailedShipmentBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_failed_shipment, container, false)
binding = FragmentFailedShipmentBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewModel = ViewModelProvider(this).get(SellsViewModel::class.java)
// val adapter = SellsAdapter()
// binding.rvFailedShipment.layoutManager = LinearLayoutManager(context)
// binding.rvFailedShipment.adapter = adapter
//
// viewModel.loadOrdersByStatus("failedShipment")
// viewModel.sellsList.observe(viewLifecycleOwner, Observer { failedShipments ->
// adapter.submitList(failedShipments)
// })
}
}

View File

@ -1,18 +0,0 @@
package com.alya.ecommerce_serang.ui.profile.mystore.sells.finished
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 FinishedFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_finished, container, false)
}
}

View File

@ -0,0 +1,60 @@
package com.alya.ecommerce_serang.ui.profile.mystore.sells.order
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.alya.ecommerce_serang.R
import com.alya.ecommerce_serang.data.api.dto.OrdersItem
class OrderAdapter : RecyclerView.Adapter<OrderAdapter.OrderViewHolder>() {
private var orderList: List<OrdersItem?>? = emptyList()
fun submitList(orders: List<OrdersItem?>?) {
orderList = orders
notifyDataSetChanged()
}
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): OrderViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_sells_order, parent, false)
return OrderViewHolder(view)
}
override fun onBindViewHolder(holder: OrderViewHolder, position: Int) {
val order = orderList?.get(position)
holder.bind(order)
}
override fun getItemCount(): Int = orderList?.size ?: 0
class OrderViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
private val tvOrderNumber: TextView = itemView.findViewById(R.id.tv_order_number)
private val tvOrderCustomer: TextView = itemView.findViewById(R.id.tv_order_customer)
private val tvOrderDue: TextView = itemView.findViewById(R.id.tv_order_due)
private val ivOrderProduct: ImageView = itemView.findViewById(R.id.iv_order_product)
private val tvOrderProductName: TextView = itemView.findViewById(R.id.tv_order_product_name)
private val tvOrderProductVariant: TextView = itemView.findViewById(R.id.tv_order_product_variant)
private val tvOrderProductQty: TextView = itemView.findViewById(R.id.tv_order_product_qty)
private val tvOrderProductPrice: TextView = itemView.findViewById(R.id.tv_order_product_price)
private val tvOrderQty: TextView = itemView.findViewById(R.id.tv_order_qty)
private val tvOrderPrice: TextView = itemView.findViewById(R.id.tv_order_price)
private val tvSeeMore: TextView = itemView.findViewById(R.id.tv_see_more)
private val btnEditOrder: Button = itemView.findViewById(R.id.btn_edit_order)
private val btnConfirmOrder: Button = itemView.findViewById(R.id.btn_confirm_order)
fun bind(order: OrdersItem?) {
tvOrderNumber.text = "No. Pesanan: ${order?.orderId}"
tvOrderCustomer.text = order?.username
tvOrderDue.text = order?.createdAt + 7
tvOrderQty.text = "${order?.orderItems?.size} produk"
tvOrderPrice.text = "Rp${order?.totalAmount}"
}
}
}

View File

@ -5,14 +5,36 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.alya.ecommerce_serang.R
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.alya.ecommerce_serang.databinding.FragmentOrderBinding
import com.alya.ecommerce_serang.utils.viewmodel.SellsViewModel
class OrderFragment : Fragment() {
private lateinit var viewModel: SellsViewModel
private lateinit var binding: FragmentOrderBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_order, container, false)
binding = FragmentOrderBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewModel = ViewModelProvider(this).get(SellsViewModel::class.java)
val adapter = OrderAdapter()
binding.rvOrder.layoutManager = LinearLayoutManager(context)
binding.rvOrder.adapter = adapter
viewModel.loadOrdersByStatus("pending")
viewModel.sellsList.observe(viewLifecycleOwner, Observer { orders ->
adapter.submitList(orders)
})
}
}

View File

@ -0,0 +1,61 @@
package com.alya.ecommerce_serang.ui.profile.mystore.sells.payment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.alya.ecommerce_serang.R
import com.alya.ecommerce_serang.data.api.dto.OrdersItem
class PaymentAdapter : RecyclerView.Adapter<PaymentAdapter.PaymentViewHolder>() {
private var paymentList: List<OrdersItem?>? = emptyList()
fun submitList(orders: List<OrdersItem?>?) {
paymentList = orders
notifyDataSetChanged()
}
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): PaymentViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_sells_payment, parent, false)
return PaymentViewHolder(view)
}
override fun onBindViewHolder(holder: PaymentViewHolder, position: Int) {
val order = paymentList?.get(position)
holder.bind(order)
}
override fun getItemCount(): Int = paymentList?.size ?: 0
class PaymentViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView){
private val tvPaymentNumber: TextView = itemView.findViewById(R.id.tv_payment_number)
private val tvPaymentDue: TextView = itemView.findViewById(R.id.tv_payment_due)
private val ivPaymentProduct: ImageView = itemView.findViewById(R.id.iv_payment_product)
private val tvPaymentProductName: TextView = itemView.findViewById(R.id.tv_payment_product_name)
private val tvPaymentProductVariant: TextView = itemView.findViewById(R.id.tv_payment_product_variant)
private val tvPaymentProductQty: TextView = itemView.findViewById(R.id.tv_payment_product_qty)
private val tvPaymentProductPrice: TextView = itemView.findViewById(R.id.tv_payment_product_price)
private val tvPaymentQty: TextView = itemView.findViewById(R.id.tv_payment_qty)
private val tvPaymentPrice: TextView = itemView.findViewById(R.id.tv_payment_price)
private val tvPaymentCustomer: TextView = itemView.findViewById(R.id.tv_payment_customer)
private val tvPaymentLocation: TextView = itemView.findViewById(R.id.tv_payment_location)
private val tvSeeMore: TextView = itemView.findViewById(R.id.tv_see_more)
private val btnConfirmPayment: Button = itemView.findViewById(R.id.btn_confirm_payment)
fun bind(order: OrdersItem?) {
tvPaymentNumber.text = "No. Pesanan: ${order?.orderId}"
tvPaymentDue.text = order?.createdAt + 7
tvPaymentQty.text = "${order?.orderItems?.size} produk"
tvPaymentPrice.text = "Rp${order?.totalAmount}"
tvPaymentCustomer.text = order?.username
tvPaymentLocation.text = order?.address?.subdistrict
}
}
}

View File

@ -5,14 +5,36 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.alya.ecommerce_serang.R
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.alya.ecommerce_serang.databinding.FragmentPaymentBinding
import com.alya.ecommerce_serang.utils.viewmodel.SellsViewModel
class PaymentFragment : Fragment() {
private lateinit var viewModel: SellsViewModel
private lateinit var binding: FragmentPaymentBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_payment, container, false)
binding = FragmentPaymentBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewModel = ViewModelProvider(this).get(SellsViewModel::class.java)
val adapter = PaymentAdapter()
binding.rvPayment.layoutManager = LinearLayoutManager(context)
binding.rvPayment.adapter = adapter
viewModel.loadOrdersByStatus("paid")
viewModel.sellsList.observe(viewLifecycleOwner, Observer { payments ->
adapter.submitList(payments)
})
}
}

View File

@ -0,0 +1,56 @@
package com.alya.ecommerce_serang.ui.profile.mystore.sells.shipment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.alya.ecommerce_serang.R
import com.alya.ecommerce_serang.data.api.dto.OrdersItem
class ShipmentAdapter : RecyclerView.Adapter<ShipmentAdapter.ShipmentViewHolder>() {
private var shipmentList: List<OrdersItem> = emptyList()
fun submitList(orders: List<OrdersItem>) {
shipmentList = orders
notifyDataSetChanged()
}
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): ShipmentAdapter.ShipmentViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_sells_shipment, parent, false)
return ShipmentViewHolder(view)
}
override fun onBindViewHolder(holder: ShipmentAdapter.ShipmentViewHolder, position: Int) {
val order = shipmentList[position]
holder.bind(order)
}
override fun getItemCount(): Int = shipmentList.size
class ShipmentViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
private val tvShipmentNumber: TextView = itemView.findViewById(R.id.tv_shipment_number)
private val tvShipmentDue: TextView = itemView.findViewById(R.id.tv_shipment_due)
private val ivShipmentProduct: ImageView = itemView.findViewById(R.id.iv_shipment_product)
private val tvShipmentProductName: TextView = itemView.findViewById(R.id.tv_shipment_product_name)
private val tvShipmentProductVariant: TextView = itemView.findViewById(R.id.tv_shipment_product_variant)
private val tvShipmentProductQty: TextView = itemView.findViewById(R.id.tv_shipment_product_qty)
private val tvShipmentCustomer: TextView = itemView.findViewById(R.id.tv_shipment_customer)
private val tvShipmentLocation: TextView = itemView.findViewById(R.id.tv_shipment_location)
private val tvSeeMore: TextView = itemView.findViewById(R.id.tv_see_more)
private val btnConfirmPayment: Button = itemView.findViewById(R.id.btn_confirm_payment)
fun bind(order: OrdersItem) {
tvShipmentNumber.text = "No. Pesanan: ${order.orderId}"
tvShipmentDue.text = order.createdAt + 7
tvShipmentCustomer.text = order.username
tvShipmentLocation.text = order.address?.subdistrict
}
}
}

View File

@ -5,14 +5,37 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.alya.ecommerce_serang.R
import com.alya.ecommerce_serang.databinding.FragmentShipmentBinding
import com.alya.ecommerce_serang.utils.viewmodel.SellsViewModel
class ShipmentFragment : Fragment() {
private lateinit var viewModel: SellsViewModel
private lateinit var binding: FragmentShipmentBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_shipment, container, false)
binding = FragmentShipmentBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewModel = ViewModelProvider(this).get(SellsViewModel::class.java)
val adapter = ShipmentAdapter()
binding.rvShipment.layoutManager = LinearLayoutManager(context)
// binding.rvShipment.adapter = adapter
//
// viewModel.loadOrdersByStatus("processed")
// viewModel.sellsList.observe(viewLifecycleOwner, Observer { shipments ->
// adapter.submitList(shipments)
// })
}
}

View File

@ -5,14 +5,37 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.alya.ecommerce_serang.R
import com.alya.ecommerce_serang.databinding.FragmentShippedBinding
import com.alya.ecommerce_serang.utils.viewmodel.SellsViewModel
class ShippedFragment : Fragment() {
private lateinit var viewModel: SellsViewModel
private lateinit var binding: FragmentShippedBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_shipped, container, false)
binding = FragmentShippedBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewModel = ViewModelProvider(this).get(SellsViewModel::class.java)
// val adapter = SellsAdapter()
// binding.rvShipped.layoutManager = LinearLayoutManager(context)
// binding.rvShipped.adapter = adapter
//
// viewModel.loadOrdersByStatus("shipped")
// viewModel.sellsList.observe(viewLifecycleOwner, Observer { shipped ->
// adapter.submitList(shipped)
// })
}
}

View File

@ -1,7 +1,26 @@
package com.alya.ecommerce_serang.utils.viewmodel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.liveData
import androidx.lifecycle.viewModelScope
import com.alya.ecommerce_serang.data.api.dto.OrdersItem
import com.alya.ecommerce_serang.data.repository.OrderRepository
import kotlinx.coroutines.launch
class SellsViewModel : ViewModel() {
// TODO: Implement the ViewModel
class SellsViewModel(private val repository: OrderRepository) : ViewModel() {
private val _sellsList = MutableLiveData<List<OrdersItem?>>()
val sellsList: LiveData<List<OrdersItem?>> get() = _sellsList
fun loadOrdersByStatus(status: String) {
viewModelScope.launch {
val result = if (status == "all") {
repository.fetchSells()
} else {
repository.fetchOrdersByStatus(status)
}
_sellsList.value = result
}
}
}

View File

@ -1,8 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/sells_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.profile.mystore.sells.SellsActivity"/>
tools:context=".ui.profile.mystore.sells.SellsActivity">
<FrameLayout
android:id="@+id/sells_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,17 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
<androidx.recyclerview.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rv_all_sells"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="13dp"
tools:context=".ui.profile.mystore.sells.all_sells.AllSellsFragment">
<TextView
android:id="@+id/tv_semua_pesanan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Semua Pesanan"
style="@style/label_medium_prominent"
android:textColor="@color/black_300"/>
</FrameLayout>
android:layout_height="match_parent"/>

View File

@ -1,17 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.recyclerview.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rv_cancellation"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.profile.mystore.sells.cancellation.CancellationFragment"
android:padding="13dp">
<TextView
android:id="@+id/tv_pembatalan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pembatalan"
style="@style/label_medium_prominent"
android:textColor="@color/black_300"/>
</FrameLayout>
android:layout_height="match_parent"/>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rv_completed"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

View File

@ -1,17 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.recyclerview.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rv_failed_payment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.profile.mystore.sells.failed_payment.FailedPaymentFragment"
android:padding="13dp">
<TextView
android:id="@+id/tv_klaim_pembayaran"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Klaim Pembayaran"
style="@style/label_medium_prominent"
android:textColor="@color/black_300"/>
</FrameLayout>
android:layout_height="match_parent"/>

View File

@ -1,17 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.recyclerview.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rv_failed_shipment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.profile.mystore.sells.failed_shipment.FailedShipmentFragment"
android:padding="13dp">
<TextView
android:id="@+id/tv_pengiriman_gagal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pengiriman Gagal"
style="@style/label_medium_prominent"
android:textColor="@color/black_300"/>
</FrameLayout>
android:layout_height="match_parent"/>

View File

@ -1,17 +0,0 @@
<?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.sells.finished.FinishedFragment"
android:padding="13dp">
<TextView
android:id="@+id/tv_selesai"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Selesai"
style="@style/label_medium_prominent"
android:textColor="@color/black_300"/>
</FrameLayout>

View File

@ -1,17 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rv_order"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.profile.mystore.sells.order.OrderFragment"
android:padding="13dp">
<TextView
android:id="@+id/tv_perlu_tagihan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Perlu Tagihan"
style="@style/label_medium_prominent"
android:textColor="@color/black_300"/>
</FrameLayout>
tools:listitem="@layout/item_sells_order" />

View File

@ -1,17 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.recyclerview.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rv_payment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.profile.mystore.sells.payment.PaymentFragment"
android:padding="13dp">
<TextView
android:id="@+id/tv_konfirmasi_pembayaran"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Konfirmasi Pembayaran"
style="@style/label_medium_prominent"
android:textColor="@color/black_300"/>
</FrameLayout>
tools:listitem="@layout/item_sells_payment"/>

View File

@ -1,19 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
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/sells"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ui.profile.mystore.sells.SellsFragment">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout_sells"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable" />
app:tabMode="scrollable"
app:tabTextAppearance="@style/label_medium_prominent"
app:tabSelectedTextAppearance="@style/label_medium_prominent"
app:tabIndicatorColor="@color/blue_500"
app:tabSelectedTextColor="@color/blue_500"
app:tabTextColor="@color/black_300"
app:tabBackground="@color/white"
app:tabPadding="13dp"/>
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/view_pager_sells"
@ -21,4 +27,4 @@
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,17 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rv_shipment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.profile.mystore.sells.shipment.ShipmentFragment"
android:padding="13dp">
<TextView
android:id="@+id/tv_perlu_dikirim"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Perlu Dikirim"
style="@style/label_medium_prominent"
android:textColor="@color/black_300"/>
</FrameLayout>
tools:listitem="@layout/item_sells_shipment" />

View File

@ -1,17 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.recyclerview.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rv_shipped"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.profile.mystore.sells.shipped.ShippedFragment"
android:padding="13dp">
<TextView
android:id="@+id/tv_dikirim"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dikirim"
style="@style/label_medium_prominent"
android:textColor="@color/black_300"/>
</FrameLayout>
android:layout_height="match_parent"/>