Commit 3120dd73 authored by chaiwat's avatar chaiwat

add 3/3/2565

parent ebf673ab
...@@ -124,10 +124,15 @@ ...@@ -124,10 +124,15 @@
color: #faed26; color: #faed26;
} }
// .left { .text-left {
// // display: flex; // display: flex;
// justify-content: left; text-align: left;
// } }
.pageHeader {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
border-radius: 1%;
}
...@@ -131,6 +131,20 @@ const PagesRoutes = [ ...@@ -131,6 +131,20 @@ const PagesRoutes = [
layout: 'VerticalLayout', layout: 'VerticalLayout',
}, },
// Garage Detail
{
path: '/admin/all-garage/detail',
component: lazy(() => import('../../view/Admin/garageDetail')),
layout: 'VerticalLayout',
},
// Admin Approve
{
path: '/admin/approve',
component: lazy(() => import('../../view/Admin/Approve')),
layout: 'VerticalLayout',
},
]; ];
......
...@@ -12,9 +12,6 @@ function Admin() { ...@@ -12,9 +12,6 @@ function Admin() {
const [datas, setDatas] = useState([]); const [datas, setDatas] = useState([]);
useEffect(() => { useEffect(() => {
const getGarage = async () => { const getGarage = async () => {
await FetchGarageAll().then(async (response) => { await FetchGarageAll().then(async (response) => {
......
import React from 'react'
function Approve() {
return (
<>Approve</>
)
}
export default Approve
\ No newline at end of file
import React, { useState, useEffect } from "react"; import React, { useState, useEffect } from "react";
import { Collapse, Col, Row, Typography, Divider } from "antd"; import { Collapse, Col, Row, Typography, Divider } from "antd";
import { RightCircleOutlined } from "@ant-design/icons";
import { Link } from "react-router-dom";
// import services // import services
import { FetchGarageAll } from "../../services"; import { FetchGarageAll } from "../../services";
const { Title, Text } = Typography; const { Title, Text } = Typography;
const { Panel } = Collapse; const { Panel } = Collapse;
const text = `
A dog is a type of domesticated animal.
Known for its loyalty and faithfulness,
it can be found as a welcome guest in many households across the world.
`;
function Garage() { function Garage() {
const [datas, setDatas] = useState([]); const [datas, setDatas] = useState([]);
useEffect(() => { useEffect(() => {
const getGarage = async () => { const getGarage = () => {
await FetchGarageAll().then(async (response) => { FetchGarageAll().then((response) => {
if (response.code === 500) { if (response.data) {
console.log("data", response); setDatas(response.data);
} else {
await setDatas(response.data[0]);
// console.log('data', response.data) // console.log('data', response.data)
} }
// console.log('data', response) // console.log('data', response)
...@@ -31,9 +27,28 @@ function Garage() { ...@@ -31,9 +27,28 @@ function Garage() {
getGarage(); getGarage();
}, []); }, []);
function callback(key) { // function callback(key) {
console.log(key); // // console.log(key);
} // }
const genExtra = (id, data) => (
<Link
to={{
pathname: "/admin/all-garage/detail",
state: {
garageID: id,
data: data,
},
}}
>
<RightCircleOutlined />
</Link>
);
// const detailGarage = (id) => {
// console.log("id", id);
// };
return ( return (
<> <>
...@@ -43,64 +58,86 @@ function Garage() { ...@@ -43,64 +58,86 @@ function Garage() {
</Col> </Col>
<Col span={24}> <Col span={24}>
<Collapse onChange={callback}> <Collapse>
<Panel header={datas.garage_name} key="1" extra={datas.province}> {datas.length !== 0 ? (
<Row gutter={[0, 16]}> <>
<Divider orientation="left" plain> {datas.map((val, index) => {
รายละเอียดร้านซ่อม return (
</Divider> <>
<Col <Panel
xs={24} header={val.garage_name}
md={{ span: 11, offset: 1 }} key={index}
lg={{ span: 7, offset: 1 }} extra={genExtra(val.garageID, val)}
> >
<Text style={{ fontWeight: "bold" }}>User ID : </Text> <Row gutter={[0, 16]} className="text-left">
<Text>{datas.garageID} </Text> <Divider orientation="left" plain>
</Col> รายละเอียดร้านซ่อม
</Divider>
<Col
xs={24} <Col xs={24} lg={{ span: 7, offset: 1 }}>
md={{ span: 11, offset: 1 }} <Text style={{ fontWeight: "bold" }}>
lg={{ span: 7, offset: 1 }} ชื่อร้าน :{" "}
> </Text>
<Text style={{ fontWeight: "bold" }}>ชื่อร้าน : </Text> <Text>{val.garage_name} </Text>
<Text>{datas.garage_name} </Text> </Col>
</Col>
<Col xs={24} lg={{ span: 7, offset: 1 }}>
<Col <Text style={{ fontWeight: "bold" }}>
xs={24} ชื่อ-สกุล :{" "}
md={{ span: 11, offset: 1 }} </Text>
lg={{ span: 7, offset: 1 }} <Text>{val.user_name} </Text>
> </Col>
<Text style={{ fontWeight: "bold" }}>ชื่อ-สกุล : </Text>
<Text>{datas.user_name} </Text> <Col xs={24} lg={{ span: 7, offset: 1 }}>
</Col> <Text style={{ fontWeight: "bold" }}>
E-Mail :{" "}
<Col </Text>
xs={24} <Text>{val.email} </Text>
md={{ span: 11, offset: 1 }} </Col>
lg={{ span: 7, offset: 1 }}
> <Col xs={24} lg={{ span: 7, offset: 1 }}>
<Text style={{ fontWeight: "bold" }}>E-Mail : </Text> <Text style={{ fontWeight: "bold" }}>
<Text>{datas.email} </Text> ประเภทร้านซ่อม :{" "}
</Col> </Text>
<Text>
<Col {JSON.parse(val.garage_type).join(", ")}{" "}
xs={24} </Text>
md={{ span: 11, offset: 1 }} </Col>
lg={{ span: 7, offset: 1 }}
> <Col xs={24} lg={{ span: 7, offset: 1 }}>
<Text style={{ fontWeight: "bold" }}>ประเภทร้านซ่อม : </Text> <Text style={{ fontWeight: "bold" }}>
<Text>{datas.garage_type} </Text> เวลาเปิด - ปิด :{" "}
</Col> </Text>
</Row> <Text>
</Panel> {val.on_time} - {val.off_time}{" "}
<Panel header="This is panel header 2" key="2"> </Text>
<p>{text}</p> </Col>
</Panel>
<Panel header="This is panel header 3" key="3"> <Col xs={24} lg={{ span: 7, offset: 1 }}>
<p>{text}</p> <Text style={{ fontWeight: "bold" }}>
</Panel> เบอร์โทรศัพท์ :{" "}
</Text>
<Text>{val.tel} </Text>
</Col>
<Col xs={24} lg={{ span: 15, offset: 1 }}>
<Text style={{ fontWeight: "bold" }}>
ที่อยู่ :{" "}
</Text>
<Text>
{val.address_number} หมู่ {val.moo} ซอย{" "}
{val.alley} ถนน {val.road} ต.{val.sub_district} อ.
{val.district} จ.{val.province} {val.pos_code}{" "}
</Text>
</Col>
</Row>
<Divider />
</Panel>
</>
);
})}
</>
) : null}
</Collapse> </Collapse>
</Col> </Col>
</Row> </Row>
......
import React, { useState, useEffect } from "react";
import {
PageHeader,
Button,
Statistic,
Descriptions,
Row,
Col,
Modal,
} from "antd";
import {
withScriptjs,
withGoogleMap,
GoogleMap,
Marker,
} from "react-google-maps";
import { useLocation } from "react-router-dom";
// Import services
import { FetctDetailByGarage } from "../../services";
import IconCar from "../../assets/icons/car.png";
export default function GarageDetail() {
let location = useLocation;
const garageID = location().state;
const garage = location().state.data;
const [datas, setDatas] = useState([]);
const [visible, setVisible] = useState(false);
// console.log(garage);
useEffect(() => {
const getDetailByGarage = async () => {
await FetctDetailByGarage(garageID).then(async (response) => {
await setDatas(response.data);
});
};
getDetailByGarage();
}, [garageID]);
// console.log(datas);
let newData = [];
let car = [];
let moto = [];
let arg = [];
let succeed = [];
let notSucceed = [];
if (datas !== null) {
for (let i = 0; i < datas.length; i++) {
newData.push(datas[i]);
if (datas[i].device_type === "รถยนต์") {
car.push(datas[i]);
}
if (datas[i].device_type === "รถจักรยานยนต์") {
moto.push(datas[i]);
}
if (datas[i].device_type === "อุปกรณ์การเกษตร") {
arg.push(datas[i]);
}
if (datas[i].status === "สำเร็จ") {
succeed.push(datas[i]);
}
if (datas[i].status === "อยู่ระหว่างการซ่อม") {
notSucceed.push(datas[i]);
}
}
}
let newLatLng = [
{
lat: JSON.parse(garage.address_map)[0],
lng: JSON.parse(garage.address_map)[1],
},
];
// console.log(newLatLng);
const MapWithAMarker = withScriptjs(
withGoogleMap(() => (
<GoogleMap defaultZoom={15} defaultCenter={newLatLng[0]}>
<Marker
position={newLatLng[0]}
icon={{
url: IconCar,
scaledSize: new window.google.maps.Size(40, 40),
}}
/>
</GoogleMap>
))
);
return (
<>
<Row className="div-p-5">
<Col span={24} className="pageHeader" style={{ padding: "2%" }}>
<PageHeader
className="site-page-header"
onBack={() => window.history.back()}
title={garage.garage_name}
subTitle="ข้อมูลการซ่อมของร้าน"
extra={[
<Button key="3" onClick={() => setVisible(true)}>
ดูตำแหน่งของร้าน
</Button>,
]}
>
<Row gutter={[0, 16]}>
<Col span={24}>
<Descriptions size="small" column={2}>
<Descriptions.Item label="เจ้าของร้าน">
คุณ {garage.user_name}
</Descriptions.Item>
<Descriptions.Item label="ชื่อร้าน">
{garage.garage_name}
</Descriptions.Item>
<Descriptions.Item label="ประเภท">
{JSON.parse(garage.garage_type).join(", ")}
</Descriptions.Item>
<Descriptions.Item label="เข้าร่วมระบบ">
{garage.registration_date}
</Descriptions.Item>
</Descriptions>
</Col>
<Statistic
title="การซ่อมทั้งหมด"
value={newData.length}
style={{
margin: "0 20px",
}}
/>
<Statistic
title="ที่สำเร็จ"
value={succeed.length}
style={{
margin: "0 20px",
}}
/>
<Statistic
title="กำลังดำเนินการซ่อม"
value={notSucceed.length}
style={{
margin: "0 20px",
}}
/>
<br />
<Statistic
title="รถยนต์"
value={car.length}
style={{
margin: "0 20px",
}}
/>
<Statistic
title="รถจักรยานยนต์"
value={moto.length}
style={{
margin: "0 20px",
}}
/>
<Statistic
title="อุปกรณ์การเกษตร"
value={arg.length}
style={{
margin: "0 20px",
}}
/>
</Row>
</PageHeader>
</Col>
</Row>
<Modal
title={garage.garage_name}
centered
visible={visible}
onOk={() => setVisible(false)}
onCancel={() => setVisible(false)}
width={700}
>
<MapWithAMarker
googleMapURL="https://maps.googleapis.com/maps/api/js?key=AIzaSyBYQsoMGSxKVOe6vilIiEedgPhRDjcPbC8&libraries=geometry,drawing,places"
loadingElement={<div style={{ height: "100%" }} />}
containerElement={<div style={{ height: "400px" }} />}
mapElement={<div style={{ height: "100%" }} />}
/>
</Modal>
</>
);
}
...@@ -8,7 +8,6 @@ import { useLocation } from "react-router-dom"; ...@@ -8,7 +8,6 @@ import { useLocation } from "react-router-dom";
// import Service // import Service
import { FetctDetailByGarageID, FetchSpareByDetailID } from "../../../services"; import { FetctDetailByGarageID, FetchSpareByDetailID } from "../../../services";
// import { useLocation } from "react-router-dom";
const { Text, Title } = Typography; const { Text, Title } = Typography;
const { Column, ColumnGroup } = Table; const { Column, ColumnGroup } = Table;
......
...@@ -70,7 +70,7 @@ function Map() { ...@@ -70,7 +70,7 @@ function Map() {
<h4> <h4>
<b>{selectPark.garage_name}</b> <b>{selectPark.garage_name}</b>
</h4> </h4>
<p>{JSON.parse(selectPark.garage_type)}</p> <p>{JSON.parse(selectPark.garage_type).join(", ")}</p>
<p>เปิด {selectPark.on_time} - {selectPark.off_time}</p> <p>เปิด {selectPark.on_time} - {selectPark.off_time}</p>
</div> </div>
</InfoWindow> </InfoWindow>
......
import { Col } from 'antd' import { Col, } from 'antd'
import { import {
withScriptjs, withScriptjs,
withGoogleMap, withGoogleMap,
...@@ -11,7 +11,7 @@ import { ...@@ -11,7 +11,7 @@ import {
const onMarkerDragEnd = (event) => { const onMarkerDragEnd = (event) => {
newLatLng[0].lat = event.latLng.lat() newLatLng[0].lat = event.latLng.lat()
newLatLng[0].lng = event.latLng.lng() newLatLng[0].lng = event.latLng.lng()
console.log('newLat', newLatLng[0].lat, 'newLng', newLatLng[0].lng) // console.log('newLat', newLatLng[0].lat, 'newLng', newLatLng[0].lng)
} }
const MapWithAMarker = withScriptjs( const MapWithAMarker = withScriptjs(
......
Markdown is supported
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