Skip to content
Snippets Groups Projects
Commit a785f74e authored by DewanaGustavus's avatar DewanaGustavus
Browse files

feat: fetch available order from SOAP

parent 857332c9
No related merge requests found
import express from "express";
import type { Request, Response } from "express";
import * as OrderServices from './order.service'
export const OrderRouter = express.Router()
OrderRouter.get('/available-order', async (request: Request, response: Response) => {
try {
const availableOrder = await OrderServices.getAvailableOrder();
return response.status(200).json(availableOrder);
} catch (error: any) {
return response.status(500).json(error.message);
}
})
\ No newline at end of file
import { getPesananNoKurir } from "../soap-caller/PesananSoapCaller";
import OrderInterface from "../../interfaces/OrderInterface";
export async function getAvailableOrder() {
const response = await getPesananNoKurir();
console.log(response);
if(response === null) {
return [];
}
const JSONArray = Array.isArray(response) ? response : [response];
const availableOrder = JSONArray.map((item: any) => {
return JSON.parse(JSON.stringify(item)) as OrderInterface;
});
return availableOrder;
}
\ No newline at end of file
export default interface OrderDetail {
id_pesanan : number
nama_produk : string
quantity : number
harga : number
}
\ No newline at end of file
import OrderStatus from "./OrderStatus"
export default interface OrderInterface {
alamat : string
biaya_pengiriman : number
harga : number
id : number
id_kurir : number
id_pemesan : number
keterangan : string
nama_penerima : string
status : OrderStatus
}
\ No newline at end of file
type OrderStatus = 'searching_courier' | 'pickup' | 'transit' | 'delivered';
export default OrderStatus;
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment