Skip to content

Commit

Permalink
Merge pull request #69 from CMU-17-356/rsantoni
Browse files Browse the repository at this point in the history
Introduced actual api functionality in employee order dashboard, pulling orders directly from API.
  • Loading branch information
santoniriccardo authored Mar 1, 2022
2 parents f19494a + 511243c commit f17bc32
Show file tree
Hide file tree
Showing 16 changed files with 272 additions and 272 deletions.
Binary file modified .DS_Store
Binary file not shown.
93 changes: 93 additions & 0 deletions backend/postman/Dronuts.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,99 @@
}
},
"response": []
},
{
"name": "Drone Creation",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"battery_life\": 12,\n \"critical\": false\n}"
},
"url": {
"raw": "http://localhost:3001/api/v1/drones",
"protocol": "http",
"host": [
"localhost"
],
"port": "3001",
"path": [
"api",
"v1",
"drones"
]
}
},
"response": []
},
{
"name": "Location Creation",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"street_address\": \"5318 beeler street\",\n \"city\": \"Pittsburgh\",\n \"state\": \"PA\",\n \"zipcode\": \"15217\"\n}"
},
"url": {
"raw": "http://localhost:3001/api/v1/locations",
"protocol": "http",
"host": [
"localhost"
],
"port": "3001",
"path": [
"api",
"v1",
"locations"
]
}
},
"response": []
},
{
"name": "Order Creation",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"customer\": \"62156bc7d87cc8c8385ae3e2\",\n \"drone\": {\"battery_life\": 12, \"critical\": false},\n \"location\": \"621d97a5e5b76f899d2f88f4\",\n \"items\": [],\n \"price\": 12.12,\n \"status\": \"Preparing\"\n}"
},
"url": {
"raw": "http://localhost:3001/api/v1/orders",
"protocol": "http",
"host": [
"localhost"
],
"port": "3001",
"path": [
"api",
"v1",
"orders"
]
}
},
"response": []
}
],
"protocolProfileBehavior": {}
Expand Down
6 changes: 2 additions & 4 deletions backend/src/models/drone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
import mongoose, { Schema, Document, Model } from 'mongoose';
import { LocationInterface, LocationSchema } from './location';



export interface DroneInterface extends Document {
battery_life: number,
drone_location: LocationInterface,
// location: LocationInterface,
critical: boolean
}

export const DroneSchema = new Schema({
battery_life: {type: Number, required: true},
drone_location: {type: LocationSchema, required: true},
// location: {type: LocationSchema, required: true},
critical: {type: Boolean, required: true},
});

Expand Down
20 changes: 14 additions & 6 deletions backend/src/models/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,25 @@ export interface OrderInterface extends Document {
drone: DroneInterface,
location: LocationInterface,
store: StoreInterface,
order_items: [DonutInterface]
order_total: number
items: [DonutInterface],
total: number,
status: string,
start_time: Date,
end_time: Date
}

export const OrderSchema = new Schema({
customer: {type: CustomerSchema, required: true},
customer: { type: mongoose.Schema.Types.ObjectId,
ref: "CustomerSchema"
},
drone: {type: DroneSchema, required: true},
location: {type: LocationSchema, required: true},
store: {type: StoreSchema, required: true},
order_items: {type: [DonutSchema], required: true},
order_price: {type: Number, required: true}
store: {type: StoreSchema},
items: {type: [DonutSchema], required: true},
price: {type: Number, required: true},
status: {type: String, enum: ["Accepted", "Preparing", "Delivering", "Delivered", "Canceled"], required: true},
start_time: {type: Date, default: Date.now},
end_time: {type: Date}
});

export const OrderModel: Model<OrderInterface> = mongoose.model('Order', OrderSchema);
2 changes: 1 addition & 1 deletion backend/src/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class Routes {
app.use('/api/v1/orders', orderRouter);
app.use('/api/v1/locations', locationRouter);
app.use('/api/v1/donuts', donutRouter);
app.use('api/v1/drones', droneRouter);
app.use('/api/v1/drones', droneRouter);
}
}

Expand Down
4 changes: 2 additions & 2 deletions backend/tests/models/order.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ describe('order test', function() {

it('should take on assigned values', () => {
const c = new OrderModel();
c.order_total = 11.50
c.total = 11.50

expect(c.order_total).toEqual(11.50);
expect(c.total).toEqual(11.50);
});

it('should be invalid if a field is empty', () => {
Expand Down
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "dronuts",
"version": "0.1.0",
"private": true,
"proxy": "http://localhost:3001/api/v1",
"dependencies": {
"@mui/icons-material": "^5.4.1",
"@mui/lab": "^5.0.0-alpha.69",
Expand Down
29 changes: 12 additions & 17 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
import CssBaseline from '@mui/material/CssBaseline';
import { ThemeProvider } from '@mui/material/styles';
import {
BrowserRouter as Router, Route, Routes
} from "react-router-dom";
import './App.css';

import Cart from './components/Customer/Cart';
import CustomerMenu from './components/Customer/CustomerMenu';
import TrackOrder from './components/Customer/TrackOrder';
import EmployeeDashboard from './components/Employee/EmployeeDashboard';
import Home from './components/Home/Home';
import { ThemeProvider } from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
import ResponsiveAppBar from './components/Home/ResponsiveAppBar';
import theme from "./components/Theme/Theme";

import ResponsiveAppBar from './components/Home/ResponsiveAppBar';
import CustomerMenu from './components/Customer/CustomerMenu';
import TrackOrder from './components/Customer/TrackOrder';
import Cart from './components/Customer/Cart';
import Dashboard from './components/Dashboard/Dashboard';

import {
BrowserRouter as Router,
Routes,
Route,
Link,
useMatch,
useParams
} from "react-router-dom";


function App() {
return (
Expand All @@ -30,7 +25,7 @@ function App() {
<Route path="/customer" element={<CustomerMenu />} />
<Route path="/order" element={<TrackOrder />} />
<Route path="/cart" element={<Cart />} />
<Route path="/employee" element={<Dashboard />} />
<Route path="/employee" element={<EmployeeDashboard />} />
<Route path="" element={<Home />} />
</Routes>
</ThemeProvider>
Expand Down
71 changes: 0 additions & 71 deletions frontend/src/components/Dashboard/Chart.tsx

This file was deleted.

99 changes: 0 additions & 99 deletions frontend/src/components/Dashboard/Dashboard.tsx

This file was deleted.

Loading

0 comments on commit f17bc32

Please sign in to comment.