Replace entire repo content with code from /root/shahikitchen-google/

This commit is contained in:
root
2026-07-03 02:51:15 +00:00
parent c8b7dc95e4
commit 8ccf033329
79 changed files with 7611 additions and 439 deletions
+62 -3
View File
@@ -1,11 +1,70 @@
import { PICKUP_LEAD_TIME_MINUTES } from '@/domain/shared/constants';
export type FulfillmentMode = 'pickup' | 'delivery';
export interface PickupInquiryDetails {
export type InquiryBranch = 'askim' | 'backaplan' | '';
export const DEFAULT_INQUIRY_BRANCH: InquiryBranch = 'backaplan';
export type InquiryPreferredDate = 'today' | 'tomorrow' | '';
export type InquiryScheduleValidation =
| 'ok'
| 'incomplete'
| 'too_soon'
| 'invalid_time';
export interface InquirySchedule {
preferredDate: InquiryPreferredDate;
preferredTime: string;
}
export interface PickupInquiryDetails extends InquirySchedule {
name: string;
phone: string;
email: string;
branch: InquiryBranch;
}
export interface DeliveryInquiryDetails extends PickupInquiryDetails {
address: string;
preferredTime: string;
}
export function isInquiryBranchOnlineEnabled(branch: InquiryBranch): boolean {
return branch === 'backaplan';
}
export function getMinInquiryTimeForToday(now: Date = new Date()): string {
const min = new Date(now.getTime() + PICKUP_LEAD_TIME_MINUTES * 60 * 1000);
return `${String(min.getHours()).padStart(2, '0')}:${String(min.getMinutes()).padStart(2, '0')}`;
}
export function validateInquirySchedule(
schedule: InquirySchedule,
now: Date = new Date(),
): InquiryScheduleValidation {
const hasDate = schedule.preferredDate === 'today' || schedule.preferredDate === 'tomorrow';
const hasTime = schedule.preferredTime.trim().length > 0;
if (!hasDate && !hasTime) return 'ok';
if (hasDate !== hasTime) return 'incomplete';
const [hours, minutes] = schedule.preferredTime.split(':').map(Number);
if (Number.isNaN(hours) || Number.isNaN(minutes)) return 'invalid_time';
const scheduled = new Date(now);
if (schedule.preferredDate === 'tomorrow') {
scheduled.setDate(scheduled.getDate() + 1);
}
scheduled.setHours(hours, minutes, 0, 0);
const minTime = new Date(now.getTime() + PICKUP_LEAD_TIME_MINUTES * 60 * 1000);
if (scheduled.getTime() < minTime.getTime()) return 'too_soon';
return 'ok';
}
export function hasInquirySchedule(schedule: InquirySchedule): boolean {
return validateInquirySchedule(schedule) === 'ok' &&
schedule.preferredDate !== '' &&
schedule.preferredTime.trim() !== '';
}