출발지 목적지 선택
This commit is contained in:
@@ -271,6 +271,9 @@ export class ButtonActionExecutor {
|
||||
case "geolocation":
|
||||
return await this.handleGeolocation(config, context);
|
||||
|
||||
case "swap_fields":
|
||||
return await this.handleSwapFields(config, context);
|
||||
|
||||
case "update_field":
|
||||
return await this.handleUpdateField(config, context);
|
||||
|
||||
@@ -3412,6 +3415,59 @@ export class ButtonActionExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 필드 값 교환 액션 처리 (예: 출발지 ↔ 도착지)
|
||||
*/
|
||||
private static async handleSwapFields(config: ButtonActionConfig, context: ButtonActionContext): Promise<boolean> {
|
||||
try {
|
||||
console.log("🔄 필드 값 교환 액션 실행:", { config, context });
|
||||
|
||||
const { formData, onFormDataChange } = context;
|
||||
|
||||
// 교환할 필드 확인
|
||||
const fieldA = config.swapFieldA;
|
||||
const fieldB = config.swapFieldB;
|
||||
|
||||
if (!fieldA || !fieldB) {
|
||||
toast.error("교환할 필드가 설정되지 않았습니다.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 현재 값 가져오기
|
||||
const valueA = formData?.[fieldA];
|
||||
const valueB = formData?.[fieldB];
|
||||
|
||||
console.log("🔄 교환 전:", { [fieldA]: valueA, [fieldB]: valueB });
|
||||
|
||||
// 값 교환
|
||||
if (onFormDataChange) {
|
||||
onFormDataChange(fieldA, valueB);
|
||||
onFormDataChange(fieldB, valueA);
|
||||
}
|
||||
|
||||
// 관련 필드도 함께 교환 (예: 위도/경도)
|
||||
if (config.swapRelatedFields && config.swapRelatedFields.length > 0) {
|
||||
for (const related of config.swapRelatedFields) {
|
||||
const relatedValueA = formData?.[related.fieldA];
|
||||
const relatedValueB = formData?.[related.fieldB];
|
||||
if (onFormDataChange) {
|
||||
onFormDataChange(related.fieldA, relatedValueB);
|
||||
onFormDataChange(related.fieldB, relatedValueA);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log("🔄 교환 후:", { [fieldA]: valueB, [fieldB]: valueA });
|
||||
|
||||
toast.success(config.successMessage || "값이 교환되었습니다.");
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error("❌ 필드 값 교환 오류:", error);
|
||||
toast.error(config.errorMessage || "값 교환 중 오류가 발생했습니다.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 필드 값 변경 액션 처리 (예: status를 active로 변경)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user