fix: handle standing limits in fishmongerController #795
@ -3,7 +3,8 @@ import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { addMiscItems, getInventory, getStandingLimit, updateStandingLimit } from "@/src/services/inventoryService";
 | 
			
		||||
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { IOid } from "@/src/types/commonTypes";
 | 
			
		||||
import { ExportSyndicates, ISyndicate } from "warframe-public-export-plus";
 | 
			
		||||
import { ExportSyndicates } from "warframe-public-export-plus";
 | 
			
		||||
import { getMaxStanding } from "@/src/helpers/syndicateStandingHelper";
 | 
			
		||||
 | 
			
		||||
export const syndicateStandingBonusController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
@ -67,14 +68,3 @@ interface ISyndicateStandingBonusRequest {
 | 
			
		||||
    };
 | 
			
		||||
    ModularWeaponId: IOid; // Seems to just be "000000000000000000000000", also note there's a "Category" query field
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const getMaxStanding = (syndicate: ISyndicate, title: number): number => {
 | 
			
		||||
    if (!syndicate.titles) {
 | 
			
		||||
        // LibrarySyndicate
 | 
			
		||||
        return 125000;
 | 
			
		||||
    }
 | 
			
		||||
    if (title == 0) {
 | 
			
		||||
        return syndicate.titles.find(x => x.level == 1)!.minStanding;
 | 
			
		||||
    }
 | 
			
		||||
    return syndicate.titles.find(x => x.level == title)!.maxStanding;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										12
									
								
								src/helpers/syndicateStandingHelper.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/helpers/syndicateStandingHelper.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
import { ISyndicate } from "warframe-public-export-plus";
 | 
			
		||||
 | 
			
		||||
export const getMaxStanding = (syndicate: ISyndicate, title: number): number => {
 | 
			
		||||
    if (!syndicate.titles) {
 | 
			
		||||
        // LibrarySyndicate
 | 
			
		||||
        return 125000;
 | 
			
		||||
    }
 | 
			
		||||
    if (title == 0) {
 | 
			
		||||
        return syndicate.titles.find(x => x.level == 1)!.minStanding;
 | 
			
		||||
    }
 | 
			
		||||
    return syndicate.titles.find(x => x.level == title)!.maxStanding;
 | 
			
		||||
| 
					
	
	
	
	
	
	
	
	 | 
			||||
};
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	
⚠️ Potential issue
Handle cases where the title level is not found
Using the non-null assertion operator
!afterfindassumes that a matching title will always be found. If no matching title exists, this will result in a runtime error.Modify the code to handle undefined cases:
Alternatively, you can provide a default value or handle the error gracefully.
📝 Committable suggestion