feat(medusa,dashboard,tax): added tax rates and regions UI (#7026)
whats missing: - make rules required for overrides - conditions for other rules - populating condition reference ids with labels on update Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
This commit is contained in:
co-authored by
Adrien de Peretti
parent
92b633d1cb
commit
00e6b21bb5
@@ -1,8 +1,14 @@
|
||||
import {
|
||||
AdminCreateTaxRegion,
|
||||
AdminPostTaxRatesTaxRateReq,
|
||||
} from "@medusajs/medusa"
|
||||
import {
|
||||
AdminTaxRateResponse,
|
||||
AdminTaxRegionListResponse,
|
||||
AdminTaxRegionResponse,
|
||||
} from "@medusajs/types"
|
||||
import { getRequest } from "./common"
|
||||
import { TaxRateDeleteRes, TaxRegionDeleteRes } from "../../types/api-responses"
|
||||
import { deleteRequest, getRequest, postRequest } from "./common"
|
||||
|
||||
async function retrieveTaxRegion(id: string, query?: Record<string, any>) {
|
||||
return getRequest<AdminTaxRegionResponse>(`/admin/tax-regions/${id}`, query)
|
||||
@@ -12,7 +18,42 @@ async function listTaxRegions(query?: Record<string, any>) {
|
||||
return getRequest<AdminTaxRegionListResponse>(`/admin/tax-regions`, query)
|
||||
}
|
||||
|
||||
async function createTaxRegion(payload: AdminCreateTaxRegion) {
|
||||
return postRequest<AdminTaxRegionResponse>(`/admin/tax-regions`, payload)
|
||||
}
|
||||
|
||||
async function deleteTaxRegion(id: string) {
|
||||
return deleteRequest<TaxRegionDeleteRes>(`/admin/tax-regions/${id}`)
|
||||
}
|
||||
|
||||
async function retrieveTaxRate(id: string, query?: Record<string, any>) {
|
||||
return getRequest<AdminTaxRegionResponse>(`/admin/tax-rates/${id}`, query)
|
||||
}
|
||||
|
||||
async function listTaxRates(query?: Record<string, any>) {
|
||||
return getRequest<AdminTaxRegionListResponse>(`/admin/tax-rates`, query)
|
||||
}
|
||||
|
||||
async function updateTaxRate(id: string, payload: AdminPostTaxRatesTaxRateReq) {
|
||||
return postRequest<AdminTaxRateResponse>(`/admin/tax-rates/${id}`, payload)
|
||||
}
|
||||
|
||||
async function createTaxRate(payload: AdminCreateTaxRate) {
|
||||
return postRequest<AdminTaxRateResponse>(`/admin/tax-rates`, payload)
|
||||
}
|
||||
|
||||
async function deleteTaxRate(id: string) {
|
||||
return deleteRequest<TaxRateDeleteRes>(`/admin/tax-rates/${id}`)
|
||||
}
|
||||
|
||||
export const taxes = {
|
||||
retrieveTaxRegion,
|
||||
listTaxRegions,
|
||||
retrieveTaxRate,
|
||||
listTaxRates,
|
||||
updateTaxRate,
|
||||
createTaxRegion,
|
||||
deleteTaxRegion,
|
||||
createTaxRate,
|
||||
deleteTaxRate,
|
||||
}
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
/** This file is auto-generated. Do not modify it manually. */
|
||||
import type { RegionCountryDTO } from "@medusajs/types"
|
||||
|
||||
export function getCountryByIso2(
|
||||
iso2: string | null
|
||||
): Omit<RegionCountryDTO, "id"> | undefined {
|
||||
if (!iso2) {
|
||||
return
|
||||
}
|
||||
|
||||
return countries.find((c) => c.iso_2 === iso2)
|
||||
}
|
||||
|
||||
export const countries: Omit<RegionCountryDTO, "id">[] = [
|
||||
{
|
||||
iso_2: "af",
|
||||
|
||||
Reference in New Issue
Block a user