Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a7bc034
fix(MainActivity) : route of Admin and User when login app
hoanghaoz Apr 10, 2026
ef7ea6c
feat(invoice-core): add shared invoice models and mock workflow data
hoanghaoz Apr 10, 2026
1ea22fc
feat(invoice-flow): implement admin-user invoice workflow and navigation
hoanghaoz Apr 10, 2026
f7c7a00
feat(auth): adjust auth paths and related screen wiring
hoanghaoz Apr 10, 2026
b942375
fix(Logout_Test) : solve Duplicated Lines (%) on New Code 8.6%
hoanghaoz Apr 11, 2026
dd0f32e
refactor(invoice): fix sonar cognitive complexity and long parameter …
hoanghaoz Apr 13, 2026
e27883a
Merge branch 'main' of https://github.com/tqha1011/ShoeStore into fea…
hoanghaoz Apr 17, 2026
7edc145
Merge branch 'main' of https://github.com/tqha1011/ShoeStore into fea…
hoanghaoz Apr 17, 2026
31f7bb2
Merge branch 'main' of https://github.com/tqha1011/ShoeStore into fea…
hoanghaoz Apr 17, 2026
4dd0a07
Merge branch 'main' of https://github.com/tqha1011/ShoeStore into fea…
hoanghaoz Apr 17, 2026
c94b143
feat(invoice) : create mockdata for admin and user and create screen …
hoanghaoz Apr 19, 2026
d7c8cf1
Merge branch 'main' of https://github.com/tqha1011/ShoeStore into fea…
hoanghaoz Apr 19, 2026
70beb1d
feat(invoice) : create dto , api and mapper data
hoanghaoz Apr 22, 2026
bf89c38
fix : duplicated code in AdminOrderCard and UserOrderCard to reduce …
hoanghaoz Apr 22, 2026
d49a2f9
fix : duplicated code in AdminOrderCard and UserOrderCard to reduce …
hoanghaoz Apr 22, 2026
b94598f
feat(Invoice) : impliment repository of invoice and fix some dto to m…
hoanghaoz Apr 23, 2026
66c20f8
Merge branch 'main' into features/invoice_fe
hoanghaoz Apr 23, 2026
5cf3290
fix : duplicated itemdto
hoanghaoz Apr 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.example.shoestoreapp.features.invoice.data.mapper

import com.example.shoestoreapp.features.invoice.data.remote.Item
import com.example.shoestoreapp.features.invoice.data.remote.DetailDto
import com.example.shoestoreapp.features.invoice.data.remote.ItemDto
import com.example.shoestoreapp.features.invoice.model.Detail
import com.example.shoestoreapp.features.invoice.model.Invoice
import com.example.shoestoreapp.features.invoice.model.InvoiceStatus

fun Item.toDomain() : Invoice {
fun ItemDto.toDomain() : Invoice {
return Invoice(
orderCode = this.orderCode ?: "",
userName = this.username ?: "Empty",
Expand All @@ -20,4 +22,15 @@ fun Item.toDomain() : Invoice {
createdAt = this.dateCreated,
finalPrice = this.finalPrice
)
}

fun DetailDto.toDomain() : Detail {
return Detail(
color = this.color ?: "",
imageUrl = this.imageUrl ?: "",
productName = this.productName ?: "",
quantity = this.quantity ?: 0,
size = this.size ?: 0,
unitPrice = this.unitPrice ?: 0
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.example.shoestoreapp.features.invoice.data.remote


import com.google.gson.annotations.SerializedName

data class DetailDto(
@SerializedName("color")
val color: String?,
@SerializedName("imageUrl")
val imageUrl: String?,
@SerializedName("productName")
val productName: String?,
@SerializedName("quantity")
val quantity: Int?,
@SerializedName("size")
val size: Int?,
@SerializedName("unitPrice")
val unitPrice: Int?
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import retrofit2.http.Query

interface InvoiceApi {
@GET ("api/invoice/admin/get-all")
suspend fun getallInvoices(
suspend fun getAllInvoices(
@Query("PageNumber") pageNumber: Int = 1,
@Query("PageSize") pageSize: Int = 10
): Response<InvoiceListDto>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.google.gson.annotations.SerializedName

data class InvoiceDetailsDto(
@SerializedName("data")
val `data`: List<Data?>?,
val detailDto: List<DetailDto>?,
@SerializedName("message")
val message: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ data class InvoiceListDto(
@SerializedName("hasPrevious")
val hasPrevious: Boolean?,
@SerializedName("items")
val item: List<Item>?,
val itemDto: List<ItemDto>?,
@SerializedName("pageNumber")
val pageNumber: String?,
@SerializedName("pageSize")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.example.shoestoreapp.features.invoice.data.remote

import com.google.gson.annotations.SerializedName

data class Item(
data class ItemDto(
@SerializedName("address")
val address: String?,
@SerializedName("dateCreated")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.example.shoestoreapp.features.invoice.data.repositories

import com.example.shoestoreapp.features.invoice.data.remote.InvoiceApi
import com.example.shoestoreapp.features.invoice.data.mapper.toDomain
import com.example.shoestoreapp.features.invoice.data.remote.UpdateStatusRequestDto
import com.example.shoestoreapp.features.invoice.model.Invoice
import com.example.shoestoreapp.features.invoice.model.Detail
class InvoiceRepositoryImpl (private val api : InvoiceApi) {
suspend fun getAllInvoices(): Result<List<Invoice>> = runCatching {
val response = api.getAllInvoices(pageNumber = 1, pageSize = 10)
if (response.isSuccessful) {
val dtos = response.body()?.itemDto ?: emptyList()
dtos.map { it.toDomain() }
} else {
throw Exception("Lỗi API: ${response.code()} - ${response.message()}")
}
}

suspend fun updateInvoiceStatus(invoiceGuid: String, status: Int): Result<Unit> = runCatching {
val request = UpdateStatusRequestDto(status = status)
val response = api.updateInvoiceStatus(invoiceGuid, request)
if (!response.isSuccessful) {
throw Exception("Lỗi update : ${response.code()} - ${response.message()}")
}
}

suspend fun getInvoiceDetails(invoiceGuid: String): Result<List<Detail>> = runCatching {
val response = api.getInvoiceDetails(invoiceGuid)
if (response.isSuccessful) {
val dtos = response.body()?.detailDto ?: emptyList()
dtos.map { it.toDomain() }
} else {
throw Exception("Lỗi : ${response.code()} - ${response.message()}")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ data class Invoice(
val createdAt: String?,
val finalPrice: String?,
)
// Data Details
data class Detail (
val color: String,
val imageUrl: String,
val productName: String,
val quantity: Int,
val size: Int,
val unitPrice: Int
)

fun InvoiceStatus.displayName(): String {
return when (this) {
Expand Down
Loading