Skip to content

Commit 52bc139

Browse files
committed
updates
1 parent 102e0c3 commit 52bc139

1 file changed

Lines changed: 32 additions & 55 deletions

File tree

client/src/containers/User/AvailableTable/AvailableTable.tsx

Lines changed: 32 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,33 @@ const AvailableTable: React.FC = () => {
728728
fetchDrivers();
729729
}, [fetchLoads, fetchDrivers]);
730730

731+
// // Auto-refresh token every 14 minutes
732+
// useEffect(() => {
733+
// const interval = setInterval(async () => {
734+
// const currentToken = getCookie("lb_access_token") || localStorage.getItem("lb_access_token");
735+
// if (!currentToken) return;
736+
737+
// try {
738+
// const resp = await axios.get(`${process.env.REACT_APP_SOCKET_IO_CLIENT_PORT || ""}/refresh-token`, {
739+
// headers: { Authorization: `Bearer ${currentToken}` },
740+
// });
741+
742+
// const newToken = resp.data?.access_token;
743+
// if (newToken) {
744+
// document.cookie = `lb_access_token=${newToken}; path=/; secure; samesite=lax`;
745+
// localStorage.setItem("lb_access_token", newToken);
746+
// setToken(newToken);
747+
// console.log("123Loadboard token refreshed automatically.");
748+
// }
749+
// } catch (err) {
750+
// console.error("Auto token refresh failed:", err);
751+
// setError("Automatic token refresh failed. Please reconnect.");
752+
// }
753+
// }, 14 * 60 * 1000); // 14 minutes
754+
755+
// return () => clearInterval(interval);
756+
// }, []);
757+
731758
// Handle form changes
732759
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement>) => {
733760
const { name, value } = e.target;
@@ -847,7 +874,7 @@ const AvailableTable: React.FC = () => {
847874
if (code) {
848875
try {
849876
localStorage.setItem("lb_auth_code", code);
850-
} catch {}
877+
} catch { }
851878
}
852879
}, [code]);
853880

@@ -947,62 +974,12 @@ const AvailableTable: React.FC = () => {
947974
</button>
948975
</div>
949976
{error && <p style={{ color: "red", marginTop: 8 }}>{error}</p>}
950-
{success && <p style={{ color: "green", marginTop: 8 }}>Search completed!</p>}
977+
{success && <p style={{ color: "green", marginTop: 8 }}>Search complete!</p>}
951978
</form>
952979

953-
<div ref={resultsRef} className={styles["at-scrollableTableContainer"]} style={{ marginTop: 18 }}>
954-
<div className={styles["at-scrollableTableWrapper"]} style={{ maxHeight: 400 }}>
955-
{searchResults.length === 0 && !loading ? (
956-
<div style={{ padding: 20, textAlign: "center" }}>No search results yet. Try a search.</div>
957-
) : (
958-
<table className={styles["at-table"]}>
959-
<thead>
960-
<tr>
961-
<th>Load ID</th>
962-
<th>Reference</th>
963-
<th>Company</th>
964-
<th>Delivery</th>
965-
<th>Stops</th>
966-
<th>Mileage</th>
967-
<th># Loads</th>
968-
<th>Pickup</th>
969-
<th>Equipment</th>
970-
<th>Note</th>
971-
<th>Status</th>
972-
<th>Origin</th>
973-
<th>Destination</th>
974-
</tr>
975-
</thead>
976-
<tbody>
977-
{searchResults.map((load) => (
978-
<tr key={load.id}>
979-
<td>{load.id}</td>
980-
<td>{load.postReference || load.description || "N/A"}</td>
981-
<td>{load.poster?.company || load.company || "N/A"}</td>
982-
<td>{load.deliveryDateTimeUtc ? new Date(load.deliveryDateTimeUtc).toLocaleString() : "N/A"}</td>
983-
<td>{load.numberOfStops ?? "N/A"}</td>
984-
<td>{load.computedMileage ?? "N/A"}</td>
985-
<td>{load.numberOfLoads ?? "N/A"}</td>
986-
<td>
987-
{load.pickupDateTimesUtc && load.pickupDateTimesUtc.length > 0
988-
? load.pickupDateTimesUtc.map((dt) => new Date(dt).toLocaleString()).join(", ")
989-
: "N/A"}
990-
</td>
991-
<td>
992-
{load.equipments && load.equipments.length > 0
993-
? load.equipments.map((e: any) => e.name || e.code || e).join(", ")
994-
: "N/A"}
995-
</td>
996-
<td>{load.privateLoadNote || ""}</td>
997-
<td>{load.status}</td>
998-
<td>{load.originLocation ? `${load.originLocation.city || ""}, ${load.originLocation.state || ""}` : "N/A"}</td>
999-
<td>{load.destinationLocation ? `${load.destinationLocation.city || ""}, ${load.destinationLocation.state || ""}` : "N/A"}</td>
1000-
</tr>
1001-
))}
1002-
</tbody>
1003-
</table>
1004-
)}
1005-
</div>
980+
{/* Search Results */}
981+
<div ref={resultsRef} style={{ marginTop: 20 }}>
982+
<Table data={searchResults} title="Search Results" isUser={false} showCompanyLink />
1006983
</div>
1007984
</section>
1008985
</div>

0 commit comments

Comments
 (0)