update
This commit is contained in:
parent
c8722e6b10
commit
306dd78acb
|
|
@ -122,27 +122,27 @@ class TrackingController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
public function update(DiscountRequest $request)
|
||||
public function update(Request $request)
|
||||
{
|
||||
$id = $request->get('id');
|
||||
|
||||
$discount = Discount::find($id);
|
||||
$tracking = Tracking::find($id);
|
||||
$payload = $request->all();
|
||||
|
||||
if ($discount) {
|
||||
$discount->update($payload);
|
||||
if ($tracking) {
|
||||
$tracking->update($payload);
|
||||
}
|
||||
return response()->json([
|
||||
'data' => $discount,
|
||||
'data' => $tracking,
|
||||
'status' => true
|
||||
]);
|
||||
}
|
||||
|
||||
public function delete(DiscountRequest $request)
|
||||
public function delete(Request $request)
|
||||
{
|
||||
$id = $request->get('id');
|
||||
|
||||
Discount::destroy($id);
|
||||
Tracking::destroy($id);
|
||||
return response()->json([
|
||||
'status' => true
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -150,5 +150,6 @@ Route::middleware('api')
|
|||
], function () {
|
||||
Route::get('/', [TrackingController::class, 'get']);
|
||||
Route::post('/scan-create', [TrackingController::class, 'create']);
|
||||
Route::get('/delete', [TrackingController::class, 'delete']);
|
||||
// Route::get('/clear-cache', [SettingController::class, 'clearCache']);
|
||||
});
|
||||
|
|
@ -52,4 +52,5 @@ export const statisticSearchSNByMonth = API_URL + 'v1/admin/dashboard/statistics
|
|||
export const statisticRevenuesByMonth = API_URL + 'v1/admin/dashboard/statistics-revenues-by-month'
|
||||
|
||||
// Tracking
|
||||
export const getListTracking = API_URL + 'v1/admin/tracking'
|
||||
export const getListTracking = API_URL + 'v1/admin/tracking'
|
||||
export const deleteTracking = API_URL + 'v1/admin/tracking/delete'
|
||||
|
|
@ -7,4 +7,30 @@
|
|||
padding: 0 var(--mantine-spacing-sm) var(--mantine-spacing-lg)
|
||||
var(--mantine-spacing-sm);
|
||||
border-bottom: solid rgba(201, 201, 201, 0.377) 1px;
|
||||
}
|
||||
|
||||
.optionIcon {
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
|
||||
.deleteIcon {
|
||||
color: red;
|
||||
cursor: pointer;
|
||||
padding: 2px;
|
||||
border-radius: 25%;
|
||||
}
|
||||
|
||||
.deleteIcon:hover {
|
||||
background-color: rgba(203, 203, 203, 0.809);
|
||||
}
|
||||
|
||||
.dialog {
|
||||
background-color: light-dark(white, #2d353c);
|
||||
text-align: center;
|
||||
border: solid 1px rgb(255, 145, 0);
|
||||
}
|
||||
|
||||
.dialogText {
|
||||
color: light-dark(#2d353c, white);
|
||||
}
|
||||
|
|
@ -1,15 +1,19 @@
|
|||
import { getListTracking } from "@/api/Admin"
|
||||
import { deleteTracking, getListTracking } from "@/api/Admin"
|
||||
import { DataTablePagination } from "@/components/DataTable/DataTable"
|
||||
import { Xdelete } from "@/rtk/helpers/CRUD"
|
||||
import { get } from "@/rtk/helpers/apiService"
|
||||
import { Box, Text } from "@mantine/core"
|
||||
import { Box, Button, Dialog, Group, Text } from "@mantine/core"
|
||||
import { IconTrash } from "@tabler/icons-react"
|
||||
import moment from "moment"
|
||||
import { useEffect, useState } from "react"
|
||||
import classes from './Tracking.module.css'
|
||||
import { DataTablePagination } from "@/components/DataTable/DataTable"
|
||||
const Tracking = () => {
|
||||
const [listTracking, setListTracking] = useState({
|
||||
data: []
|
||||
})
|
||||
|
||||
const [action, setAction] = useState('')
|
||||
const [item, setItem] = useState({id: 0})
|
||||
const [activeBtn, setActiveBtn] = useState(false)
|
||||
const columns = [
|
||||
{
|
||||
name: 'id',
|
||||
|
|
@ -39,6 +43,28 @@ const Tracking = () => {
|
|||
return moment(row.updated_at).format('YYYY/MM/DD - HH:mm:ss')
|
||||
},
|
||||
},
|
||||
{
|
||||
name: '#',
|
||||
size: '10%',
|
||||
header: 'Action',
|
||||
render: (row: any) => {
|
||||
return (
|
||||
<Box
|
||||
className={classes.optionIcon}
|
||||
>
|
||||
<IconTrash
|
||||
className={classes.deleteIcon}
|
||||
onClick={() => {
|
||||
setAction('delete')
|
||||
setItem(row)
|
||||
}}
|
||||
width={20}
|
||||
height={20}
|
||||
/>
|
||||
</Box>
|
||||
)
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
const filterInfo = [
|
||||
|
|
@ -81,10 +107,18 @@ const Tracking = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
await Xdelete(deleteTracking, { id: id }, getAllTracking)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(()=>{
|
||||
setInterval(()=>{
|
||||
getAllTracking()
|
||||
}, 3000)
|
||||
}, 7000)
|
||||
}, [])
|
||||
return (
|
||||
<div>
|
||||
|
|
@ -114,6 +148,44 @@ const Tracking = () => {
|
|||
/>
|
||||
}
|
||||
</Box>
|
||||
|
||||
<Dialog
|
||||
className={classes.dialog}
|
||||
opened={action === 'delete'}
|
||||
withCloseButton
|
||||
onClose={() => setAction('')}
|
||||
size="lg"
|
||||
radius="md"
|
||||
position={{ top: 30, right: 10 }}
|
||||
>
|
||||
<Text className={classes.dialogText} size="sm" mb="xs" fw={500}>
|
||||
Do you want to delete this discount?
|
||||
<Group justify="center" m={10}>
|
||||
<Button
|
||||
disabled={activeBtn}
|
||||
fw={700}
|
||||
size="xs"
|
||||
variant="light"
|
||||
onClick={async () => {
|
||||
setActiveBtn(true)
|
||||
await handleDelete(item.id)
|
||||
setActiveBtn(false)
|
||||
setAction('')
|
||||
}}
|
||||
>
|
||||
Yes
|
||||
</Button>
|
||||
<Button
|
||||
fw={700}
|
||||
size="xs"
|
||||
variant="light"
|
||||
onClick={() => setAction('')}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
</Group>
|
||||
</Text>
|
||||
</Dialog>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue