This commit is contained in:
shafi54 2026-04-11 12:04:27 +05:30
parent b27e05aab0
commit 55bfd1aafa
18 changed files with 8413 additions and 229 deletions

View file

@ -6,14 +6,7 @@ import { trpc } from '../../../src/trpc-client';
import { useRouter } from 'expo-router';
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
interface ConstantFormData {
constants: ConstantItem[];
}
interface ConstantItem {
key: string;
value: any;
}
type ConstantFormData = Record<string, any>
const CONST_LABELS: Record<string, string> = {
minRegularOrderValue: 'Minimum Regular Order Value',
@ -61,21 +54,21 @@ const CONST_VISIBILITY: Record<string, boolean> = {
};
interface ConstantInputProps {
constant: ConstantItem;
constantKey: string;
value: any;
setFieldValue: (field: string, value: any) => void;
index: number;
router: any;
}
const ConstantInput: React.FC<ConstantInputProps> = ({ constant, setFieldValue, index, router }) => {
const fieldName = `constants.${index}.value`;
const ConstantInput: React.FC<ConstantInputProps> = ({ constantKey, value, setFieldValue, router }) => {
const fieldName = constantKey
// Special handling for popularItems - show navigation button instead of input
if (constant.key === 'popularItems') {
if (constantKey === 'popularItems') {
return (
<View>
<MyText style={tw`text-sm font-medium text-gray-700 mb-2`}>
{CONST_LABELS[constant.key] || constant.key}
{CONST_LABELS[constantKey] || constantKey}
</MyText>
<MyTouchableOpacity
onPress={() => router.push('/(drawer)/customize-app/popular-items')}
@ -83,7 +76,7 @@ const ConstantInput: React.FC<ConstantInputProps> = ({ constant, setFieldValue,
>
<MaterialIcons name="edit" size={20} color="#3b82f6" style={tw`mr-2`} />
<MyText style={tw`text-blue-700 font-medium`}>
Manage Popular Items ({Array.isArray(constant.value) ? constant.value.length : 0} items)
Manage Popular Items ({Array.isArray(value) ? value.length : 0} items)
</MyText>
<MaterialIcons name="chevron-right" size={20} color="#3b82f6" style={tw`ml-2`} />
</MyTouchableOpacity>
@ -92,12 +85,12 @@ const ConstantInput: React.FC<ConstantInputProps> = ({ constant, setFieldValue,
}
// Special handling for allItemsOrder - show navigation button instead of input
if (constant.key === 'allItemsOrder') {
if (constantKey === 'allItemsOrder') {
return (
<View>
<MyText style={tw`text-sm font-medium text-gray-700 mb-2`}>
{CONST_LABELS[constant.key] || constant.key}
{CONST_LABELS[constantKey] || constantKey}
</MyText>
<MyTouchableOpacity
onPress={() => router.push('/(drawer)/customize-app/all-items-order')}
@ -105,7 +98,7 @@ const ConstantInput: React.FC<ConstantInputProps> = ({ constant, setFieldValue,
>
<MaterialIcons name="reorder" size={20} color="#16a34a" style={tw`mr-2`} />
<MyText style={tw`text-green-700 font-medium`}>
Manage All Visible Items ({Array.isArray(constant.value) ? constant.value.length : 0} items)
Manage All Visible Items ({Array.isArray(value) ? value.length : 0} items)
</MyText>
<MaterialIcons name="chevron-right" size={20} color="#16a34a" style={tw`ml-2`} />
</MyTouchableOpacity>
@ -114,20 +107,20 @@ const ConstantInput: React.FC<ConstantInputProps> = ({ constant, setFieldValue,
}
// Handle boolean values - show checkbox
if (typeof constant.value === 'boolean') {
if (typeof value === 'boolean') {
return (
<View>
<MyText style={tw`text-sm font-medium text-gray-700 mb-2`}>
{CONST_LABELS[constant.key] || constant.key}
{CONST_LABELS[constantKey] || constantKey}
</MyText>
<View style={tw`flex-row items-center`}>
<Checkbox
checked={constant.value}
onPress={() => setFieldValue(fieldName, !constant.value)}
checked={value}
onPress={() => setFieldValue(fieldName, !value)}
size={28}
/>
<MyText style={tw`ml-3 text-gray-700`}>
{constant.value ? 'Enabled' : 'Disabled'}
{value ? 'Enabled' : 'Disabled'}
</MyText>
</View>
</View>
@ -135,11 +128,11 @@ const ConstantInput: React.FC<ConstantInputProps> = ({ constant, setFieldValue,
}
// Handle different value types
if (typeof constant.value === 'number') {
if (typeof value === 'number') {
return (
<MyTextInput
topLabel={CONST_LABELS[constant.key] || constant.key}
value={constant.value.toString()}
topLabel={CONST_LABELS[constantKey] || constantKey}
value={value.toString()}
onChangeText={(value) => {
const numValue = parseFloat(value);
setFieldValue(fieldName, isNaN(numValue) ? 0 : numValue);
@ -150,11 +143,11 @@ const ConstantInput: React.FC<ConstantInputProps> = ({ constant, setFieldValue,
);
}
if (Array.isArray(constant.value)) {
if (Array.isArray(value)) {
return (
<MyTextInput
topLabel={CONST_LABELS[constant.key] || constant.key}
value={constant.value.join(', ')}
topLabel={CONST_LABELS[constantKey] || constantKey}
value={value.join(', ')}
onChangeText={(value) => {
const arrayValue = value.split(',').map(s => s.trim()).filter(s => s.length > 0);
setFieldValue(fieldName, arrayValue);
@ -167,9 +160,12 @@ const ConstantInput: React.FC<ConstantInputProps> = ({ constant, setFieldValue,
// Default to string
return (
<MyTextInput
topLabel={CONST_LABELS[constant.key] || constant.key}
value={String(constant.value)}
onChangeText={(value) => setFieldValue(fieldName, value)}
topLabel={CONST_LABELS[constantKey] || constantKey}
// value={value === null || value === undefined ? '' : String(value)}
value={value}
onChangeText={(value) => {
setFieldValue(fieldName, value)
}}
placeholder="Enter value"
/>
);
@ -183,10 +179,13 @@ export default function CustomizeApp() {
const handleSubmit = (values: ConstantFormData) => {
// Filter out constants that haven't changed
const changedConstants = values.constants.filter((constant, index) => {
const original = constants?.[index];
return original && JSON.stringify(constant.value) !== JSON.stringify(original.value);
});
const changedConstants = (constants || []).filter((constant) => {
const nextValue = values[constant.key]
return JSON.stringify(nextValue) !== JSON.stringify(constant.value)
}).map((constant) => ({
key: constant.key,
value: values[constant.key],
}))
if (changedConstants.length === 0) {
Alert.alert('No Changes', 'No constants were modified.');
@ -224,9 +223,10 @@ export default function CustomizeApp() {
);
}
const initialValues: ConstantFormData = {
constants: constants.map(c => ({ key: c.key, value: c.value ?? '' } as ConstantItem)),
};
const initialValues: ConstantFormData = constants.reduce((acc, constant) => {
acc[constant.key] = constant.value ?? ''
return acc
}, {} as ConstantFormData)
@ -241,11 +241,22 @@ export default function CustomizeApp() {
<Formik initialValues={initialValues} onSubmit={handleSubmit}>
{({ handleSubmit, values, setFieldValue }) => (
<View>
{values.constants.filter((constant) => CONST_VISIBILITY[constant.key]).map((constant, index) => (
{constants.map((constant) => {
if (!CONST_VISIBILITY[constant.key]) {
return null
}
return (
<View key={constant.key} style={tw`mb-4`}>
<ConstantInput constant={constant} setFieldValue={setFieldValue} index={index} router={router} />
<ConstantInput
constantKey={constant.key}
value={values[constant.key]}
setFieldValue={setFieldValue}
router={router}
/>
</View>
))}
)
})}
<MyTouchableOpacity
onPress={() => handleSubmit()}

View file

@ -1,48 +0,0 @@
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
DROP TABLE IF EXISTS "vendor_snippets";
DROP TABLE IF EXISTS "users";
DROP TABLE IF EXISTS "user_notifications";
DROP TABLE IF EXISTS "user_incidents";
DROP TABLE IF EXISTS "user_details";
DROP TABLE IF EXISTS "user_creds";
DROP TABLE IF EXISTS "upload_url_status";
DROP TABLE IF EXISTS "unlogged_user_tokens";
DROP TABLE IF EXISTS "units";
DROP TABLE IF EXISTS "store_info";
DROP TABLE IF EXISTS "staff_users";
DROP TABLE IF EXISTS "staff_roles";
DROP TABLE IF EXISTS "staff_role_permissions";
DROP TABLE IF EXISTS "staff_permissions";
DROP TABLE IF EXISTS "special_deals";
DROP TABLE IF EXISTS "reserved_coupons";
DROP TABLE IF EXISTS "refunds";
DROP TABLE IF EXISTS "product_tags";
DROP TABLE IF EXISTS "product_tag_info";
DROP TABLE IF EXISTS "product_slots";
DROP TABLE IF EXISTS "product_reviews";
DROP TABLE IF EXISTS "product_info";
DROP TABLE IF EXISTS "product_group_membership";
DROP TABLE IF EXISTS "product_group_info";
DROP TABLE IF EXISTS "product_categories";
DROP TABLE IF EXISTS "product_availability_schedules";
DROP TABLE IF EXISTS "payments";
DROP TABLE IF EXISTS "payment_info";
DROP TABLE IF EXISTS "orders";
DROP TABLE IF EXISTS "order_status";
DROP TABLE IF EXISTS "order_items";
DROP TABLE IF EXISTS "notifications";
DROP TABLE IF EXISTS "notif_creds";
DROP TABLE IF EXISTS "key_val_store";
DROP TABLE IF EXISTS "home_banners";
DROP TABLE IF EXISTS "delivery_slot_info";
DROP TABLE IF EXISTS "coupons";
DROP TABLE IF EXISTS "coupon_usage";
DROP TABLE IF EXISTS "coupon_applicable_users";
DROP TABLE IF EXISTS "coupon_applicable_products";
DROP TABLE IF EXISTS "complaints";
DROP TABLE IF EXISTS "cart_items";
DROP TABLE IF EXISTS "addresses";
DROP TABLE IF EXISTS "address_zones";
DROP TABLE IF EXISTS "address_areas";
COMMIT;

View file

@ -285,6 +285,7 @@ INSERT INTO "coupon_applicable_users" ("id","coupon_id","user_id") VALUES(5,15,1
INSERT INTO "coupon_applicable_users" ("id","coupon_id","user_id") VALUES(6,18,145);
INSERT INTO "coupon_applicable_users" ("id","coupon_id","user_id") VALUES(7,19,1);
INSERT INTO "coupon_applicable_users" ("id","coupon_id","user_id") VALUES(8,20,296);
INSERT INTO "coupon_applicable_users" ("id","coupon_id","user_id") VALUES(9,21,1);
CREATE TABLE IF NOT EXISTS "coupon_usage" ("id" INTEGER PRIMARY KEY, "user_id" INTEGER NOT NULL, "coupon_id" INTEGER NOT NULL, "used_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, "order_id" INTEGER, "order_item_id" INTEGER);
INSERT INTO "coupon_usage" ("id","user_id","coupon_id","used_at","order_id","order_item_id") VALUES(1,2,4,'2025-11-25T06:29:10.947Z',NULL,NULL);
INSERT INTO "coupon_usage" ("id","user_id","coupon_id","used_at","order_id","order_item_id") VALUES(2,1,4,'2025-11-25T10:52:34.453Z',NULL,NULL);
@ -396,6 +397,7 @@ INSERT INTO "coupon_usage" ("id","user_id","coupon_id","used_at","order_id","ord
INSERT INTO "coupon_usage" ("id","user_id","coupon_id","used_at","order_id","order_item_id") VALUES(112,99,17,'2026-03-28T10:38:02.987Z',587,NULL);
INSERT INTO "coupon_usage" ("id","user_id","coupon_id","used_at","order_id","order_item_id") VALUES(113,229,17,'2026-03-29T06:06:58.130Z',594,NULL);
INSERT INTO "coupon_usage" ("id","user_id","coupon_id","used_at","order_id","order_item_id") VALUES(114,115,17,'2026-03-30T08:47:20.108Z',600,NULL);
INSERT INTO "coupon_usage" ("id","user_id","coupon_id","used_at","order_id","order_item_id") VALUES(115,1,21,'2026-04-09T09:49:29.879Z',614,NULL);
CREATE TABLE IF NOT EXISTS "coupons" ("id" INTEGER PRIMARY KEY, "is_user_based" INTEGER NOT NULL DEFAULT false, "discount_percent" REAL, "flat_discount" REAL, "min_order" REAL, "created_by" INTEGER, "max_value" REAL, "is_invalidated" INTEGER NOT NULL DEFAULT false, "created_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, "is_apply_for_all" INTEGER NOT NULL DEFAULT false, "valid_till" TEXT, "max_limit_for_user" INTEGER, "coupon_code" TEXT NOT NULL, "product_ids" INTEGER, "exclusive_apply" INTEGER NOT NULL DEFAULT false);
INSERT INTO "coupons" ("id","is_user_based","discount_percent","flat_discount","min_order","created_by","max_value","is_invalidated","created_at","is_apply_for_all","valid_till","max_limit_for_user","coupon_code","product_ids","exclusive_apply") VALUES(1,0,20,NULL,500,6,NULL,1,'2025-11-21T14:14:20.264Z',1,'2025-11-30T00:00:00.000Z',NULL,'BIG50',NULL,0);
INSERT INTO "coupons" ("id","is_user_based","discount_percent","flat_discount","min_order","created_by","max_value","is_invalidated","created_at","is_apply_for_all","valid_till","max_limit_for_user","coupon_code","product_ids","exclusive_apply") VALUES(2,0,50,NULL,1000,6,500,1,'2025-11-22T08:59:29.904Z',1,'2026-01-07T00:00:00.000Z',1,'SAVEMORE',NULL,0);
@ -417,6 +419,7 @@ INSERT INTO "coupons" ("id","is_user_based","discount_percent","flat_discount","
INSERT INTO "coupons" ("id","is_user_based","discount_percent","flat_discount","min_order","created_by","max_value","is_invalidated","created_at","is_apply_for_all","valid_till","max_limit_for_user","coupon_code","product_ids","exclusive_apply") VALUES(18,1,10,NULL,100,6,50,0,'2026-02-18T09:14:14.005Z',0,'2026-02-28T09:14:00.000Z',2,'NAHEED10',NULL,0);
INSERT INTO "coupons" ("id","is_user_based","discount_percent","flat_discount","min_order","created_by","max_value","is_invalidated","created_at","is_apply_for_all","valid_till","max_limit_for_user","coupon_code","product_ids","exclusive_apply") VALUES(19,1,20,NULL,1000,4,500,1,'2026-03-03T19:17:10.632Z',0,'2026-06-01T19:17:10.598Z',1,'MF14964305375IIB',NULL,0);
INSERT INTO "coupons" ("id","is_user_based","discount_percent","flat_discount","min_order","created_by","max_value","is_invalidated","created_at","is_apply_for_all","valid_till","max_limit_for_user","coupon_code","product_ids","exclusive_apply") VALUES(20,1,10,NULL,250,6,100,0,'2026-03-18T14:57:34.307Z',0,'2026-03-30T14:57:00.000Z',1,'D10',NULL,0);
INSERT INTO "coupons" ("id","is_user_based","discount_percent","flat_discount","min_order","created_by","max_value","is_invalidated","created_at","is_apply_for_all","valid_till","max_limit_for_user","coupon_code","product_ids","exclusive_apply") VALUES(21,1,12,NULL,100,6,80,0,'2026-04-09 09:48:03',0,'2026-04-30T09:47:00.000Z',2,'SHAFI20',NULL,0);
CREATE TABLE IF NOT EXISTS "delivery_slot_info" ("id" INTEGER PRIMARY KEY, "delivery_time" TEXT NOT NULL, "freeze_time" TEXT NOT NULL, "is_active" INTEGER NOT NULL DEFAULT true, "delivery_sequence" TEXT, "is_flash" INTEGER NOT NULL DEFAULT false, "group_ids" TEXT, "is_capacity_full" INTEGER NOT NULL DEFAULT false);
INSERT INTO "delivery_slot_info" ("id","delivery_time","freeze_time","is_active","delivery_sequence","is_flash","group_ids","is_capacity_full") VALUES(1,'2025-11-26T01:30:00.000Z','2025-11-21T23:30:00.000Z',1,NULL,0,NULL,0);
INSERT INTO "delivery_slot_info" ("id","delivery_time","freeze_time","is_active","delivery_sequence","is_flash","group_ids","is_capacity_full") VALUES(2,'2025-11-30T07:09:00.000Z','2025-11-29T07:10:00.000Z',1,NULL,0,NULL,0);
@ -908,7 +911,7 @@ INSERT INTO "key_val_store" ("key","value") VALUES('allItemsOrder','[10,57,99,75
INSERT INTO "key_val_store" ("key","value") VALUES('appStoreUrl','https://info.freshyo.in/qr-based-download');
INSERT INTO "key_val_store" ("key","value") VALUES('deliveryCharge','12.0');
INSERT INTO "key_val_store" ("key","value") VALUES('flashDeliveryCharge','39.0');
INSERT INTO "key_val_store" ("key","value") VALUES('flashFreeDeliveryThreshold','799.0');
INSERT INTO "key_val_store" ("key","value") VALUES('flashFreeDeliveryThreshold','500');
INSERT INTO "key_val_store" ("key","value") VALUES('freeDeliveryThreshold','180.0');
INSERT INTO "key_val_store" ("key","value") VALUES('isFlashDeliveryEnabled','1.0');
INSERT INTO "key_val_store" ("key","value") VALUES('minRegularOrderValue','180.0');
@ -919,7 +922,7 @@ INSERT INTO "key_val_store" ("key","value") VALUES('supportEmail','qushammohd@gm
INSERT INTO "key_val_store" ("key","value") VALUES('supportMobile','9000885620.0');
INSERT INTO "key_val_store" ("key","value") VALUES('tester','value41');
INSERT INTO "key_val_store" ("key","value") VALUES('versionNum','1.2.0');
INSERT INTO "key_val_store" ("key","value") VALUES('cache_version','16');
INSERT INTO "key_val_store" ("key","value") VALUES('cache_version','18');
CREATE TABLE IF NOT EXISTS "notif_creds" ("id" INTEGER PRIMARY KEY, "token" TEXT NOT NULL, "added_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, "user_id" INTEGER NOT NULL, "last_verified" TEXT);
INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(3,'ExponentPushToken[iv6POIJTUIiGpkElL84fG7]','2026-02-07T16:46:24.831Z',7,'2026-02-28T05:38:25.639Z');
INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(5,'ExponentPushToken[HnHTZNKG8TO0uuxIEus-PG]','2026-02-08T03:33:08.347Z',91,'2026-02-08T03:33:13.416Z');
@ -1083,7 +1086,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA
INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(185,'ExponentPushToken[GrgPQsDgwa5N3D4zYWM6Bq]','2026-03-04T10:37:39.397Z',259,'2026-03-09T15:41:51.843Z');
INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(188,'ExponentPushToken[jbO_CmG1fNSI6C8H7gMynW]','2026-03-04T13:49:49.638Z',262,'2026-03-04T13:49:49.635Z');
INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(189,'ExponentPushToken[maIvRtPY6x8uRtvsdsN8CV]','2026-03-04T19:41:48.743Z',263,'2026-03-10T06:36:20.538Z');
INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(190,'ExponentPushToken[93-_2gEHMwejR3miLX0RGU]','2026-03-05T11:03:08.664Z',1,'2026-04-08T18:40:54.830Z');
INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(190,'ExponentPushToken[93-_2gEHMwejR3miLX0RGU]','2026-03-05T11:03:08.664Z',1,'2026-04-09T09:48:36.087Z');
INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(191,'ExponentPushToken[N2eYJUG94IpJDmwf5uMKWO]','2026-03-06T03:53:06.574Z',92,'2026-03-17T11:15:35.386Z');
INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(192,'ExponentPushToken[10ByBoOOJtIbixAFhUnzh6]','2026-03-06T09:18:08.994Z',265,'2026-03-20T16:19:18.350Z');
INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(193,'ExponentPushToken[mMaLNcO1vNYObmRiycjckA]','2026-03-06T10:15:46.830Z',56,'2026-03-06T12:20:27.129Z');
@ -2770,6 +2773,7 @@ INSERT INTO "order_items" ("id","order_id","product_id","quantity","price","disc
INSERT INTO "order_items" ("id","order_id","product_id","quantity","price","discounted_price","is_packaged","is_package_verified") VALUES(1624,611,9,'1',296,296,0,0);
INSERT INTO "order_items" ("id","order_id","product_id","quantity","price","discounted_price","is_packaged","is_package_verified") VALUES(1625,612,9,'1',296,296,0,0);
INSERT INTO "order_items" ("id","order_id","product_id","quantity","price","discounted_price","is_packaged","is_package_verified") VALUES(1626,613,123,'1',250,250,0,0);
INSERT INTO "order_items" ("id","order_id","product_id","quantity","price","discounted_price","is_packaged","is_package_verified") VALUES(1627,614,9,'1',296,296,0,0);
CREATE TABLE IF NOT EXISTS "order_status" ("id" INTEGER PRIMARY KEY, "order_time" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, "user_id" INTEGER NOT NULL, "order_id" INTEGER NOT NULL, "is_packaged" INTEGER NOT NULL DEFAULT false, "is_delivered" INTEGER NOT NULL DEFAULT false, "is_cancelled" INTEGER NOT NULL DEFAULT false, "cancel_reason" TEXT, "payment_state" TEXT NOT NULL DEFAULT 'pending', "cancellation_user_notes" TEXT, "cancellation_admin_notes" TEXT, "cancellation_reviewed" INTEGER NOT NULL DEFAULT false, "cancellation_reviewed_at" TEXT, "refund_coupon_id" INTEGER, "is_cancelled_by_admin" INTEGER);
INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(1,'2025-11-19T14:51:36.005Z',3,1,1,0,0,NULL,'success',NULL,NULL,0,NULL,NULL,NULL);
INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2,'2025-11-19T15:08:30.002Z',1,2,0,0,0,NULL,'pending',NULL,NULL,0,NULL,NULL,NULL);
@ -3376,6 +3380,7 @@ INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged"
INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(611,'2026-04-03 15:13:41',1,611,0,0,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL);
INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(612,'2026-04-03 15:28:14',1,612,0,0,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL);
INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(613,'2026-04-08 18:41:07',1,613,0,0,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL);
INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(614,'2026-04-09 09:49:29',1,614,0,0,1,'Assuming','cod','Assuming',NULL,0,NULL,NULL,NULL);
CREATE TABLE IF NOT EXISTS "orders" ("id" INTEGER PRIMARY KEY, "user_id" INTEGER NOT NULL, "address_id" INTEGER NOT NULL, "slot_id" INTEGER, "total_amount" REAL NOT NULL, "created_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, "is_cod" INTEGER NOT NULL DEFAULT false, "is_online_payment" INTEGER NOT NULL DEFAULT false, "payment_info_id" INTEGER, "readable_id" INTEGER NOT NULL, "admin_notes" TEXT, "user_notes" TEXT, "delivery_charge" REAL NOT NULL DEFAULT '0', "order_group_id" TEXT, "order_group_proportion" REAL, "is_flash_delivery" INTEGER NOT NULL DEFAULT false);
INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery") VALUES(1,3,1,1,44,'2025-11-19T14:51:36.005Z',0,1,1,1,NULL,NULL,0,NULL,NULL,0);
INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery") VALUES(2,1,17,1,220,'2025-11-19T15:08:30.002Z',0,1,2,2,NULL,NULL,0,NULL,NULL,0);
@ -3982,6 +3987,7 @@ INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","crea
INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery") VALUES(611,1,17,483,296,'2026-04-03 15:13:41',1,0,NULL,-1,NULL,NULL,0,'1775229220746-1',1,0);
INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery") VALUES(612,1,17,483,296,'2026-04-03 15:28:13',1,0,NULL,-1,NULL,NULL,0,'1775230092878-1',1,0);
INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery") VALUES(613,1,17,483,250,'2026-04-08 18:41:07',1,0,NULL,-1,NULL,NULL,0,'1775673666769-1',1,0);
INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery") VALUES(614,1,17,483,260.48,'2026-04-09 09:49:28',1,0,NULL,-1,NULL,NULL,0,'1775728168103-1',1,0);
CREATE TABLE IF NOT EXISTS "payment_info" ("id" INTEGER PRIMARY KEY, "status" TEXT NOT NULL, "gateway" TEXT NOT NULL, "order_id" TEXT, "token" TEXT, "merchant_order_id" TEXT NOT NULL, "payload" TEXT);
INSERT INTO "payment_info" ("id","status","gateway","order_id","token","merchant_order_id","payload") VALUES(1,'pending','phonepe',NULL,NULL,'order_1763563896010',NULL);
INSERT INTO "payment_info" ("id","status","gateway","order_id","token","merchant_order_id","payload") VALUES(2,'pending','phonepe',NULL,NULL,'order_1763564910006',NULL);
@ -4103,6 +4109,7 @@ INSERT INTO "product_group_info" ("id","group_name","description","created_at")
INSERT INTO "product_group_info" ("id","group_name","description","created_at") VALUES(9,'All fish ','All fish ','2026-01-25T14:27:31.702Z');
INSERT INTO "product_group_info" ("id","group_name","description","created_at") VALUES(10,'All fruits items ','','2026-01-30T15:09:13.561Z');
INSERT INTO "product_group_info" ("id","group_name","description","created_at") VALUES(11,'All fruits juices ','','2026-03-10T09:00:27.292Z');
INSERT INTO "product_group_info" ("id","group_name","description","created_at") VALUES(12,'Flash Only','Flash items only','2026-04-09 13:30:40');
CREATE TABLE IF NOT EXISTS "product_group_membership" ("product_id" INTEGER NOT NULL, "group_id" INTEGER NOT NULL, "added_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP);
INSERT INTO "product_group_membership" ("product_id","group_id","added_at") VALUES(1,2,'2026-01-01T03:43:41.542Z');
INSERT INTO "product_group_membership" ("product_id","group_id","added_at") VALUES(2,2,'2026-01-01T03:43:41.542Z');
@ -4267,6 +4274,9 @@ INSERT INTO "product_group_membership" ("product_id","group_id","added_at") VALU
INSERT INTO "product_group_membership" ("product_id","group_id","added_at") VALUES(115,11,'2026-03-11T09:50:06.551Z');
INSERT INTO "product_group_membership" ("product_id","group_id","added_at") VALUES(116,11,'2026-03-11T09:50:06.551Z');
INSERT INTO "product_group_membership" ("product_id","group_id","added_at") VALUES(117,11,'2026-03-11T09:50:06.551Z');
INSERT INTO "product_group_membership" ("product_id","group_id","added_at") VALUES(1,12,'2026-04-09 13:30:41');
INSERT INTO "product_group_membership" ("product_id","group_id","added_at") VALUES(2,12,'2026-04-09 13:30:41');
INSERT INTO "product_group_membership" ("product_id","group_id","added_at") VALUES(3,12,'2026-04-09 13:30:41');
CREATE TABLE IF NOT EXISTS "product_info" ("id" INTEGER PRIMARY KEY, "name" TEXT NOT NULL, "short_description" TEXT, "long_description" TEXT, "unit_id" INTEGER NOT NULL, "price" REAL NOT NULL, "images" TEXT, "created_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, "is_out_of_stock" INTEGER NOT NULL DEFAULT false, "market_price" REAL, "store_id" INTEGER, "is_suspended" INTEGER NOT NULL DEFAULT false, "increment_step" REAL NOT NULL DEFAULT 1, "is_flash_available" INTEGER NOT NULL DEFAULT false, "flash_price" REAL, "product_quantity" REAL NOT NULL DEFAULT 1);
INSERT INTO "product_info" ("id","name","short_description","long_description","unit_id","price","images","created_at","is_out_of_stock","market_price","store_id","is_suspended","increment_step","is_flash_available","flash_price","product_quantity") VALUES(1,'Chicken Liver','Liver sourced from the farm hens.',replace('Bring home the deep, hearty taste of fresh Chicken Liver, sourced from healthy, farm-raised chickens. Each piece is carefully cleaned and handled with care to retain its natural richness, smooth texture, and vibrant color.\n\nPerfect for making creamy pâtés, spicy fry dishes, gravies, or traditional home-style recipes, our chicken liver delivers authentic flavor and exceptional freshness in every bite.','\n',char(10)),1,99,'["product-images/1768478127128-0","product-images/1768478472220-0"]','2025-11-18T13:36:27.505Z',0,110,1,0,1,1,NULL,0.5);
INSERT INTO "product_info" ("id","name","short_description","long_description","unit_id","price","images","created_at","is_out_of_stock","market_price","store_id","is_suspended","increment_step","is_flash_available","flash_price","product_quantity") VALUES(2,'Chicken Breast 500 g','Farm Chicken Breast uncut and solid.',replace('Experience the rich taste of fresh, premium-quality chicken sourced directly from trusted farms. Each bird is carefully cleaned, processed hygienically, and delivered chilled to preserve its natural flavor, tenderness, and juiciness.\n\nWhether you''re preparing a hearty curry, roasting for a family meal, or grilling for a weekend cookout, our whole chicken offers consistent texture, rich aroma, and superior taste in every bite.','\n',char(10)),1,215,'["product-images/1768397780093-0","product-images/1768479562478-0"]','2025-11-18T14:02:49.003Z',0,225,1,0,1,1,219,0.5);
@ -4297,7 +4307,7 @@ INSERT INTO "product_info" ("id","name","short_description","long_description","
INSERT INTO "product_info" ("id","name","short_description","long_description","unit_id","price","images","created_at","is_out_of_stock","market_price","store_id","is_suspended","increment_step","is_flash_available","flash_price","product_quantity") VALUES(27,'Brinjal ','Fresh medium-sized brinjal, rich in fiber, low in calories, and ideal for everyday curries and fries.','Freshly harvested brinjal with smooth skin and tender flesh. Mild in taste and versatile in cooking, it is commonly used in curries, stir-fries, bharta, and gravies. Naturally rich in fiber and antioxidants, making it suitable for regular home cooking. Washed and packed hygienically.',1,24,'["product-images/1768639645423-0"]','2025-12-22T11:31:30.466Z',0,30,4,0,1,1,NULL,0.5);
INSERT INTO "product_info" ("id","name","short_description","long_description","unit_id","price","images","created_at","is_out_of_stock","market_price","store_id","is_suspended","increment_step","is_flash_available","flash_price","product_quantity") VALUES(28,'Mutton Boneless ','Tender boneless mutton rich in protein, ideal for quick curries, fry, and kebabs.','Freshly cut boneless mutton pieces with minimal fat and strong natural flavour. Suitable for fast-cooking dishes such as gravies, stir-fries, kebabs, and biryani. High in protein and essential minerals, supporting strength and energy. Cleaned and packed hygienically to ensure freshness and quality.',1,855,'["product-images/1769356702593-0"]','2025-12-22T11:44:24.499Z',1,879,1,0,1,0,NULL,0.5);
INSERT INTO "product_info" ("id","name","short_description","long_description","unit_id","price","images","created_at","is_out_of_stock","market_price","store_id","is_suspended","increment_step","is_flash_available","flash_price","product_quantity") VALUES(29,' Bottle Gourd (Lauki)','Fresh medium-sized bottle gourd, low in calories, high in water content, easy to digest, and ideal for healthy everyday cooking.','Fresh bottle gourd with smooth green skin and soft, tender flesh. Light in taste and easy to digest, it is widely used in Indian home cooking for curries, dals, soups, and juices. Naturally low in calories and rich in water content, making it suitable for daily meals. Handpicked for freshness and packed hygienically.',4,29,'["product-images/1768823985921-0"]','2025-12-22T11:45:31.316Z',0,32,4,0,1,1,NULL,1);
INSERT INTO "product_info" ("id","name","short_description","long_description","unit_id","price","images","created_at","is_out_of_stock","market_price","store_id","is_suspended","increment_step","is_flash_available","flash_price","product_quantity") VALUES(30,' Bitter Gourd (Karela)','Fresh bitter gourd, known to help control blood sugar and support digestion.','Fresh bitter gourd with firm texture and deep green color. Widely used in Indian cooking for stir-fries, curries, and juices. Naturally low in calories and rich in fiber, vitamins, and antioxidants. Commonly consumed for its potential benefits in blood sugar management and digestion. Wash thoroughly before use.',1,34,'["product-images/1768726783083-0"]','2025-12-22T11:46:16.981Z',0,42,4,0,1,1,NULL,0.5);
INSERT INTO "product_info" ("id","name","short_description","long_description","unit_id","price","images","created_at","is_out_of_stock","market_price","store_id","is_suspended","increment_step","is_flash_available","flash_price","product_quantity") VALUES(30,' Bitter Gourd (Karela)','Fresh bitter gourd, known to help control blood sugar and support digestionn.','Fresh bitter gourd with firm texture and deep green color. Widely used in Indian cooking for stir-fries, curries, and juices. Naturally low in calories and rich in fiber, vitamins, and antioxidants. Commonly consumed for its potential benefits in blood sugar management and digestion. Wash thoroughly before use.',1,34,'["product-images/1768726783083-0","product-images/1775705965861.jpg"]','2025-12-22T11:46:16.981Z',0,42,4,0,1,0,NULL,0.5);
INSERT INTO "product_info" ("id","name","short_description","long_description","unit_id","price","images","created_at","is_out_of_stock","market_price","store_id","is_suspended","increment_step","is_flash_available","flash_price","product_quantity") VALUES(31,'Lady Finger (Okra / Bhindi)','Fresh tender lady finger, soft and non-fibrous, ideal for fries and curries.','Lady finger, also known as okra or bhindi, is a popular vegetable used in everyday Indian cooking. Tender lady finger has a soft texture and mild flavour, making it perfect for fries, stir-fries, curries, and gravies. When fresh, it cooks evenly without becoming too sticky. Rich in dietary fiber, vitamins, and antioxidants, it supports digestion and overall health. Carefully sourced and packed to maintain freshness and tenderness. Wash well and trim the ends before cooking.',1,25,'["product-images/1769574792720-0"]','2025-12-22T11:47:07.804Z',0,30,4,0,1,1,30,0.5);
INSERT INTO "product_info" ("id","name","short_description","long_description","unit_id","price","images","created_at","is_out_of_stock","market_price","store_id","is_suspended","increment_step","is_flash_available","flash_price","product_quantity") VALUES(32,'Lemons ','Farm-fresh lemons with high juice content and natural tangy flavor. Perfect for daily cooking, juices, and salads.','Fresh, handpicked lemons known for their strong aroma, thin skin, and high juice yield. Ideal for nimbu pani, curries, marinades, chutneys, and garnishing. Carefully selected to ensure firmness, freshness, and bright yellow color. Stored and delivered with proper care to maintain natural taste and quality.',4,39,'["product-images/1766406273176-0","product-images/1766406273178-1"]','2025-12-22T12:24:35.209Z',0,45,4,0,1,1,45,6);
INSERT INTO "product_info" ("id","name","short_description","long_description","unit_id","price","images","created_at","is_out_of_stock","market_price","store_id","is_suspended","increment_step","is_flash_available","flash_price","product_quantity") VALUES(33,'Small Methi / Baby Fenugreek Leaves','Fresh small methi leaves with a mild bitterness, perfect for everyday cooking and quick stir-fries.','Small methi, also known as baby fenugreek leaves, is a tender and flavorful leafy vegetable widely used in Indian kitchens. Compared to regular methi, these leaves are smaller, softer, and less bitter, making them ideal for curries, dal, parathas, and simple stir-fries. They cook quickly and blend well with spices without overpowering the dish. Small methi is naturally rich in fiber, iron, and essential nutrients that support digestion and overall health. Carefully cleaned and freshly sourced, these leaves bring authentic taste and freshness to your daily meals.',4,15,'["product-images/1769396046557-0"]','2025-12-22T12:25:49.838Z',0,20,4,0,1,0,NULL,8);
@ -45612,7 +45622,6 @@ INSERT INTO "product_tags" ("id","product_id","tag_id","assigned_at") VALUES(294
INSERT INTO "product_tags" ("id","product_id","tag_id","assigned_at") VALUES(295,29,5,'2026-01-28T02:50:37.640Z');
INSERT INTO "product_tags" ("id","product_id","tag_id","assigned_at") VALUES(298,19,5,'2026-01-28T03:00:53.298Z');
INSERT INTO "product_tags" ("id","product_id","tag_id","assigned_at") VALUES(299,18,5,'2026-01-28T03:02:17.814Z');
INSERT INTO "product_tags" ("id","product_id","tag_id","assigned_at") VALUES(301,30,5,'2026-01-28T03:05:38.807Z');
INSERT INTO "product_tags" ("id","product_id","tag_id","assigned_at") VALUES(303,27,5,'2026-01-28T03:08:48.593Z');
INSERT INTO "product_tags" ("id","product_id","tag_id","assigned_at") VALUES(304,89,5,'2026-01-28T03:09:06.159Z');
INSERT INTO "product_tags" ("id","product_id","tag_id","assigned_at") VALUES(306,70,5,'2026-01-28T03:12:26.477Z');
@ -45679,6 +45688,7 @@ INSERT INTO "product_tags" ("id","product_id","tag_id","assigned_at") VALUES(375
INSERT INTO "product_tags" ("id","product_id","tag_id","assigned_at") VALUES(376,122,2,'2026-04-08 18:21:00');
INSERT INTO "product_tags" ("id","product_id","tag_id","assigned_at") VALUES(377,123,2,'2026-04-08 18:42:04');
INSERT INTO "product_tags" ("id","product_id","tag_id","assigned_at") VALUES(378,123,4,'2026-04-08 18:42:04');
INSERT INTO "product_tags" ("id","product_id","tag_id","assigned_at") VALUES(379,30,5,'2026-04-09 03:39:27');
CREATE TABLE IF NOT EXISTS "refunds" ("id" INTEGER PRIMARY KEY, "order_id" INTEGER NOT NULL, "refund_amount" REAL, "refund_status" TEXT DEFAULT 'none', "merchant_refund_id" TEXT, "refund_processed_at" TEXT, "created_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP);
INSERT INTO "refunds" ("id","order_id","refund_amount","refund_status","merchant_refund_id","refund_processed_at","created_at") VALUES(1,14,73.5,'success','rfnd_Rithb3BCPvwCVZ','2025-11-22T19:15:42.202Z','2025-11-19T18:17:41.044Z');
INSERT INTO "refunds" ("id","order_id","refund_amount","refund_status","merchant_refund_id","refund_processed_at","created_at") VALUES(2,16,NULL,'none',NULL,NULL,'2025-11-23T11:41:45.422Z');
@ -45786,6 +45796,7 @@ INSERT INTO "refunds" ("id","order_id","refund_amount","refund_status","merchant
INSERT INTO "refunds" ("id","order_id","refund_amount","refund_status","merchant_refund_id","refund_processed_at","created_at") VALUES(104,562,NULL,'na',NULL,NULL,'2026-03-24T06:32:12.361Z');
INSERT INTO "refunds" ("id","order_id","refund_amount","refund_status","merchant_refund_id","refund_processed_at","created_at") VALUES(105,575,NULL,'na',NULL,NULL,'2026-03-25T16:24:27.240Z');
INSERT INTO "refunds" ("id","order_id","refund_amount","refund_status","merchant_refund_id","refund_processed_at","created_at") VALUES(106,579,NULL,'na',NULL,NULL,'2026-03-27T02:35:54.745Z');
INSERT INTO "refunds" ("id","order_id","refund_amount","refund_status","merchant_refund_id","refund_processed_at","created_at") VALUES(107,614,NULL,'na',NULL,NULL,'2026-04-09 13:34:02');
CREATE TABLE IF NOT EXISTS "reserved_coupons" ("id" INTEGER PRIMARY KEY, "secret_code" TEXT NOT NULL, "coupon_code" TEXT NOT NULL, "discount_percent" REAL, "flat_discount" REAL, "min_order" REAL, "product_ids" TEXT, "max_value" REAL, "valid_till" TEXT, "max_limit_for_user" INTEGER, "exclusive_apply" INTEGER NOT NULL DEFAULT false, "is_redeemed" INTEGER NOT NULL DEFAULT false, "redeemed_by" INTEGER, "redeemed_at" TEXT, "created_by" INTEGER NOT NULL, "created_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP);
INSERT INTO "reserved_coupons" ("id","secret_code","coupon_code","discount_percent","flat_discount","min_order","product_ids","max_value","valid_till","max_limit_for_user","exclusive_apply","is_redeemed","redeemed_by","redeemed_at","created_by","created_at") VALUES(1,'RESERVE_TEST34','RESERVE_TEST34',25,NULL,1000,NULL,250,'2026-01-30T13:16:00.000Z',2,0,1,1,'2026-01-12T08:58:20.468Z',6,'2026-01-07T13:16:53.387Z');
CREATE TABLE IF NOT EXISTS "special_deals" ("id" INTEGER PRIMARY KEY, "product_id" INTEGER NOT NULL, "quantity" REAL NOT NULL, "price" REAL NOT NULL, "valid_till" TEXT NOT NULL);
@ -46133,6 +46144,7 @@ INSERT INTO "upload_url_status" ("id","created_at","key","status") VALUES(144,'2
INSERT INTO "upload_url_status" ("id","created_at","key","status") VALUES(145,'2026-04-08 18:25:46','product-images/1775672746319.jpg','claimed');
INSERT INTO "upload_url_status" ("id","created_at","key","status") VALUES(146,'2026-04-08 18:41:57','product-images/1775673717536.jpg','pending');
INSERT INTO "upload_url_status" ("id","created_at","key","status") VALUES(147,'2026-04-08 18:42:58','product-images/1775673778289.jpg','pending');
INSERT INTO "upload_url_status" ("id","created_at","key","status") VALUES(148,'2026-04-09 03:39:25','product-images/1775705965861.jpg','claimed');
CREATE TABLE IF NOT EXISTS "user_creds" ("id" INTEGER PRIMARY KEY, "user_id" INTEGER NOT NULL, "user_password" TEXT NOT NULL, "created_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP);
INSERT INTO "user_creds" ("id","user_id","user_password","created_at") VALUES(2,1,'$2b$10$aJacFZFCniKqXOewMIlznOsEKcTJa/ji7xBU2dhHsioxTC0mR9BvK','2025-11-19T17:30:25.180Z');
INSERT INTO "user_creds" ("id","user_id","user_password","created_at") VALUES(3,17,'$2b$10$mn/CpXmKq.dKgeH2gHtKk.IvlgQyahG2tCpD8k42mPOEysWoO3pti','2025-12-19T09:14:09.761Z');

File diff suppressed because it is too large Load diff

View file

@ -9,7 +9,9 @@
"db:seed": "tsx src/db/seed.ts",
"dev2": "tsx watch index.ts",
"dev_node": "tsx watch index.ts",
"dev": "bun --watch index.ts",
"dev_prev": "bun --watch index.ts",
"dev": "wrangler dev --config wrangler.dev.toml --ip 0.0.0.0",
"deploy": "wrangler deploy --config wrangler.prod.toml",
"wrangler:dev": "wrangler dev worker.ts --config wrangler.toml",
"wrangler:deploy": "wrangler deploy worker.ts --config wrangler.toml",
"docker:build": "cd .. && docker buildx build --platform linux/amd64 -t mohdshafiuddin54/health_petal:latest --progress=plain -f backend/Dockerfile .",

28
apps/backend/reset-remote-db.sh Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -euo pipefail
DB_NAME="freshyo-dev"
DUMP_DIR="./dumps"
MIGRATION_FILE="./migrated.sql"
if ! command -v wrangler >/dev/null 2>&1; then
echo "wrangler not found in PATH"
exit 1
fi
if [ ! -f "$MIGRATION_FILE" ]; then
echo "Migration file not found: $MIGRATION_FILE"
exit 1
fi
mkdir -p "$DUMP_DIR"
TIMESTAMP="$(date +"%d%m%y_%H%M")"
DUMP_FILE="${DUMP_DIR}/${TIMESTAMP}_${DB_NAME}.sql"
wrangler d1 export "$DB_NAME" --remote --output "$DUMP_FILE"
wrangler d1 delete "$DB_NAME"
wrangler d1 create "$DB_NAME"
wrangler d1 execute "$DB_NAME" --remote --file="$MIGRATION_FILE"
echo "Done. Dump saved at: $DUMP_FILE"

View file

@ -35,7 +35,7 @@ const formatOrderMessageWithFullData = (ordersData: any[]): string => {
message += '📦 <b>Items:</b>\n';
order.orderItems?.forEach((item: any) => {
message += `${item.product?.name || 'Unknown'} x${item.quantity}\n`;
message += `${item.product?.name || 'Unknown'} ${item.product.productQuantity}${item.product.unit?.shortNotation}x${item.quantity}\n`;
});
message += `\n💰 <b>Total:</b> ₹${order.totalAmount}\n`;
@ -88,7 +88,6 @@ ${orderData.orderItems?.map((item: any) => ` • ${item.product?.name || 'Unkno
export const handleOrderPlaced = async (orderIds: number[], rawMessage?: string): Promise<void> => {
try {
const ordersData = await getOrdersByIdsWithFullData(orderIds)
console.log({ordersData});
const telegramMessage = formatOrderMessageWithFullData(ordersData)
await sendTelegramMessage(telegramMessage)
} catch (error) {
@ -114,6 +113,7 @@ export const handleOrderCancelled = async (
const refundStatus = orderData.refunds?.[0]?.refundStatus || 'pending'
const telegramMessage = formatCancellationMessage({ ...orderData, refundStatus }, cancellationData)
await sendTelegramMessage(telegramMessage)
} catch (error) {

View file

@ -7,7 +7,6 @@ import { getIsDevMode, getTelegramBotToken, getTelegramChatIds } from '@/src/lib
* @returns Promise<boolean | null> indicating success, failure, or null if dev mode
*/
export const sendTelegramMessage = async (message: string): Promise<boolean | null> => {
console.log('from send telegram message')
if (getIsDevMode()) {
return null;
}
@ -18,7 +17,6 @@ export const sendTelegramMessage = async (message: string): Promise<boolean | nu
return null
}
const telegramApiUrl = `https://api.telegram.org/bot${botToken}`
console.log(botToken, chatIds, telegramApiUrl)
try {
const results = await Promise.all(
chatIds.map(async (chatId) => {

View file

@ -31,6 +31,7 @@ export async function scaffoldEssentialConsts() {
playStoreUrl: consts[CONST_KEYS.playStoreUrl],
appStoreUrl: consts[CONST_KEYS.appStoreUrl],
webViewHtml: null,
webviewHtml: null,
isWebviewClosable: true,
isFlashDeliveryEnabled: consts[CONST_KEYS.isFlashDeliveryEnabled] ?? false,
supportMobile: consts[CONST_KEYS.supportMobile] ?? '',
@ -150,9 +151,23 @@ export const commonApiRouter = router({
}),
essentialConsts: publicProcedure
.query(async () => {
.query(async ({ ctx }) => {
const requestUrl = ctx.req.url
const host = new URL(requestUrl).host
console.log('essentialConsts request', { host, url: requestUrl })
const updateNotice = `<div style="display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%;">
<h1 style="font-size: 72px">You're using an old version of app. please restart to update. Just close and open</h1>
<h1 style="font-size: 36px; margin-top: 48px">With love, from Freshyo</h5>
</div>`
const response = await scaffoldEssentialConsts();
return response;
const shouldShowNotice = host.includes('raw') || host.includes('mf')
return {
...response,
webviewHtml: shouldShowNotice ? updateNotice : null,
isWebviewClosable: shouldShowNotice ? false : true
};
}),
});

View file

@ -9,7 +9,7 @@ routes = [
[[d1_databases]]
binding = "DB"
database_name = "freshyo-dev"
database_id = "ed09e4a2-4b36-472f-8ff3-dd6c704b1b99"
database_id = "3cad440f-dc14-4baa-ab05-04eb08e206de"
[durable_objects]
bindings = [
{ name = "CACHE_CREATOR", class_name = "CacheCreator" },

View file

@ -0,0 +1,92 @@
name = "freshyo-backend"
main = "worker.ts"
compatibility_date = "2024-12-01"
compatibility_flags = ["nodejs_compat"]
routes = [
{ pattern = "api.freshyo.in/*", zone_name = "freshyo.in" }
]
[[d1_databases]]
binding = "DB"
database_name = "freshyo-dev"
database_id = "3cad440f-dc14-4baa-ab05-04eb08e206de"
[durable_objects]
bindings = [
{ name = "CACHE_CREATOR", class_name = "CacheCreator" },
]
[[migrations]]
tag = "cache-creator-v1"
new_classes = ["CacheCreator"]
[[queues.producers]]
binding = "NOTIF_QUEUE"
queue = "notif-queue"
[[queues.producers]]
binding = "ORDER_PLACED_QUEUE"
queue = "order-placed-queue"
[[queues.producers]]
binding = "ORDER_CANCELLED_QUEUE"
queue = "order-cancelled-queue"
[[queues.consumers]]
queue = "notif-queue"
[[queues.consumers]]
queue = "order-placed-queue"
[[queues.consumers]]
queue = "order-cancelled-queue"
[observability]
enabled = false
head_sampling_rate = 1
[observability.logs]
enabled = true
head_sampling_rate = 1
persist = true
invocation_logs = true
[observability.traces]
enabled = false
persist = true
head_sampling_rate = 1
[vars]
ENV_MODE = "PROD"
NOTIF_QUEUE_NAME = "notif-queue"
ORDER_PLACED_QUEUE_NAME = "order-placed-queue"
ORDER_CANCELLED_QUEUE_NAME = "order-cancelled-queue"
DATABASE_URL = "postgresql://postgres:meatfarmer_master_password@57.128.212.174:7447/meatfarmer"
PHONE_PE_BASE_URL = "https://api-preprod.phonepe.com/"
PHONE_PE_CLIENT_ID = "TEST-M23F2IGP34ZAR_25090"
PHONE_PE_CLIENT_VERSION = "1"
PHONE_PE_CLIENT_SECRET = "MTU1MmIzOTgtM2Q0Mi00N2M5LTkyMWUtNzBiMjdmYzVmZWUy"
PHONE_PE_MERCHANT_ID = "M23F2IGP34ZAR"
S3_REGION = "apac"
S3_ACCESS_KEY_ID = "8fab47503efb9547b50e4fb317e35cc7"
S3_SECRET_ACCESS_KEY = "47c2eb5636843cf568dda7ad0959a3e42071303f26dbdff94bd45a3c33dcd950"
S3_URL = "https://da9b1aa7c1951c23e2c0c3246ba68a58.r2.cloudflarestorage.com"
S3_BUCKET_NAME = "meatfarmer"
EXPO_ACCESS_TOKEN = "Asvpy8cByRh6T4ksnWScO6PLcio2n35-BwES5zK-"
JWT_SECRET = "my_meatfarmer_jwt_secret_key"
ASSETS_DOMAIN = "https://assets.freshyo.in/"
API_CACHE_KEY = "api-cache"
CLOUDFLARE_API_TOKEN = "N7jAg5X-RUj_fVfMW6zbfJ8qIYc81TSIKKlbZ6oh"
CLOUDFLARE_ZONE_ID = "edefbf750bfc3ff26ccd11e8e28dc8d7"
REDIS_URL = "redis://default:redis_shafi_password@57.128.212.174:6379"
APP_URL = "https://ui.freshyo.in"
RAZORPAY_KEY = "rzp_test_RdCBBUJ56NLaJK"
RAZORPAY_SECRET = "namEwKBE1ypWxH0QDVg6fWOe"
OTP_SENDER_AUTH_TOKEN = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJDLTM5OENEMkJDRTM0MjQ4OCIsImlhdCI6MTc0Nzg0MTEwMywiZXhwIjoxOTA1NTIxMTAzfQ.IV64ofVKjcwveIanxu_P2XlACtPeA9sJQ74uM53osDeyUXsFv0rwkCl6NNBIX93s_wnh4MKITLbcF_ClwmFQ0A"
MIN_ORDER_VALUE = "300"
DELIVERY_CHARGE = "20"
TELEGRAM_BOT_TOKEN = "8410461852:AAGXQCwRPFbndqwTgLJh8kYxST4Z0vgh72U"
# TELEGRAM_CHAT_IDS = "5147760058"
TELEGRAM_CHAT_IDS = "-5075171894"
[build]
upload_source_maps = true

View file

@ -26,6 +26,7 @@ export default function WebViewWrapper({ children }: WebViewWrapperProps) {
const webviewHtml = constsData?.webviewHtml;
const isWebviewClosable = constsData?.isWebviewClosable;
if (webviewHtml && !isClosed) {
return (
<View style={{ flex: 1 }}>

View file

@ -170,7 +170,9 @@ export default function CartPage({ isFlashDelivery = false }: CartPageProps) {
const getAvailableSlotsForProduct = React.useMemo(() => {
return (productId: number) => {
if (!slotsData || !slotsData[productId]) return [];
return slotsData[productId].map((slot) => {
return slotsData[productId]
.filter((slot) => dayjs(slot.deliveryTime).isAfter(dayjs()))
.map((slot) => {
const formatTimeRange = (deliveryTime: string) => {
const time = dayjs(deliveryTime);
const endTime = time.add(1, 'hour');

View file

@ -105,7 +105,8 @@ export default function AddToCartDialog() {
const availableSlots = availableSlotIds
.map((slotId) => slotMap[slotId])
.filter(Boolean);
.filter(Boolean)
.filter((slot) => dayjs(slot.deliveryTime).isAfter(dayjs()));
// Find cart item for this product
const cartItem = cartData?.items?.find((item: any) => item.productId === product?.id);

View file

@ -109,9 +109,10 @@ export function useStoreWithProducts(storeId: number) {
const assetsDomain = essentialConsts?.assetsDomain
const apiCacheKey = essentialConsts?.apiCacheKey
const cacheVersion = essentialConsts?.cacheVersion;
const cacheUrl = assetsDomain && apiCacheKey
? `${assetsDomain}${apiCacheKey}/stores/${storeId}.json`
? `${assetsDomain}${apiCacheKey}/v-${cacheVersion}/stores/${storeId}.json`
: null
return useQuery<StoreWithProductsResponse>({

View file

@ -713,7 +713,11 @@ export async function getOrdersByIdsWithFullData(
product: {
columns: {
name: true,
productQuantity: true,
},
with: {
unit: true
}
},
},
},

Binary file not shown.

View file

@ -65,8 +65,8 @@ const isDevMode = Constants.executionEnvironment !== "standalone";
// 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.1.5:4000';
// const BASE_API_URL = 'http://192.168.1.5:8787';
// let BASE_API_URL = "https://mf.freshyo.in";
// const BASE_API_URL = 'http://192.168.1.5:8787';
// let BASE_API_URL = "https://raw.freshyo.in";
let BASE_API_URL = "https://worker.freshyo.in";
// let BASE_API_URL = "https://freshyo.technocracy.ovh";
// let BASE_API_URL = 'http://192.168.100.109:8787';