chore: rm unused files

This commit is contained in:
dancingCycle 2022-08-25 21:57:10 +02:00
parent bac4e9126b
commit 66f0b648dc
2 changed files with 0 additions and 108 deletions

View File

@ -1,53 +0,0 @@
import React, { useEffect, useState } from 'react';
import axios from 'axios';
import TableSwitch from './table-switch-trip-calendar';
import PropTypes from 'prop-types';
const TablePage = ({ agencyIdName }) => {
if(agencyIdName !== undefined){
//console.log('TablePage agencyIdName:'+JSON.stringify(agencyIdName));
//console.log('TablePage agencyIdName.length:'+agencyIdName.length);
const agencyId=agencyIdName.agency_id;
console.log('TablePage agencyId:'+agencyId);
const agencyName=agencyIdName.agency_name;
console.log('TablePage agencyName:'+agencyName);
/*store and initialise data in function component state*/
const [tripCalendar, setTripCalendar] = useState({});
const getTripCalendar = async () => {
try {
/*get trip calendar*/
const address=`https://v1gtfs.vbn.api.swingbe.de/trip-calendar-by-agency-id?agencyid=${agencyId}`;
console.log('address:'+address);
/*TODO handle errors: https://www.valentinog.com/blog/await-react/*/
const res = await axios.get(address);
let aryTripCalendar = res.data;
console.log('aryTripCalendar.length:'+aryTripCalendar.length);
setTripCalendar(aryTripCalendar);
} catch (err) {
console.error('err.message: ' + err.message);
}
};
/*this hook is run after a DOM update. Changing state might result in an infinite loop*/
/*hook need to be placed in body of the function component in which it is used*/
useEffect(() => {
getTripCalendar();
/*use an empty dependency array to ensure the hook is running only once*/
/*TODO study dependency array: https://reactjs.org/docs/hooks-effect.html*/
}, []);
return (
<>
<TableSwitch
tripCalendar={tripCalendar}
agencyId={agencyId}
agencyName={agencyName}
/>
</>
);
}else{
return <p>Table Page loading...</p>
}
};
TablePage.propTypes = {
agencyIdName: PropTypes.object
};
export default TablePage;

View File

@ -1,55 +0,0 @@
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import Table from 'react-bootstrap/Table';
import TableHead from './agency-id-name-table-head';
import TableEntry from './agency-id-name-table-entry';
/*the simplest way to define a component is to write a JavaScript function*/
/*destructure props object*/
function TableSwitch ({
tripCalendar,
agencyId,
agencyName
}) {
if(tripCalendar!==undefined &&
agencyId!==undefined &&
agencyName!==undefined){
console.log('TableSwitch agencyId: '+agencyId);
console.log('TableSwitch agencyName: '+agencyName);
console.log('TableSwitch tripCalendar.length: '+Object.keys(tripCalendar).length);
/*return a React element*/
return (
<>
<Table
striped
bordered
hover
size="sm"
variant="dark"
responsive
>
<thead>
<TableHead
tripCalendar={tripCalendar}
/>
</thead>
<tbody>
<TableEntry
agencyId={agencyId}
agencyName={agencyName}
tripCalendar={tripCalendar}
/>
</tbody>
</Table>
</>
);
}else{
console.log('TableSwitch prop UNDEFINED');
return <p>Table loading...</p>
}
}
TableSwitch.propTypes = {
tripCalendar: PropTypes.object,
agencyId: PropTypes.string,
agencyName: PropTypes.string
};
export default TableSwitch;