fix: incorrect types for PersonalRooms & TailorShop
This commit is contained in:
parent
07b0d37440
commit
38583b1fc4
@ -8,19 +8,21 @@ import { Loadout } from "@/src/models/inventoryModels/loadoutModel";
|
||||
import { logger } from "@/src/utils/logger";
|
||||
import { toOid } from "@/src/helpers/inventoryHelpers";
|
||||
import { IGetShipResponse } from "@/src/types/shipTypes";
|
||||
import { IPersonalRooms } from "@/src/types/personalRoomsTypes";
|
||||
|
||||
export const getShipController: RequestHandler = async (req, res) => {
|
||||
const accountId = await getAccountIdForRequest(req);
|
||||
const personalRooms = await getPersonalRooms(accountId);
|
||||
const personalRoomsDb = await getPersonalRooms(accountId);
|
||||
const personalRooms = personalRoomsDb.toJSON<IPersonalRooms>();
|
||||
const loadout = await getLoadout(accountId);
|
||||
const ship = await getShip(personalRooms.activeShipId, "ShipInteriorColors ShipAttachments SkinFlavourItem");
|
||||
const ship = await getShip(personalRoomsDb.activeShipId, "ShipInteriorColors ShipAttachments SkinFlavourItem");
|
||||
|
||||
const getShipResponse: IGetShipResponse = {
|
||||
ShipOwnerId: accountId,
|
||||
LoadOutInventory: { LoadOutPresets: loadout.toJSON() },
|
||||
Ship: {
|
||||
...personalRooms.toJSON().Ship,
|
||||
ShipId: toOid(personalRooms.activeShipId),
|
||||
...personalRooms.Ship,
|
||||
ShipId: toOid(personalRoomsDb.activeShipId),
|
||||
ShipInterior: {
|
||||
Colors: ship.ShipInteriorColors,
|
||||
ShipAttachments: ship.ShipAttachments,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { toOid } from "@/src/helpers/inventoryHelpers";
|
||||
import { IOrbiter, IPersonalRooms, PersonalRoomsModelType } from "@/src/types/personalRoomsTypes";
|
||||
import { IOrbiter, IPersonalRoomsDatabase, PersonalRoomsModelType } from "@/src/types/personalRoomsTypes";
|
||||
import {
|
||||
IApartment,
|
||||
IFavouriteLoadoutDatabase,
|
||||
@ -128,15 +128,15 @@ const tailorShopDefault: ITailorShopDatabase = {
|
||||
]
|
||||
};
|
||||
|
||||
export const personalRoomsSchema = new Schema<IPersonalRooms>({
|
||||
export const personalRoomsSchema = new Schema<IPersonalRoomsDatabase>({
|
||||
personalRoomsOwnerId: Schema.Types.ObjectId,
|
||||
activeShipId: Schema.Types.ObjectId,
|
||||
Ship: orbiterSchema,
|
||||
Apartment: apartmentSchema,
|
||||
TailorShop: {
|
||||
type: tailorShopSchema,
|
||||
default: tailorShopDefault as any as undefined // Yeah, this is bad, but mongoose types here are wrong.
|
||||
}
|
||||
TailorShop: { type: tailorShopSchema, default: tailorShopDefault }
|
||||
});
|
||||
|
||||
export const PersonalRooms = model<IPersonalRooms, PersonalRoomsModelType>("PersonalRooms", personalRoomsSchema);
|
||||
export const PersonalRooms = model<IPersonalRoomsDatabase, PersonalRoomsModelType>(
|
||||
"PersonalRooms",
|
||||
personalRoomsSchema
|
||||
);
|
||||
|
@ -1,4 +1,11 @@
|
||||
import { IApartment, IRoom, IPlacedDecosDatabase, ITailorShop, TBootLocation } from "@/src/types/shipTypes";
|
||||
import {
|
||||
IApartment,
|
||||
IRoom,
|
||||
IPlacedDecosDatabase,
|
||||
ITailorShop,
|
||||
ITailorShopDatabase,
|
||||
TBootLocation
|
||||
} from "@/src/types/shipTypes";
|
||||
import { Model, Types } from "mongoose";
|
||||
|
||||
export interface IOrbiter {
|
||||
@ -9,11 +16,17 @@ export interface IOrbiter {
|
||||
}
|
||||
|
||||
export interface IPersonalRooms {
|
||||
Ship: IOrbiter;
|
||||
Apartment: IApartment;
|
||||
TailorShop: ITailorShop;
|
||||
}
|
||||
|
||||
export interface IPersonalRoomsDatabase {
|
||||
personalRoomsOwnerId: Types.ObjectId;
|
||||
activeShipId: Types.ObjectId;
|
||||
Ship: IOrbiter;
|
||||
Apartment: IApartment;
|
||||
TailorShop: ITailorShop;
|
||||
TailorShop: ITailorShopDatabase;
|
||||
}
|
||||
|
||||
export type RoomsType = { Name: string; MaxCapacity: number; PlacedDecos: Types.DocumentArray<IPlacedDecosDatabase> };
|
||||
@ -25,10 +38,10 @@ export type PersonalRoomsDocumentProps = {
|
||||
Apartment: Omit<IApartment, "Rooms"> & {
|
||||
Rooms: RoomsType[];
|
||||
};
|
||||
TailorShop: Omit<ITailorShop, "Rooms"> & {
|
||||
TailorShop: Omit<ITailorShopDatabase, "Rooms"> & {
|
||||
Rooms: RoomsType[];
|
||||
};
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
export type PersonalRoomsModelType = Model<IPersonalRooms, {}, PersonalRoomsDocumentProps>;
|
||||
export type PersonalRoomsModelType = Model<IPersonalRoomsDatabase, {}, PersonalRoomsDocumentProps>;
|
||||
|
@ -163,5 +163,5 @@ export interface ITailorShopDatabase {
|
||||
|
||||
export interface ITailorShop extends Omit<ITailorShopDatabase, "FavouriteLoadouts"> {
|
||||
FavouriteLoadouts: IFavouriteLoadout[];
|
||||
Colors: []; // ???
|
||||
Colors?: []; // ???
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user