Changes in / [a508480:2c7b9c8]


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pages/forge/+Page.tsx

    ra508480 r2c7b9c8  
    2626import ComponentDialog from '../../components/ComponentDialog';
    2727import ComponentDetailsDialog from '../../components/ComponentDetailsDialog';
    28 import {onAddNewBuild, onGetAuthState, onGetComponentDetails} from "../+Layout.telefunc";
     28import {onAddNewBuild, onGetComponentDetails} from "../+Layout.telefunc";
    2929import {onEditBuild} from "../dashboard/user/userDashboard.telefunc";
    3030import {BuildSlot, INITIAL_SLOTS} from "./types/buildTypes";
     
    157157    };
    158158
    159     // fix: changed text, new catch and removed setActiveSlotId(null), so the component name doesn't disappear.
    160159    const handleSelectComponent = async (component: any) => {
    161160        if (!activeSlotId) return;
     
    164163            let id = buildId;
    165164            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                });
    181169                id = typeof result === 'number' ? result : (result as any)?.buildId;
    182170                if (!id || !Number.isInteger(id) || id <= 0) {
    183171                    setSnackbar({
    184172                        open: true,
    185                         message: 'Please log in first!',
    186                         severity: 'warning'
     173                        message: 'Failed to create draft build. Please try again.',
     174                        severity: 'error'
    187175                    });
    188176                    return;
     
    210198            });
    211199        } finally {
    212             // setActiveSlotId(null);
    213         }
    214     };
     200            setActiveSlotId(null);
     201        }
     202    };
     203
    215204    const handleRemovePart = async (slotId: string) => {
    216205        const slot = slots.find(s => s.id === slotId);
     
    331320    };
    332321
    333 
    334     const [isLoggedIn, setIsLoggedIn] = useState(false);
    335     useEffect(() => {
    336         onGetAuthState().then(userData => {
    337             setIsLoggedIn(!!userData?.userId);
    338         });
    339     }, []);
    340 
    341 
    342322    const handleSubmit = () => {
    343         if (!isLoggedIn) {
    344             window.location.href = '/auth/login'
    345             return;
    346         }
    347 
    348323        if (!buildName.trim()) {
    349324            setSnackbar({
     
    354329            return;
    355330        }
    356 
    357331        if (!buildId) {
    358332            setSnackbar({
Note: See TracChangeset for help on using the changeset viewer.