61 lines
2.6 KiB
Python
61 lines
2.6 KiB
Python
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QLineEdit, QPushButton, QFormLayout, QMessageBox, QGroupBox, QHBoxLayout
|
|
from src.business_info_widget import BusinessInfoWidget # 사업자 정보 위젯 import
|
|
from src.config_handler import *
|
|
|
|
class MarketConfigWidget(QWidget):
|
|
def __init__(self, business_number, parent=None):
|
|
super().__init__(parent)
|
|
self.business_number = business_number
|
|
self.layout = QVBoxLayout(self)
|
|
|
|
self.businessInfoWidget = BusinessInfoWidget(self)
|
|
self.layout.addWidget(self.createGroupBox('사업자 정보', self.businessInfoWidget))
|
|
|
|
# 마켓 설정 필드 예시
|
|
self.coupangLayout = QFormLayout()
|
|
self.coupangApiKeyInput = QLineEdit(self)
|
|
self.coupangLayout.addRow(QLabel('쿠팡 API Key:'), self.coupangApiKeyInput)
|
|
self.layout.addLayout(self.coupangLayout)
|
|
|
|
# 마켓 설정 적용 버튼
|
|
self.applyMarketSettingsBtn = QPushButton('마켓 설정 적용', self)
|
|
self.applyMarketSettingsBtn.clicked.connect(self.applyMarketSettings)
|
|
self.layout.addWidget(self.applyMarketSettingsBtn)
|
|
|
|
# "사업자 변경 실행" 버튼 추가
|
|
self.executeChangeBtn = QPushButton('사업자 변경 실행', self)
|
|
self.executeChangeBtn.clicked.connect(self.executeChange)
|
|
self.layout.addWidget(self.executeChangeBtn)
|
|
|
|
def createGroupBox(self, title, widget):
|
|
groupBox = QGroupBox(title)
|
|
layout = QHBoxLayout()
|
|
layout.addWidget(widget)
|
|
groupBox.setLayout(layout)
|
|
return groupBox
|
|
|
|
def applyMarketSettings(self):
|
|
config = load_config()
|
|
business_number = self.business_number # 예: "사업자1"
|
|
|
|
# 사업자 정보 저장
|
|
config[business_number] = {
|
|
'name': self.businessInfoWidget.businessNameInput.text(),
|
|
'number': self.businessInfoWidget.businessNumberInput.text(),
|
|
'phone': self.businessInfoWidget.businessPhoneInput.text(),
|
|
'address': self.businessInfoWidget.businessAddressInput.text(),
|
|
'card': self.businessInfoWidget.connectedCardInput.text()
|
|
}
|
|
|
|
# 마켓 설정 저장 (쿠팡 예시)
|
|
market_key = f"{business_number}_coupang"
|
|
config[market_key] = {
|
|
'api_key': self.coupangApiKeyInput.text()
|
|
}
|
|
|
|
# 추가 마켓 설정 저장 필요 시 여기에 구현...
|
|
|
|
# 변경된 설정을 파일에 저장
|
|
save_config(config)
|
|
|
|
QMessageBox.information(self, "성공", "설정이 성공적으로 적용되었습니다.") |