@@ -19,7 +19,7 @@ const app = express();
1919const server = http . createServer ( app ) ;
2020const io = socketIo ( server , {
2121 cors : {
22- origin : 'https ://core2.axleshift.com ' ,
22+ origin : 'http ://localhost:3000 ' ,
2323 methods : [ "GET" , "POST" ] ,
2424 } ,
2525} ) ;
@@ -31,7 +31,7 @@ if (!admin.apps.length) {
3131 } ) ;
3232}
3333app . use ( cors ( {
34- origin : [ 'https ://core2.axleshift.com ' ] ,
34+ origin : [ 'http ://localhost:3000 ' ] ,
3535 methods : [ 'GET' , 'POST' ] ,
3636 credentials : true
3737} ) ) ;
@@ -314,6 +314,28 @@ app.get('/driver/shipments', async (req, res) => {
314314 res . status ( 500 ) . json ( { success : false , message : "Server error" } )
315315 }
316316} )
317+ // Driver selects shipments to track
318+ app . post ( '/driver/select-shipment' , async ( req , res ) => {
319+ const { trackingNumber, driverUsername } = req . body ;
320+ console . log ( 'Received for assign:' , { trackingNumber, driverUsername } )
321+
322+ try {
323+ const shipment = await TrackData . findOne ( { trackingNumber } ) ;
324+
325+ if ( ! shipment ) {
326+ return res . status ( 404 ) . json ( { message : "Shipment not found" } ) ;
327+ }
328+
329+ shipment . driverUsername = driverUsername ;
330+ await shipment . save ( ) ;
331+
332+ res . json ( { message : "Shipment successfully assigned to the driver" , shipment } ) ;
333+ } catch ( error ) {
334+ console . error ( "Error assigning shipment:" , error ) ;
335+ res . status ( 500 ) . json ( { message : "Server error" } ) ;
336+ }
337+ } ) ;
338+
317339
318340// Email
319341app . post ( "/verify-email" , async ( req , res ) => {
0 commit comments