-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e77c00
commit 28ba6a7
Showing
12 changed files
with
375 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
services/web/src/components/vehicleServiceDashboard/vehicleServiceDashboard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import React from "react"; | ||
import { Card, Row, Col } from "antd"; | ||
import { PageHeader } from "@ant-design/pro-components"; | ||
|
||
const { Meta } = Card; | ||
|
||
interface Owner { | ||
email: string; | ||
number: string; | ||
} | ||
|
||
interface Vehicle { | ||
owner: Owner; | ||
id: string; | ||
vin: string; | ||
} | ||
|
||
interface Service { | ||
id: string; | ||
problem_details: string; | ||
created_on: string; | ||
vehicle: Vehicle; | ||
status: string; | ||
} | ||
|
||
interface VehicleServiceDashboardProps { | ||
services: Service[]; | ||
} | ||
|
||
const VehicleServiceDashboard: React.FC<VehicleServiceDashboardProps> = ({ services }) => { | ||
const urlParams = new URLSearchParams(window.location.search); | ||
const VIN = urlParams.get("VIN"); | ||
return ( | ||
<> | ||
<PageHeader title={`Service History for VIN: ${VIN}`} /> | ||
<Row gutter={[16, 24]}> | ||
{services.map((service: Service) => ( | ||
<Col span={8} key={service.id}> | ||
<Card hoverable className="dashboard-card" title={service.problem_details}> | ||
<Meta | ||
title={service.status} | ||
description={service.created_on} | ||
/> | ||
<p> | ||
Vehicle VIN: {service.vehicle.vin} | ||
</p> | ||
<p> | ||
Owner email-id: | ||
{service.vehicle.owner.email} | ||
</p> | ||
<p> | ||
Owner Phone No.: | ||
{service.vehicle.owner.number} | ||
</p> | ||
|
||
{/* If status is completed, show report link */} | ||
<a href={`/service-report?reportId=${service.id}`}>View Report</a> | ||
</Card> | ||
</Col> | ||
))} | ||
</Row> | ||
</> | ||
); | ||
}; | ||
|
||
export default VehicleServiceDashboard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 0 additions & 64 deletions
64
services/web/src/containers/mechanicDashboard/mechanicDashboard.js
This file was deleted.
Oops, something went wrong.
76 changes: 76 additions & 0 deletions
76
services/web/src/containers/mechanicDashboard/mechanicDashboard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import React, { useState, useEffect } from "react"; | ||
|
||
import { connect, ConnectedProps } from "react-redux"; | ||
import { Modal } from "antd"; | ||
import { getMechanicServicesAction } from "../../actions/userActions"; | ||
import MechanicDashboard from "../../components/mechanicDashboard/mechanicDashboard"; | ||
import responseTypes from "../../constants/responseTypes"; | ||
import { FAILURE_MESSAGE } from "../../constants/messages"; | ||
|
||
interface RootState { | ||
userReducer: { | ||
accessToken: string; | ||
}; | ||
} | ||
|
||
interface Service { | ||
id: string; | ||
problem_details: string; | ||
created_on: string; | ||
vehicle: { | ||
owner: { | ||
email: string; | ||
number: string; | ||
}; | ||
}; | ||
} | ||
|
||
const mapStateToProps = (state: RootState) => ({ | ||
accessToken: state.userReducer.accessToken, | ||
}); | ||
|
||
const mapDispatchToProps = { | ||
getServices: getMechanicServicesAction, | ||
}; | ||
|
||
const connector = connect(mapStateToProps, mapDispatchToProps); | ||
|
||
type PropsFromRedux = ConnectedProps<typeof connector>; | ||
|
||
const MechanicDashboardContainer: React.FC<PropsFromRedux> = ({ accessToken, getServices }) => { | ||
const [services, setServices] = useState<Service[]>([]); | ||
|
||
useEffect(() => { | ||
const callback = (res: string, data: Service[] | string) => { | ||
if (res === responseTypes.SUCCESS) { | ||
setServices(data as Service[]); | ||
} else { | ||
Modal.error({ | ||
title: FAILURE_MESSAGE, | ||
content: data as string, | ||
}); | ||
} | ||
}; | ||
getServices({ accessToken, callback }); | ||
}, [accessToken, getServices]); | ||
const typedServices: Service[] = services; | ||
|
||
return <MechanicDashboard services={services} />; | ||
}; | ||
|
||
export default connector(MechanicDashboardContainer); |
Oops, something went wrong.