Skip to content

Commit

Permalink
ping server
Browse files Browse the repository at this point in the history
  • Loading branch information
Nobatgeldi committed Oct 18, 2023
1 parent 04f803c commit 19e20d5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/covisart/Product.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { Space, Table, notification } from 'antd';
import { Space, Table, notification } from 'antd';
import { PhoneOutlined } from '@ant-design/icons';

import { Tab, Tabs, TabList, TabPanel } from 'react-tabs';
Expand All @@ -11,7 +11,7 @@ import { useSnapshot } from 'valtio'
import { state } from './store'
import Configuration from './Configuration'
import ReactGA from "react-ga4";
import { Order } from './system/OrderRequest';
import { Order, PingAPI } from './system/OrderRequest';

const Product = () => {
const [selectedTab, setSelectedTab] = useState(0);
Expand Down Expand Up @@ -40,14 +40,14 @@ const Product = () => {
'Dear ' + state.name + ', we got your order. Our sales team will contact with you for further operation. Thanks for your interest our NGS-360 family motion platform.',
duration: 0,
placement,
icon:<PhoneOutlined style={{ color: 'green' }}/>
icon: <PhoneOutlined style={{ color: 'green' }} />
});
};

const handleSubmit = event => {
event.preventDefault(); // 👈️ prevent page refresh

Order(state)
PingAPI();
Order(state);
openNotification('bottomRight')
};
return (
Expand Down
2 changes: 1 addition & 1 deletion src/covisart/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const state = proxy({
decal: 'three2',
motors: ['BECKHOFF_AM8552', 'BECKHOFF_AM8052'],
motor: 'BECKHOFF_AM8552',
speed: 1
speed: 1,
})

export { state }
16 changes: 14 additions & 2 deletions src/covisart/system/OrderRequest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Axios from "axios";
import { useSnapshot } from 'valtio'
import { state } from '../store'

export const Order = (state) => {
export const Order = async (state) => {
const data = {
email: state.email,
name: state.name,
Expand All @@ -13,11 +15,21 @@ export const Order = (state) => {
"string"
]
}
Axios.post("https://ngsmarket.azurewebsites.net/api/Orders/", data,)
const resp = await Axios.post("https://ngsmarket.azurewebsites.net/api/Orders/", data,)
.then((res) => {
console.log(res)
})
.catch((err) => {
console.log(err)
});
};

export const PingAPI = () => {
const resp = Axios.get("https://ngsmarket.azurewebsites.net/api/Orders/")
.then((res) => {
console.log(res)
})
.catch((err) => {
console.log(err)
});
};

0 comments on commit 19e20d5

Please sign in to comment.