Changeset 3a9c59c
- Timestamp:
- 02/19/26 22:09:38 (5 months ago)
- Branches:
- main
- Children:
- a508480
- Parents:
- 546a194
- File:
-
- 1 edited
-
pages/forge/+Page.tsx (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pages/forge/+Page.tsx
r546a194 r3a9c59c 26 26 import ComponentDialog from '../../components/ComponentDialog'; 27 27 import ComponentDetailsDialog from '../../components/ComponentDetailsDialog'; 28 import {onAddNewBuild, onGet ComponentDetails} from "../+Layout.telefunc";28 import {onAddNewBuild, onGetAuthState, 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. 159 160 const handleSelectComponent = async (component: any) => { 160 161 if (!activeSlotId) return; … … 163 164 let id = buildId; 164 165 if (!id) { 165 const result = await onAddNewBuild({ 166 name: buildName.trim() || "New Build", 167 description: description || "Work in progress" 168 }); 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 169 181 id = typeof result === 'number' ? result : (result as any)?.buildId; 170 182 if (!id || !Number.isInteger(id) || id <= 0) { 171 183 setSnackbar({ 172 184 open: true, 173 message: ' Failed to create draft build. Please try again.',174 severity: ' error'185 message: 'Please log in first!', 186 severity: 'warning' 175 187 }); 176 188 return; … … 198 210 }); 199 211 } finally { 200 setActiveSlotId(null); 201 } 202 }; 203 212 // setActiveSlotId(null); 213 } 214 }; 204 215 const handleRemovePart = async (slotId: string) => { 205 216 const slot = slots.find(s => s.id === slotId); … … 320 331 }; 321 332 333 334 const [isLoggedIn, setIsLoggedIn] = useState(false); 335 useEffect(() => { 336 onGetAuthState().then(userData => { 337 setIsLoggedIn(!!userData?.userId); 338 }); 339 }, []); 340 341 322 342 const handleSubmit = () => { 343 if (!isLoggedIn) { 344 window.location.href = '/auth/login' 345 return; 346 } 347 323 348 if (!buildName.trim()) { 324 349 setSnackbar({ … … 329 354 return; 330 355 } 356 331 357 if (!buildId) { 332 358 setSnackbar({
Note:
See TracChangeset
for help on using the changeset viewer.
