From c1be1893f5432789d5af22738b0d853e7287208d Mon Sep 17 00:00:00 2001 From: leeheejin Date: Mon, 15 Dec 2025 16:45:26 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A7=80=EA=B8=88=EC=9D=80=20=EC=B6=9C?= =?UTF-8?q?=EB=B0=9C=EC=A7=80=EB=AA=A9=EC=A0=81=EC=A7=80=EA=B0=80=20?= =?UTF-8?q?=EB=8B=AC=EB=9D=BC=EB=8F=84=20=EA=B0=95=EC=A0=9C=EB=A1=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=EC=9D=B4=20=EA=B0=80=EB=8A=A5=ED=95=A9?= =?UTF-8?q?=EB=8B=88=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/lib/utils/buttonActions.ts | 64 +++++++++++++++-------------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/frontend/lib/utils/buttonActions.ts b/frontend/lib/utils/buttonActions.ts index c039d55a..4d5915e9 100644 --- a/frontend/lib/utils/buttonActions.ts +++ b/frontend/lib/utils/buttonActions.ts @@ -4116,39 +4116,43 @@ export class ButtonActionExecutor { try { console.log("๐Ÿ›‘ [handleTrackingStop] ์œ„์น˜ ์ถ”์  ์ข…๋ฃŒ:", { config, context }); - // ์ถ”์  ์ค‘์ธ์ง€ ํ™•์ธ - if (!this.trackingIntervalId) { - toast.warning("์ง„ํ–‰ ์ค‘์ธ ์œ„์น˜ ์ถ”์ ์ด ์—†์Šต๋‹ˆ๋‹ค."); - return false; + // ์ถ”์  ์ค‘์ธ์ง€ ํ™•์ธ (์ƒˆ๋กœ๊ณ ์นจ ํ›„์—๋„ DB ์ƒํƒœ ๊ธฐ๋ฐ˜ ์ข…๋ฃŒ ๊ฐ€๋Šฅํ•˜๋„๋ก ์ˆ˜์ •) + const isTrackingActive = !!this.trackingIntervalId; + + if (!isTrackingActive) { + // ์ถ”์  ์ค‘์ด ์•„๋‹ˆ์–ด๋„ DB ์ƒํƒœ ๋ณ€๊ฒฝ์€ ์ง„ํ–‰ (์ƒˆ๋กœ๊ณ ์นจ ํ›„ ์ข…๋ฃŒ ์ง€์›) + console.log("โš ๏ธ [handleTrackingStop] trackingIntervalId ์—†์Œ - DB ์ƒํƒœ ๊ธฐ๋ฐ˜ ์ข…๋ฃŒ ์ง„ํ–‰"); + } else { + // ํƒ€์ด๋จธ ์ •๋ฆฌ (์ถ”์  ์ค‘์ธ ๊ฒฝ์šฐ์—๋งŒ) + clearInterval(this.trackingIntervalId); + this.trackingIntervalId = null; } - // ํƒ€์ด๋จธ ์ •๋ฆฌ - clearInterval(this.trackingIntervalId); - this.trackingIntervalId = null; - const tripId = this.currentTripId; - // ๋งˆ์ง€๋ง‰ ์œ„์น˜ ์ €์žฅ (trip_status๋ฅผ completed๋กœ) - const departure = - this.trackingContext?.formData?.[this.trackingConfig?.trackingDepartureField || "departure"] || null; - const arrival = this.trackingContext?.formData?.[this.trackingConfig?.trackingArrivalField || "arrival"] || null; - const departureName = this.trackingContext?.formData?.["departure_name"] || null; - const destinationName = this.trackingContext?.formData?.["destination_name"] || null; - const vehicleId = - this.trackingContext?.formData?.[this.trackingConfig?.trackingVehicleIdField || "vehicle_id"] || null; + // ๋งˆ์ง€๋ง‰ ์œ„์น˜ ์ €์žฅ (์ถ”์  ์ค‘์ด์—ˆ๋˜ ๊ฒฝ์šฐ์—๋งŒ) + if (isTrackingActive) { + const departure = + this.trackingContext?.formData?.[this.trackingConfig?.trackingDepartureField || "departure"] || null; + const arrival = this.trackingContext?.formData?.[this.trackingConfig?.trackingArrivalField || "arrival"] || null; + const departureName = this.trackingContext?.formData?.["departure_name"] || null; + const destinationName = this.trackingContext?.formData?.["destination_name"] || null; + const vehicleId = + this.trackingContext?.formData?.[this.trackingConfig?.trackingVehicleIdField || "vehicle_id"] || null; - await this.saveLocationToHistory( - tripId, - departure, - arrival, - departureName, - destinationName, - vehicleId, - "completed", - ); + await this.saveLocationToHistory( + tripId, + departure, + arrival, + departureName, + destinationName, + vehicleId, + "completed", + ); + } - // ๐Ÿ†• ๊ฑฐ๋ฆฌ/์‹œ๊ฐ„ ๊ณ„์‚ฐ ๋ฐ ์ €์žฅ - if (tripId) { + // ๐Ÿ†• ๊ฑฐ๋ฆฌ/์‹œ๊ฐ„ ๊ณ„์‚ฐ ๋ฐ ์ €์žฅ (์ถ”์  ์ค‘์ด์—ˆ๋˜ ๊ฒฝ์šฐ์—๋งŒ) + if (isTrackingActive && tripId) { try { const tripStats = await this.calculateTripStats(tripId); console.log("๐Ÿ“Š ์šดํ–‰ ํ†ต๊ณ„:", tripStats); @@ -4260,9 +4264,9 @@ export class ButtonActionExecutor { } } - // ์ƒํƒœ ๋ณ€๊ฒฝ (vehicles ํ…Œ์ด๋ธ” ๋“ฑ) - const effectiveConfig = config.trackingStatusOnStop ? config : this.trackingConfig; - const effectiveContext = context.userId ? context : this.trackingContext; + // ์ƒํƒœ ๋ณ€๊ฒฝ (vehicles ํ…Œ์ด๋ธ” ๋“ฑ) - ์ƒˆ๋กœ๊ณ ์นจ ํ›„์—๋„ ๋™์ž‘ํ•˜๋„๋ก config ์šฐ์„  ์‚ฌ์šฉ + const effectiveConfig = config.trackingStatusOnStop ? config : this.trackingConfig || config; + const effectiveContext = context.userId ? context : this.trackingContext || context; if (effectiveConfig?.trackingStatusOnStop && effectiveConfig?.trackingStatusField && effectiveContext) { try {