Reverted to edit edt-f8847c66-50e6-4952-bb7a-178d44a26294: "Fix edit functionality
The edit functionality was not working as expected. This commit addresses the issue."
This commit is contained in:
@@ -3,6 +3,7 @@ import React, { useCallback, useEffect, useState, useRef } from 'react';
|
|||||||
import { getAppVersionInfo, isAndroidPlatform } from '@/utils/platform';
|
import { getAppVersionInfo, isAndroidPlatform } from '@/utils/platform';
|
||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
|
import { Textarea } from '@/components/ui/textarea';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
|
|
||||||
interface AppVersionInfoProps {
|
interface AppVersionInfoProps {
|
||||||
@@ -11,8 +12,6 @@ interface AppVersionInfoProps {
|
|||||||
editable?: boolean;
|
editable?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const STORAGE_KEY = 'app_version_custom_info';
|
|
||||||
|
|
||||||
const AppVersionInfo: React.FC<AppVersionInfoProps> = ({
|
const AppVersionInfo: React.FC<AppVersionInfoProps> = ({
|
||||||
className,
|
className,
|
||||||
showDevInfo = true,
|
showDevInfo = true,
|
||||||
@@ -33,8 +32,8 @@ const AppVersionInfo: React.FC<AppVersionInfoProps> = ({
|
|||||||
// 편집 가능한 필드를 위한 상태
|
// 편집 가능한 필드를 위한 상태
|
||||||
const [editableVersionName, setEditableVersionName] = useState('1.0.1');
|
const [editableVersionName, setEditableVersionName] = useState('1.0.1');
|
||||||
const [editableBuildNumber, setEditableBuildNumber] = useState('2');
|
const [editableBuildNumber, setEditableBuildNumber] = useState('2');
|
||||||
const [editableDetailText, setEditableDetailText] = useState('The first build');
|
const [companyText, setCompanyText] = useState('ZELLYY CLOUD');
|
||||||
const [editableCompanyText, setEditableCompanyText] = useState('ZELLYY CLOUD');
|
const [detailText, setDetailText] = useState('The first build');
|
||||||
const [isEditing, setIsEditing] = useState(false);
|
const [isEditing, setIsEditing] = useState(false);
|
||||||
|
|
||||||
// 버전 정보 가져오기
|
// 버전 정보 가져오기
|
||||||
@@ -85,24 +84,6 @@ const AppVersionInfo: React.FC<AppVersionInfoProps> = ({
|
|||||||
// 초기화 완료 후 한번 더 시도하도록 설정
|
// 초기화 완료 후 한번 더 시도하도록 설정
|
||||||
const initialLoadAttemptedRef = useRef(false);
|
const initialLoadAttemptedRef = useRef(false);
|
||||||
|
|
||||||
// 저장된 커스텀 정보 로드
|
|
||||||
useEffect(() => {
|
|
||||||
if (editable) {
|
|
||||||
try {
|
|
||||||
const savedInfo = localStorage.getItem(STORAGE_KEY);
|
|
||||||
if (savedInfo) {
|
|
||||||
const parsedInfo = JSON.parse(savedInfo);
|
|
||||||
if (parsedInfo.versionName) setEditableVersionName(parsedInfo.versionName);
|
|
||||||
if (parsedInfo.buildNumber) setEditableBuildNumber(parsedInfo.buildNumber);
|
|
||||||
if (parsedInfo.detailText) setEditableDetailText(parsedInfo.detailText);
|
|
||||||
if (parsedInfo.companyText) setEditableCompanyText(parsedInfo.companyText);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error('저장된 버전 정보 로드 실패:', e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [editable]);
|
|
||||||
|
|
||||||
// 컴포넌트 마운트 시 즉시 실행 (IIFE)
|
// 컴포넌트 마운트 시 즉시 실행 (IIFE)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!editable) {
|
if (!editable) {
|
||||||
@@ -130,27 +111,43 @@ const AppVersionInfo: React.FC<AppVersionInfoProps> = ({
|
|||||||
}
|
}
|
||||||
}, [fetchVersionInfo, error, loading, editable]);
|
}, [fetchVersionInfo, error, loading, editable]);
|
||||||
|
|
||||||
// 편집 모드 토글
|
// 변경사항 저장 처리
|
||||||
const toggleEditMode = () => {
|
const handleSaveChanges = () => {
|
||||||
setIsEditing(!isEditing);
|
// 편집 모드 종료
|
||||||
|
setIsEditing(false);
|
||||||
|
|
||||||
|
// 실제 저장 로직 구현 (로컬 스토리지에 저장)
|
||||||
|
try {
|
||||||
|
const versionData = {
|
||||||
|
versionName: editableVersionName,
|
||||||
|
buildNumber: parseInt(editableBuildNumber, 10),
|
||||||
|
companyText,
|
||||||
|
detailText
|
||||||
|
};
|
||||||
|
localStorage.setItem('customVersionInfo', JSON.stringify(versionData));
|
||||||
|
console.log('변경사항 저장 완료:', versionData);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('변경사항 저장 실패:', error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 변경사항 저장
|
// 로컬 스토리지에서 저장된 버전 정보 로드
|
||||||
const handleSaveChanges = () => {
|
useEffect(() => {
|
||||||
// 로컬 스토리지에 저장
|
if (editable) {
|
||||||
try {
|
try {
|
||||||
const customInfo = {
|
const savedData = localStorage.getItem('customVersionInfo');
|
||||||
versionName: editableVersionName,
|
if (savedData) {
|
||||||
buildNumber: editableBuildNumber,
|
const parsedData = JSON.parse(savedData);
|
||||||
detailText: editableDetailText,
|
setEditableVersionName(parsedData.versionName || '1.0.1');
|
||||||
companyText: editableCompanyText
|
setEditableBuildNumber(String(parsedData.buildNumber || 2));
|
||||||
};
|
setCompanyText(parsedData.companyText || 'ZELLYY CLOUD');
|
||||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(customInfo));
|
setDetailText(parsedData.detailText || 'The first build');
|
||||||
} catch (e) {
|
|
||||||
console.error('커스텀 정보 저장 실패:', e);
|
|
||||||
}
|
}
|
||||||
setIsEditing(false);
|
} catch (error) {
|
||||||
};
|
console.error('저장된 버전 정보 로드 실패:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [editable]);
|
||||||
|
|
||||||
if (editable) {
|
if (editable) {
|
||||||
return (
|
return (
|
||||||
@@ -159,7 +156,7 @@ const AppVersionInfo: React.FC<AppVersionInfoProps> = ({
|
|||||||
<div>
|
<div>
|
||||||
<Label htmlFor="versionName" className="text-gray-600 text-center block">앱 버전</Label>
|
<Label htmlFor="versionName" className="text-gray-600 text-center block">앱 버전</Label>
|
||||||
{isEditing ? (
|
{isEditing ? (
|
||||||
<div className="flex gap-2 items-center mt-1">
|
<div className="flex gap-2 mt-1">
|
||||||
<Input
|
<Input
|
||||||
id="versionName"
|
id="versionName"
|
||||||
value={editableVersionName}
|
value={editableVersionName}
|
||||||
@@ -181,41 +178,40 @@ const AppVersionInfo: React.FC<AppVersionInfoProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Label htmlFor="detailText" className="text-gray-600 text-center block">세부 설명</Label>
|
<Label htmlFor="notes" className="text-gray-600 text-center block">세부 설명</Label>
|
||||||
{isEditing ? (
|
{isEditing ? (
|
||||||
<Input
|
<Textarea
|
||||||
id="detailText"
|
id="detailText"
|
||||||
value={editableDetailText}
|
value={detailText}
|
||||||
onChange={(e) => setEditableDetailText(e.target.value)}
|
onChange={(e) => setDetailText(e.target.value)}
|
||||||
className="text-center mt-1"
|
className="text-center min-h-[80px] mt-1"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="p-2 text-base mt-1 py-0 text-center">{editableDetailText}</div>
|
<div className="p-2 text-base mt-1 py-0 text-center">{detailText}</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mt-[50px] text-center">
|
<div className="mt-[70px] text-center">
|
||||||
{isEditing ? (
|
{isEditing ? (
|
||||||
<Input
|
<Input
|
||||||
id="companyText"
|
id="companyText"
|
||||||
value={editableCompanyText}
|
value={companyText}
|
||||||
onChange={(e) => setEditableCompanyText(e.target.value)}
|
onChange={(e) => setCompanyText(e.target.value)}
|
||||||
className="text-center font-semibold my-[50px]"
|
className="text-center text-gray-400 font-semibold text-lg"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<p className="text-gray-400 font-semibold text-lg my-[50px]">{editableCompanyText}</p>
|
<p className="text-gray-400 font-semibold text-lg my-[50px]">{companyText}</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-center gap-2">
|
<div className="flex justify-center mt-4">
|
||||||
{isEditing ? (
|
{isEditing ? (
|
||||||
<Button onClick={handleSaveChanges} variant="outline" size="sm">
|
<div className="flex gap-2">
|
||||||
저장
|
<Button variant="outline" onClick={() => setIsEditing(false)}>취소</Button>
|
||||||
</Button>
|
<Button onClick={handleSaveChanges}>저장</Button>
|
||||||
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<Button onClick={toggleEditMode} variant="outline" size="sm">
|
<Button onClick={() => setIsEditing(true)}>편집</Button>
|
||||||
편집
|
|
||||||
</Button>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user