diff --git a/src/functions/location/controllers/index.ts b/src/functions/location/controllers/index.ts index 725df026..4e6cb044 100644 --- a/src/functions/location/controllers/index.ts +++ b/src/functions/location/controllers/index.ts @@ -1,3 +1,2 @@ export * from "./get-coordinates"; export * from "./get-travel-time"; -export * from "./validate-address"; diff --git a/src/functions/location/controllers/validate-address.ts b/src/functions/location/controllers/validate-address.ts deleted file mode 100644 index 2f48dc41..00000000 --- a/src/functions/location/controllers/validate-address.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { z } from "zod"; -import { _ } from "~/library/handler"; -import { LocationZodSchema } from "../location.types"; -import { LocationServiceValidateAddress } from "../services/validate-address"; - -export type LocationControllerValidateAddressRequest = { - query: z.infer; -}; - -export const LocationServiceValidateAddressSchema = LocationZodSchema.pick({ - fullAddress: true, -}); - -export type LocationControllerValidateAddressResponse = Awaited< - ReturnType ->; - -export const LocationControllerValidateAddress = _( - ({ query }: LocationControllerValidateAddressRequest) => { - const validateData = LocationServiceValidateAddressSchema.parse(query); - return LocationServiceValidateAddress(validateData.fullAddress); - } -); diff --git a/src/functions/location/index.ts b/src/functions/location/index.ts index f80f6fdb..cd911600 100644 --- a/src/functions/location/index.ts +++ b/src/functions/location/index.ts @@ -1,4 +1,4 @@ export * from "./controllers"; export * from "./location.model"; +export * from "./location.schema"; export * from "./location.types"; -export * from "./schemas"; diff --git a/src/functions/location/location.model.ts b/src/functions/location/location.model.ts index 5700cf06..5d339479 100644 --- a/src/functions/location/location.model.ts +++ b/src/functions/location/location.model.ts @@ -1,5 +1,5 @@ import { Model, model } from "mongoose"; -import { ILocationDocument, LocationMongooseSchema } from "./schemas"; +import { ILocationDocument, LocationMongooseSchema } from "./location.schema"; export const LocationModel = model>( "location", diff --git a/src/functions/location/schemas/location.schema.ts b/src/functions/location/location.schema.ts similarity index 89% rename from src/functions/location/schemas/location.schema.ts rename to src/functions/location/location.schema.ts index 7fc5c913..fedbe028 100644 --- a/src/functions/location/schemas/location.schema.ts +++ b/src/functions/location/location.schema.ts @@ -1,9 +1,5 @@ import mongoose, { Document, Model } from "mongoose"; -import { - Location, - LocationOriginTypes, - LocationTypes, -} from "../location.types"; +import { Location, LocationOriginTypes, LocationTypes } from "./location.types"; export interface ILocation extends Location { geoLocation: { @@ -22,6 +18,7 @@ export const LocationMongooseSchema = new mongoose.Schema< Model >( { + isDefault: { type: Boolean, default: false }, locationType: { type: String, enum: [LocationTypes.DESTINATION, LocationTypes.ORIGIN], @@ -85,6 +82,10 @@ export const LocationMongooseSchema = new mongoose.Schema< type: String, unique: true, }, + deletedAt: { + type: Date, + default: null, + }, }, { timestamps: true } ); diff --git a/src/functions/location/location.types.ts b/src/functions/location/location.types.ts index f04b5d4a..913a39eb 100644 --- a/src/functions/location/location.types.ts +++ b/src/functions/location/location.types.ts @@ -1,5 +1,9 @@ import { z } from "zod"; -import { GidFormat, NumberOrStringType } from "~/library/zod"; +import { + BooleanOrStringType, + GidFormat, + NumberOrStringType, +} from "~/library/zod"; export enum LocationTypes { ORIGIN = "origin", @@ -11,6 +15,7 @@ export enum LocationOriginTypes { COMMERCIAL = "commercial", } export const LocationZodSchema = z.object({ + isDefault: BooleanOrStringType, locationType: z.nativeEnum(LocationTypes), customerId: GidFormat, name: z.string(), @@ -22,6 +27,7 @@ export const LocationZodSchema = z.object({ minDriveDistance: NumberOrStringType, maxDriveDistance: NumberOrStringType, startFee: NumberOrStringType, + deletedAt: z.coerce.date().optional(), }); export type Location = z.infer; diff --git a/src/functions/location/schemas/index.ts b/src/functions/location/schemas/index.ts deleted file mode 100644 index fc5af74f..00000000 --- a/src/functions/location/schemas/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./location.schema";