diff --git a/app/src/components/icons/ExportCommonIcons.tsx b/app/src/components/icons/ExportCommonIcons.tsx index 0bcb78c..b259666 100644 --- a/app/src/components/icons/ExportCommonIcons.tsx +++ b/app/src/components/icons/ExportCommonIcons.tsx @@ -1058,9 +1058,6 @@ export const SaveIcon = () => { ); }; - - - export const SaveVersionIcon = () => { return ( { fill="none" xmlns="http://www.w3.org/2000/svg" > - - - - + { ); }; + +export const RenameVersionIcon = () => { + return ( + + + + ); +}; + +export const FinishEditIcon = () => { + return ( + + + + + + + + + ); +}; diff --git a/app/src/components/layout/sidebarRight/versionHisory/VersionHistory.tsx b/app/src/components/layout/sidebarRight/versionHisory/VersionHistory.tsx index 20f0900..cc11c57 100644 --- a/app/src/components/layout/sidebarRight/versionHisory/VersionHistory.tsx +++ b/app/src/components/layout/sidebarRight/versionHisory/VersionHistory.tsx @@ -8,18 +8,19 @@ import { } from "../../../icons/ExportCommonIcons"; import RenameInput from "../../../ui/inputs/RenameInput"; import { useVersionStore } from "../../../../store/builder/store"; +import { generateUniqueId } from "../../../../functions/generateUniqueId"; const VersionHistory = () => { const userName = localStorage.getItem("userName") ?? "Anonymous"; - - const { versions, addVersion, setVersions } = useVersionStore(); + const { versions, addVersion, setVersions, updateVersion } = + useVersionStore(); const [selectedVersion, setSelectedVersion] = useState( versions.length > 0 ? versions[0] : null ); const addNewVersion = () => { const newVersion = { - id: crypto.randomUUID(), + id: generateUniqueId(), versionLabel: `v${versions.length + 1}.0`, versionName: "", timestamp: new Date().toLocaleDateString("en-US", { @@ -33,23 +34,21 @@ const VersionHistory = () => { const newVersions = [newVersion, ...versions]; addVersion(newVersion); setSelectedVersion(newVersion); - setVersions(newVersions); // bring new one to top + setVersions(newVersions); }; const handleSelectVersion = (version: any) => { setSelectedVersion(version); - - // Move selected version to top, keep others in same order const reordered = [version, ...versions.filter((v) => v.id !== version.id)]; setVersions(reordered); }; - const handleTimestampChange = (newTimestamp: string, index: number) => { - const updated = [...versions]; - updated[index].timestamp = newTimestamp; - - console.warn("Timestamp updated locally but not persisted in store."); - setVersions(updated); // Optional: persist timestamp change + const handleVersionNameChange = (newName: string, versionId: string) => { + const updated = versions.map((v) => + v.id === versionId ? { ...v, versionName: newName } : v + ); + setVersions(updated); + updateVersion(versionId, { versionName: newName }); }; return ( @@ -99,28 +98,36 @@ const VersionHistory = () => { )} - {/* Versions List or No Versions Message */} + {/* Versions List */}
{versions.length === 0 ? (
No saved versions
) : ( - versions.map((version, index) => ( + versions.map((version) => (
- Saved New Version - - - -
- -
-
- New Version Created {latestVersion.versionLabel}{" "} - {latestVersion.timestamp.toUpperCase()} +
+ +
+
+ New Version Created {latestVersion.versionLabel}{" "} + {latestVersion.timestamp.toUpperCase()} +
+ +
-
-
+ )} {isEditing && (
- +
Rename Version
@@ -154,16 +164,11 @@ const VersionSaved = () => {
- {/* setDescription(e.target.value)} - placeholder="Add description" - /> */}