Changes in / [a508480:2c7b9c8]
- File:
-
- 1 edited
-
pages/forge/+Page.tsx (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pages/forge/+Page.tsx
ra508480 r2c7b9c8 26 26 import ComponentDialog from '../../components/ComponentDialog'; 27 27 import ComponentDetailsDialog from '../../components/ComponentDetailsDialog'; 28 import {onAddNewBuild, onGet AuthState, onGetComponentDetails} from "../+Layout.telefunc";28 import {onAddNewBuild, onGetComponentDetails} from "../+Layout.telefunc"; 29 29 import {onEditBuild} from "../dashboard/user/userDashboard.telefunc"; 30 30 import {BuildSlot, INITIAL_SLOTS} from "./types/buildTypes"; … … 157 157 }; 158 158 159 // fix: changed text, new catch and removed setActiveSlotId(null), so the component name doesn't disappear.160 159 const handleSelectComponent = async (component: any) => { 161 160 if (!activeSlotId) return; … … 164 163 let id = buildId; 165 164 if (!id) { 166 let result; 167 try { 168 result = await onAddNewBuild({ 169 name: buildName.trim() || "New Build", 170 description: description || "Work in progress" 171 }); 172 } catch { 173 setSnackbar({ 174 open: true, 175 message: 'Please log in first!', 176 severity: 'warning' 177 }); 178 return; 179 } 180 165 const result = await onAddNewBuild({ 166 name: buildName.trim() || "New Build", 167 description: description || "Work in progress" 168 }); 181 169 id = typeof result === 'number' ? result : (result as any)?.buildId; 182 170 if (!id || !Number.isInteger(id) || id <= 0) { 183 171 setSnackbar({ 184 172 open: true, 185 message: ' Please log in first!',186 severity: ' warning'173 message: 'Failed to create draft build. Please try again.', 174 severity: 'error' 187 175 }); 188 176 return; … … 210 198 }); 211 199 } finally { 212 // setActiveSlotId(null); 213 } 214 }; 200 setActiveSlotId(null); 201 } 202 }; 203 215 204 const handleRemovePart = async (slotId: string) => { 216 205 const slot = slots.find(s => s.id === slotId); … … 331 320 }; 332 321 333 334 const [isLoggedIn, setIsLoggedIn] = useState(false);335 useEffect(() => {336 onGetAuthState().then(userData => {337 setIsLoggedIn(!!userData?.userId);338 });339 }, []);340 341 342 322 const handleSubmit = () => { 343 if (!isLoggedIn) {344 window.location.href = '/auth/login'345 return;346 }347 348 323 if (!buildName.trim()) { 349 324 setSnackbar({ … … 354 329 return; 355 330 } 356 357 331 if (!buildId) { 358 332 setSnackbar({
Note:
See TracChangeset
for help on using the changeset viewer.
