This commit is contained in:
shafi54 2026-02-26 22:42:09 +05:30
parent 1dca7a3454
commit 6c2b7f9bfd
8 changed files with 4100 additions and 28 deletions

View file

@ -73,6 +73,11 @@ export default function SlotForm({
return; return;
} }
if (values.freezeTime > values.deliveryTime) {
Alert.alert('Error', 'Freeze time must be before or equal to delivery time');
return;
}
const slotData = { const slotData = {
deliveryTime: values.deliveryTime.toISOString(), deliveryTime: values.deliveryTime.toISOString(),
freezeTime: values.freezeTime.toISOString(), freezeTime: values.freezeTime.toISOString(),

View file

@ -1,6 +1,6 @@
ENV_MODE=PROD ENV_MODE=PROD
# DATABASE_URL=postgresql://postgres:meatfarmer_master_password@57.128.212.174:7447/meatfarmer #technocracy DATABASE_URL=postgresql://postgres:meatfarmer_master_password@57.128.212.174:7447/meatfarmer #technocracy
DATABASE_URL=postgres://postgres:meatfarmer_master_password@5.223.55.14:7447/meatfarmer #hetzner # DATABASE_URL=postgres://postgres:meatfarmer_master_password@5.223.55.14:7447/meatfarmer #hetzner
PHONE_PE_BASE_URL=https://api-preprod.phonepe.com/ PHONE_PE_BASE_URL=https://api-preprod.phonepe.com/
PHONE_PE_CLIENT_ID=TEST-M23F2IGP34ZAR_25090 PHONE_PE_CLIENT_ID=TEST-M23F2IGP34ZAR_25090
PHONE_PE_CLIENT_VERSION=1 PHONE_PE_CLIENT_VERSION=1

File diff suppressed because one or more lines are too long

View file

@ -61,20 +61,6 @@ export async function initializeSlotStore(): Promise<void> {
orderBy: asc(deliverySlotInfo.deliveryTime), orderBy: asc(deliverySlotInfo.deliveryTime),
}); });
const allSlots = await db.query.deliverySlotInfo.findMany({
where: and(
eq(deliverySlotInfo.isActive, true),
gt(deliverySlotInfo.deliveryTime, now), // Only future slots
)
})
console.log(allSlots)
slots.forEach(slot => {
console.log({id: slot.id, delivery: dayjs(slot.deliveryTime).format('MM-DD-YY hh:mm:ss a')})
})
// Transform data for storage // Transform data for storage
const slotsWithProducts = await Promise.all( const slotsWithProducts = await Promise.all(
slots.map(async (slot) => ({ slots.map(async (slot) => ({

View file

@ -78,7 +78,7 @@ const applyDiscountToOrder = (
const discount = Math.min( const discount = Math.min(
(orderTotal * (orderTotal *
parseFloat(appliedCoupon.discountPercent.toString())) / parseFloat(appliedCoupon.discountPercent.toString())) /
100, 100,
appliedCoupon.maxValue appliedCoupon.maxValue
? parseFloat(appliedCoupon.maxValue.toString()) * proportion ? parseFloat(appliedCoupon.maxValue.toString()) * proportion
: Infinity : Infinity
@ -134,8 +134,9 @@ const placeOrderUtil = async (params: {
CONST_KEYS.flashDeliveryCharge, CONST_KEYS.flashDeliveryCharge,
]); ]);
const minOrderValue = constants[CONST_KEYS.minRegularOrderValue] ?? 0; const isFlashDelivery = params.isFlash;
const deliveryCharge = constants[CONST_KEYS.deliveryCharge] ?? 0; const minOrderValue = (isFlashDelivery ? constants[CONST_KEYS.flashFreeDeliveryThreshold] : constants[CONST_KEYS.minRegularOrderValue]) || 0;
const deliveryCharge = (isFlashDelivery ? constants[CONST_KEYS.flashDeliveryCharge] : constants[CONST_KEYS.deliveryCharge]) || 0;
const orderGroupId = `${Date.now()}-${userId}`; const orderGroupId = `${Date.now()}-${userId}`;
@ -426,7 +427,7 @@ export const orderRouter = router({
slotId: null as any, // Type override for flash delivery slotId: null as any, // Type override for flash delivery
})); }));
} }
return await placeOrderUtil({ return await placeOrderUtil({
userId, userId,
selectedItems: processedItems, selectedItems: processedItems,
@ -518,8 +519,8 @@ export const orderRouter = router({
const signedImages = item.product.images const signedImages = item.product.images
? await generateSignedUrlsFromS3Urls( ? await generateSignedUrlsFromS3Urls(
item.product.images as string[] item.product.images as string[]
) )
: []; : [];
return { return {
productName: item.product.name, productName: item.product.name,
@ -682,8 +683,8 @@ export const orderRouter = router({
order.orderItems.map(async (item) => { order.orderItems.map(async (item) => {
const signedImages = item.product.images const signedImages = item.product.images
? await generateSignedUrlsFromS3Urls( ? await generateSignedUrlsFromS3Urls(
item.product.images as string[] item.product.images as string[]
) )
: []; : [];
return { return {
productName: item.product.name, productName: item.product.name,

View file

@ -15,7 +15,7 @@ import dayjs from 'dayjs';
// Helper method to get formatted slot data by ID // Helper method to get formatted slot data by ID
async function getSlotData(slotId: number) { async function getSlotData(slotId: number) {
const slot = await getSlotByIdFromCache(slotId); const slot = await getSlotByIdFromCache(slotId);
if (!slot) { if (!slot) {
return null; return null;
} }
@ -48,7 +48,11 @@ export const slotsRouter = router({
const allSlots = await getAllSlotsFromCache(); const allSlots = await getAllSlotsFromCache();
const currentTime = new Date(); const currentTime = new Date();
const validSlots = allSlots const validSlots = allSlots
.filter((slot) => dayjs(slot.freezeTime).isAfter(currentTime) && !slot.isCapacityFull) .filter((slot) => {
return dayjs(slot.freezeTime).isAfter(currentTime) &&
dayjs(slot.deliveryTime).isAfter(currentTime) &&
!slot.isCapacityFull;
})
.sort((a, b) => dayjs(a.deliveryTime).valueOf() - dayjs(b.deliveryTime).valueOf()); .sort((a, b) => dayjs(a.deliveryTime).valueOf() - dayjs(b.deliveryTime).valueOf());
return { return {

View file

@ -63,7 +63,7 @@ const isDevMode = Constants.executionEnvironment !== "standalone";
// const BASE_API_URL = API_URL; // const BASE_API_URL = API_URL;
// const BASE_API_URL = 'http://10.0.2.2:4000'; // const BASE_API_URL = 'http://10.0.2.2:4000';
// const BASE_API_URL = 'http://192.168.100.101:4000'; // const BASE_API_URL = 'http://192.168.100.101:4000';
// const BASE_API_URL = 'http://192.168.100.105:4000'; // const BASE_API_URL = 'http://192.168.1.6:4000';
let BASE_API_URL = "https://mf.freshyo.in"; let BASE_API_URL = "https://mf.freshyo.in";
// let BASE_API_URL = 'http://192.168.100.104:4000'; // let BASE_API_URL = 'http://192.168.100.104:4000';
// let BASE_API_URL = 'http://192.168.29.176:4000'; // let BASE_API_URL = 'http://192.168.29.176:4000';

4076
session-ses_380a.md Normal file

File diff suppressed because it is too large Load diff