Skip to content

Commit

Permalink
/oracle URL is added in terraform instead
Browse files Browse the repository at this point in the history
  • Loading branch information
lauren-mieczkowski committed Jan 16, 2024
1 parent 6dc7837 commit 01bf8b8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 244 deletions.
21 changes: 5 additions & 16 deletions src/connect/components/DeviceForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import ToggleButton from '@mui/material/ToggleButton';
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
import './mycomponent.css';
import CircularProgress from '@mui/material/CircularProgress';


const destinations = [
{ label: "deviceManagement.form.destination.options.s", value: "s3" },
{ label: "deviceManagement.form.destination.options.d", value: "dynamodb" },
Expand All @@ -35,7 +33,6 @@ const sources = [
{ label: "deviceManagement.form.source.options.h", value: "http" },
{ label: "deviceManagement.form.source.options.m", value: "mqtts" },
];

type DeviceFormProps = {
onAdd: (device: Partial<Device>) => void;
onClose: () => void;
Expand All @@ -45,7 +42,6 @@ type DeviceFormProps = {
device?: Device;
};


const DeviceForm = ({
onAdd,
onClose,
Expand All @@ -56,8 +52,7 @@ const DeviceForm = ({
}: DeviceFormProps) => {
const { t } = useTranslation();
const [loading, setLoading] = useState(false);
const oracle_baseURL: string | undefined = process.env.REACT_APP_ORACLE_URL; //`http://3.95.191.132:30806/oracle`
const oracleURL: string = `${oracle_baseURL}/oracle`
const oracleURL: string | undefined = process.env.REACT_APP_ORACLE_URL; //`http://3.95.191.132:30806/oracle`

// const handleMock = (values: Partial<Device>) => {
// if (device && device.deviceId) {
Expand All @@ -72,33 +67,30 @@ const DeviceForm = ({
if (!oracleURL) {
console.error('Oracle URL is not defined!');
return;}

setLoading(true);
console.log('Oracle URL:', oracleURL);

const response = await fetch(oracleURL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(values),
});

console.log("handling submit fetch");
console.log('values:',JSON.stringify(values));

if (response.ok) {
if (response.status === 200) {
alert('Successfully registered device!');
//handleMock
if (device && device.deviceId) {
onUpdate({ ...values, id: device.deviceId } as Device);
} else {
onAdd(values);
}
}
const responseData = await response;
console.log('Response:', responseData);
}
else {
const errorMessage = `Error with response!: ${response.status} ${response.statusText}`;
const errorMessage = `Error! response: ${response.status} ${response.statusText}`;
alert(errorMessage);
}
} catch (error: any) {
Expand All @@ -112,8 +104,6 @@ const DeviceForm = ({
};




// const findrapi = axios.create({
// baseURL: "http://3.95.191.132:30806",
// headers: {'Content-Type': 'application/json'}
Expand Down Expand Up @@ -213,7 +203,6 @@ const DeviceForm = ({
// };



const formik = useFormik({
initialValues: {
deviceId: device ? device.deviceId : "",
Expand Down
Loading

0 comments on commit 01bf8b8

Please sign in to comment.