mirror of
https://github.com/shaulascr/ecommerce_serang.git
synced 2025-12-15 15:41:02 +00:00
fix hardcode detail sells
This commit is contained in:
@ -2,7 +2,6 @@ package com.alya.ecommerce_serang.ui.profile.mystore.sells
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
@ -12,7 +11,6 @@ import com.alya.ecommerce_serang.data.api.retrofit.ApiConfig
|
||||
import com.alya.ecommerce_serang.data.repository.AddressRepository
|
||||
import com.alya.ecommerce_serang.data.repository.SellsRepository
|
||||
import com.alya.ecommerce_serang.databinding.ActivityDetailSellsBinding
|
||||
import com.alya.ecommerce_serang.ui.profile.mystore.sells.shipment.DetailShipmentActivity
|
||||
import com.alya.ecommerce_serang.utils.BaseViewModelFactory
|
||||
import com.alya.ecommerce_serang.utils.SessionManager
|
||||
import com.alya.ecommerce_serang.utils.viewmodel.AddressViewModel
|
||||
@ -22,7 +20,6 @@ import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
import kotlin.getValue
|
||||
|
||||
class DetailSellsActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityDetailSellsBinding
|
||||
@ -100,8 +97,9 @@ class DetailSellsActivity : AppCompatActivity() {
|
||||
tvOrderCustomer.text = sell.username
|
||||
tvOrderDate.text = formatDate(sell.updatedAt.toString())
|
||||
tvOrderTotalProduct.text = "(${sell.orderItems?.size ?: 0} Barang)"
|
||||
tvOrderSubtotal.text = formatPrice(sell.totalAmount.toString())
|
||||
tvOrderShipPrice.text = formatPrice(sell.shipmentPrice.toString())
|
||||
val totalPrice = (sell.totalAmount?.toDouble()?.toInt() ?: 0) - (sell.shipmentPrice?.toDouble()?.toInt() ?: 0)
|
||||
tvOrderSubtotal.text = formatPrice(totalPrice.toString())
|
||||
tvOrderPrice.text = formatPrice(sell.totalAmount.toString())
|
||||
tvOrderRecipient.text = sell.recipient ?: "-"
|
||||
tvOrderRecipientNum.text = sell.receiptNum?.toString() ?: "-"
|
||||
|
||||
@ -186,7 +186,9 @@ class SellsAdapter(
|
||||
.into(ivSellsProduct)
|
||||
|
||||
tvSellsQty.text = "${order.orderItems?.size} produk"
|
||||
tvSellsPrice.text = order.totalAmount?.let { formatPrice(it.toDouble().toInt()) }
|
||||
val totalPrice = (order.totalAmount?.toDouble()?.toInt() ?: 0) - (order.shipmentPrice?.toDouble()?.toInt() ?: 0)
|
||||
tvSellsPrice.text =formatPrice(totalPrice).toString()
|
||||
Log.d("SellsAdapter", "Cek price:$totalPrice" )
|
||||
}
|
||||
"paid" -> {
|
||||
layoutOrders.visibility = View.GONE
|
||||
@ -208,7 +210,7 @@ class SellsAdapter(
|
||||
tvSellsDue.text = formatDueDate(order.updatedAt.toString(), 2)
|
||||
val totalPrice = (order.totalAmount?.toDouble()?.toInt() ?: 0) - (order.shipmentPrice?.toDouble()?.toInt() ?: 0)
|
||||
tvSellsPrice.text =formatPrice(totalPrice).toString()
|
||||
|
||||
tvSellsQty.text = "${order.orderItems?.size} produk"
|
||||
}
|
||||
"processed" -> {
|
||||
layoutOrders.visibility = View.GONE
|
||||
@ -237,6 +239,10 @@ class SellsAdapter(
|
||||
tvSellsLocation.text = order.subdistrict
|
||||
tvSellsCustomer.text = order.username
|
||||
tvSellsDue.text = formatDueDate(order.updatedAt.toString(), 2)
|
||||
tvSellsQty.text = "${order.orderItems?.size} produk"
|
||||
val totalPrice = (order.totalAmount?.toDouble()?.toInt() ?: 0) - (order.shipmentPrice?.toDouble()?.toInt() ?: 0)
|
||||
tvSellsPrice.text =formatPrice(totalPrice).toString()
|
||||
|
||||
}
|
||||
"shipped" -> {
|
||||
layoutOrders.visibility = View.GONE
|
||||
@ -248,7 +254,11 @@ class SellsAdapter(
|
||||
|
||||
tvSellsDue.text = formatDueDate(order.updatedAt.toString(), 0)
|
||||
tvSellsDue.background = itemView.context.getDrawable(R.drawable.bg_product_inactive)
|
||||
tvSellsQty.text = "${order.orderItems?.size} produk"
|
||||
btnConfirmPayment.visibility = View.GONE
|
||||
|
||||
val totalPrice = (order.totalAmount?.toDouble()?.toInt() ?: 0) - (order.shipmentPrice?.toDouble()?.toInt() ?: 0)
|
||||
tvSellsPrice.text =formatPrice(totalPrice).toString()
|
||||
}
|
||||
"delivered" -> {
|
||||
layoutOrders.visibility = View.GONE
|
||||
@ -259,8 +269,13 @@ class SellsAdapter(
|
||||
tvSellsDueDesc.text = "Dikirimkan pada"
|
||||
|
||||
tvSellsDue.text = formatDueDate(order.updatedAt.toString(), 0)
|
||||
tvSellsQty.text = "${order.orderItems?.size} produk"
|
||||
|
||||
tvSellsDue.background = itemView.context.getDrawable(R.drawable.bg_product_inactive)
|
||||
btnConfirmPayment.visibility = View.GONE
|
||||
|
||||
val totalPrice = (order.totalAmount?.toDouble()?.toInt() ?: 0) - (order.shipmentPrice?.toDouble()?.toInt() ?: 0)
|
||||
tvSellsPrice.text =formatPrice(totalPrice).toString()
|
||||
}
|
||||
"completed" -> {
|
||||
layoutOrders.visibility = View.GONE
|
||||
@ -271,8 +286,13 @@ class SellsAdapter(
|
||||
tvSellsDueDesc.text = "Selesai pada"
|
||||
|
||||
tvSellsDue.text = formatDueDate(order.updatedAt.toString(), 0)
|
||||
tvSellsQty.text = "${order.orderItems?.size} produk"
|
||||
|
||||
tvSellsDue.background = itemView.context.getDrawable(R.drawable.bg_product_inactive)
|
||||
btnConfirmPayment.visibility = View.GONE
|
||||
|
||||
val totalPrice = (order.totalAmount?.toDouble()?.toInt() ?: 0) - (order.shipmentPrice?.toDouble()?.toInt() ?: 0)
|
||||
tvSellsPrice.text =formatPrice(totalPrice).toString()
|
||||
}
|
||||
"canceled" -> {
|
||||
layoutOrders.visibility = View.GONE
|
||||
@ -283,6 +303,10 @@ class SellsAdapter(
|
||||
tvSellsDueDesc.text = "Dibatalkan pada"
|
||||
|
||||
tvSellsDue.text = formatDueDate(order.updatedAt.toString(), 0)
|
||||
tvSellsQty.text = "${order.orderItems?.size} produk"
|
||||
val totalPrice = (order.totalAmount?.toDouble()?.toInt() ?: 0) - (order.shipmentPrice?.toDouble()?.toInt() ?: 0)
|
||||
tvSellsPrice.text =formatPrice(totalPrice).toString()
|
||||
|
||||
tvSellsDue.background = itemView.context.getDrawable(R.drawable.bg_product_inactive)
|
||||
btnConfirmPayment.visibility = View.GONE
|
||||
}
|
||||
|
||||
@ -145,7 +145,8 @@ class DetailPaymentActivity : AppCompatActivity() {
|
||||
tvOrderCustomer.text = sell.username
|
||||
tvOrderDate.text = formatDate(sell.updatedAt.toString())
|
||||
tvOrderTotalProduct.text = "(${sell.orderItems?.size ?: 0} Barang)"
|
||||
tvOrderSubtotal.text = formatPrice(sell.totalAmount.toString())
|
||||
val totalPrice = (sell.totalAmount?.toDouble()?.toInt() ?: 0) - (sell.shipmentPrice?.toDouble()?.toInt() ?: 0)
|
||||
tvOrderSubtotal.text = formatPrice(totalPrice.toString())
|
||||
tvOrderShipPrice.text = formatPrice(sell.shipmentPrice.toString())
|
||||
tvOrderPrice.text = formatPrice(sell.totalAmount.toString())
|
||||
tvOrderDue.text = formatDueDate(sell.updatedAt.toString(), 2)
|
||||
|
||||
@ -101,7 +101,8 @@ class DetailShipmentActivity : AppCompatActivity() {
|
||||
tvOrderCustomer.text = sell.username
|
||||
tvOrderDate.text = formatDate(sell.updatedAt.toString())
|
||||
tvOrderTotalProduct.text = "(${sell.orderItems?.size ?: 0} Barang)"
|
||||
tvOrderSubtotal.text = formatPrice(sell.totalAmount.toString())
|
||||
val totalPrice = (sell.totalAmount?.toDouble()?.toInt() ?: 0) - (sell.shipmentPrice?.toDouble()?.toInt() ?: 0)
|
||||
tvOrderSubtotal.text = formatPrice(totalPrice.toString())
|
||||
tvOrderShipPrice.text = formatPrice(sell.shipmentPrice.toString())
|
||||
tvOrderPrice.text = formatPrice(sell.totalAmount.toString())
|
||||
tvOrderDue.text = formatDueDate(sell.updatedAt.toString(), 2)
|
||||
|
||||
@ -133,35 +133,36 @@
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/btn_left"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/bg_button_outline"
|
||||
android:backgroundTint="@color/white"
|
||||
android:visibility="gone"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:scrollHorizontally="false"
|
||||
android:singleLine="false"
|
||||
android:padding="4dp"
|
||||
android:visibility="gone"
|
||||
android:text="Tidak"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvDeadlineDate"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:layout_marginTop="8dp"/>
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/btn_right"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/bg_button_filled"
|
||||
android:visibility="gone"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:visibility="gone"
|
||||
android:scrollHorizontally="false"
|
||||
android:singleLine="false"
|
||||
android:padding="4dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:text="Kirim Bukti Bayar"
|
||||
android:text="Ya"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvDeadlineDate"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:layout_marginTop="8dp"/>
|
||||
|
||||
Reference in New Issue
Block a user