@fctc/interface-logic 4.4.7 → 4.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.d.mts +71 -1
- package/dist/constants.d.ts +71 -1
- package/dist/constants.js +96 -0
- package/dist/constants.mjs +93 -0
- package/dist/hooks.d.mts +21 -1
- package/dist/hooks.d.ts +21 -1
- package/dist/hooks.js +146 -68
- package/dist/hooks.mjs +144 -68
- package/dist/provider.d.mts +3 -1
- package/dist/provider.d.ts +3 -1
- package/dist/provider.js +150 -74
- package/dist/provider.mjs +145 -69
- package/dist/services.d.mts +6 -2
- package/dist/services.d.ts +6 -2
- package/dist/services.js +161 -164
- package/dist/services.mjs +158 -161
- package/package.json +1 -1
package/dist/provider.js
CHANGED
|
@@ -807,6 +807,25 @@ var LoadDataModel = /* @__PURE__ */ ((LoadDataModel2) => {
|
|
|
807
807
|
LoadDataModel2["POS_MAKE_PAYMENT"] = "pos.make.payment";
|
|
808
808
|
return LoadDataModel2;
|
|
809
809
|
})(LoadDataModel || {});
|
|
810
|
+
var MODEL_TO_TABLE = {
|
|
811
|
+
["account.tax" /* ACCOUNT_TAX */]: "account_taxes" /* ACCOUNT_TAXES */,
|
|
812
|
+
["res.company" /* RES_COMPANY */]: "companies" /* COMPANIES */,
|
|
813
|
+
["res.partner" /* RES_PARTNER */]: "customers" /* CUSTOMERS */,
|
|
814
|
+
["res.users" /* RES_USERS */]: "employees" /* EMPLOYEES */,
|
|
815
|
+
["loyalty.program" /* LOYALTY_PROGRAM */]: "loyalty_programs" /* LOYALTY_PROGRAMS */,
|
|
816
|
+
["loyalty.rule" /* LOYALTY_RULE */]: "loyalty_rules" /* LOYALTY_RULES */,
|
|
817
|
+
["loyalty.reward" /* LOYALTY_REWARD */]: "loyalty_rewards" /* LOYALTY_REWARDS */,
|
|
818
|
+
["pos.config" /* POS_CONFIG */]: "pos_configs" /* POS_CONFIGS */,
|
|
819
|
+
["pos.session" /* POS_SESSION */]: "pos_sessions" /* POS_SESSIONS */,
|
|
820
|
+
["pos.order.line" /* POS_ORDER_LINE */]: "order_lines" /* ORDER_LINES */,
|
|
821
|
+
["pos.order" /* POS_ORDER */]: "orders" /* ORDERS */,
|
|
822
|
+
["pos.payment.method" /* POS_PAYMENT_METHOD */]: "payment_methods" /* PAYMENT_METHODS */,
|
|
823
|
+
["pos.payment" /* POS_PAYMENT */]: "payments" /* PAYMENTS */,
|
|
824
|
+
["pos.category" /* POS_CATEGORY */]: "product_categories" /* PRODUCT_CATEGORIES */,
|
|
825
|
+
["product.product" /* PRODUCT_PRODUCT */]: "products" /* PRODUCTS */,
|
|
826
|
+
["restaurant.floor" /* RESTAURANT_FLOOR */]: "restaurant_floors" /* RESTAURANT_FLOORS */,
|
|
827
|
+
["restaurant.table" /* RESTAURANT_TABLE */]: "restaurant_tables" /* RESTAURANT_TABLES */
|
|
828
|
+
};
|
|
810
829
|
|
|
811
830
|
// src/constants/widget/widget-avatar-constant.ts
|
|
812
831
|
var WIDGETAVATAR = /* @__PURE__ */ ((WIDGETAVATAR2) => {
|
|
@@ -5320,8 +5339,13 @@ var addEntityService = (env) => {
|
|
|
5320
5339
|
values,
|
|
5321
5340
|
xNode,
|
|
5322
5341
|
service,
|
|
5323
|
-
isCreateEndpoint = false
|
|
5342
|
+
isCreateEndpoint = false,
|
|
5343
|
+
isSupa = false,
|
|
5344
|
+
supaCallback
|
|
5324
5345
|
}) => {
|
|
5346
|
+
if (isSupa && supaCallback) {
|
|
5347
|
+
return supaCallback(values);
|
|
5348
|
+
}
|
|
5325
5349
|
const jsonData = {
|
|
5326
5350
|
model,
|
|
5327
5351
|
values
|
|
@@ -5465,8 +5489,13 @@ var createEntityService = (env) => {
|
|
|
5465
5489
|
model,
|
|
5466
5490
|
args,
|
|
5467
5491
|
xNode,
|
|
5468
|
-
service
|
|
5492
|
+
service,
|
|
5493
|
+
isSupa = false,
|
|
5494
|
+
supaCallback
|
|
5469
5495
|
}) => {
|
|
5496
|
+
if (isSupa && supaCallback) {
|
|
5497
|
+
return supaCallback(args);
|
|
5498
|
+
}
|
|
5470
5499
|
const jsonData = {
|
|
5471
5500
|
model,
|
|
5472
5501
|
method: "create" /* CREATE */,
|
|
@@ -6032,25 +6061,12 @@ var handleClosingSessionService = (env) => {
|
|
|
6032
6061
|
|
|
6033
6062
|
// src/services/pos-service/load-data-pos-session.ts
|
|
6034
6063
|
var import_react34 = require("react");
|
|
6035
|
-
var
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
["loyalty.rule" /* LOYALTY_RULE */]: "loyalty_rules",
|
|
6042
|
-
["loyalty.reward" /* LOYALTY_REWARD */]: "loyalty_rewards",
|
|
6043
|
-
["pos.config" /* POS_CONFIG */]: "pos_configs",
|
|
6044
|
-
["pos.session" /* POS_SESSION */]: "pos_sessions",
|
|
6045
|
-
["pos.order.line" /* POS_ORDER_LINE */]: "order_lines",
|
|
6046
|
-
["pos.order" /* POS_ORDER */]: "orders",
|
|
6047
|
-
["pos.payment.method" /* POS_PAYMENT_METHOD */]: "payment_methods",
|
|
6048
|
-
["pos.payment" /* POS_PAYMENT */]: "payments",
|
|
6049
|
-
["pos.category" /* POS_CATEGORY */]: "product_categories",
|
|
6050
|
-
["product.product" /* PRODUCT_PRODUCT */]: "products",
|
|
6051
|
-
["restaurant.floor" /* RESTAURANT_FLOOR */]: "restaurant_floors",
|
|
6052
|
-
["restaurant.table" /* RESTAURANT_TABLE */]: "restaurant_tables"
|
|
6053
|
-
};
|
|
6064
|
+
var createModelResult = (modelName, data = []) => ({
|
|
6065
|
+
modelName,
|
|
6066
|
+
data,
|
|
6067
|
+
fields: {},
|
|
6068
|
+
relations: {}
|
|
6069
|
+
});
|
|
6054
6070
|
var loadDataPosSessionService = (env) => {
|
|
6055
6071
|
const supabase = useSupabaseOptional();
|
|
6056
6072
|
const loadDataPosSession = (0, import_react34.useCallback)(
|
|
@@ -6092,56 +6108,25 @@ var loadDataPosSessionService = (env) => {
|
|
|
6092
6108
|
[env]
|
|
6093
6109
|
);
|
|
6094
6110
|
const loadDataPosSessionSupabase = (0, import_react34.useCallback)(async () => {
|
|
6111
|
+
if (!supabase) return {};
|
|
6095
6112
|
try {
|
|
6096
6113
|
const allModels = Object.values(LoadDataModel);
|
|
6097
|
-
const
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
return
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
}
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
return {
|
|
6109
|
-
modelName,
|
|
6110
|
-
data: [],
|
|
6111
|
-
fields: {},
|
|
6112
|
-
relations: {}
|
|
6113
|
-
};
|
|
6114
|
-
}
|
|
6115
|
-
const { data, error } = await supabase.from(tableName).select("*");
|
|
6116
|
-
if (error) {
|
|
6117
|
-
console.error(`Error loading ${modelName}:`, error);
|
|
6118
|
-
return {
|
|
6119
|
-
modelName,
|
|
6120
|
-
data: [],
|
|
6121
|
-
fields: {},
|
|
6122
|
-
relations: {}
|
|
6123
|
-
};
|
|
6124
|
-
}
|
|
6125
|
-
return {
|
|
6126
|
-
modelName,
|
|
6127
|
-
data: data || [],
|
|
6128
|
-
fields: {},
|
|
6129
|
-
relations: {}
|
|
6130
|
-
};
|
|
6131
|
-
});
|
|
6132
|
-
const results = await Promise.all(promises);
|
|
6133
|
-
const response = results.reduce(
|
|
6134
|
-
(acc, { modelName, data, fields, relations }) => {
|
|
6135
|
-
acc[modelName] = {
|
|
6136
|
-
data,
|
|
6137
|
-
fields,
|
|
6138
|
-
relations
|
|
6139
|
-
};
|
|
6140
|
-
return acc;
|
|
6141
|
-
},
|
|
6142
|
-
{}
|
|
6114
|
+
const results = await Promise.all(
|
|
6115
|
+
allModels.map(async (modelName) => {
|
|
6116
|
+
const tableName = MODEL_TO_TABLE[modelName];
|
|
6117
|
+
if (!tableName) return createModelResult(modelName);
|
|
6118
|
+
const { data, error } = await supabase.from(tableName).select("*");
|
|
6119
|
+
if (error) {
|
|
6120
|
+
console.error(`Error loading ${modelName}:`, error);
|
|
6121
|
+
return createModelResult(modelName);
|
|
6122
|
+
}
|
|
6123
|
+
return createModelResult(modelName, data || []);
|
|
6124
|
+
})
|
|
6143
6125
|
);
|
|
6144
|
-
return
|
|
6126
|
+
return results.reduce((acc, { modelName, ...rest }) => {
|
|
6127
|
+
acc[modelName] = rest;
|
|
6128
|
+
return acc;
|
|
6129
|
+
}, {});
|
|
6145
6130
|
} catch (error) {
|
|
6146
6131
|
console.error("Error loading data from Supabase:", error);
|
|
6147
6132
|
return {};
|
|
@@ -7017,7 +7002,7 @@ function useEnv() {
|
|
|
7017
7002
|
}
|
|
7018
7003
|
|
|
7019
7004
|
// src/provider/service-provider.tsx
|
|
7020
|
-
var
|
|
7005
|
+
var import_react49 = require("react");
|
|
7021
7006
|
|
|
7022
7007
|
// src/hooks/auth/use-forgot-password.ts
|
|
7023
7008
|
var import_react_query3 = require("@tanstack/react-query");
|
|
@@ -9020,9 +9005,98 @@ var useCompleteCurrentStage = () => {
|
|
|
9020
9005
|
};
|
|
9021
9006
|
var use_complete_current_stage_default = useCompleteCurrentStage;
|
|
9022
9007
|
|
|
9008
|
+
// src/hooks/pos/supabase/use-add-floor.ts
|
|
9009
|
+
var import_react_query115 = require("@tanstack/react-query");
|
|
9010
|
+
|
|
9011
|
+
// src/services/pos-service/supabase/add-floor.ts
|
|
9012
|
+
var import_react47 = require("react");
|
|
9013
|
+
var addFloorSupabaseService = () => {
|
|
9014
|
+
const supabase = useSupabaseOptional();
|
|
9015
|
+
const addFloorSupabase = (0, import_react47.useCallback)(
|
|
9016
|
+
async (values) => {
|
|
9017
|
+
if (!supabase) {
|
|
9018
|
+
console.error("Supabase client not initialized");
|
|
9019
|
+
return null;
|
|
9020
|
+
}
|
|
9021
|
+
try {
|
|
9022
|
+
const { data, error } = await supabase.from("restaurant_floors" /* RESTAURANT_FLOORS */).insert({
|
|
9023
|
+
name: values.name,
|
|
9024
|
+
sequence: values.sequence ?? 1,
|
|
9025
|
+
pos_config_ids: values.pos_config_ids ?? [],
|
|
9026
|
+
table_ids: values.table_ids ?? []
|
|
9027
|
+
}).select("id, name").single();
|
|
9028
|
+
if (error) {
|
|
9029
|
+
console.error("Error adding floor:", error);
|
|
9030
|
+
return null;
|
|
9031
|
+
}
|
|
9032
|
+
return [[data.id, data.name]];
|
|
9033
|
+
} catch (error) {
|
|
9034
|
+
console.error("Error adding floor:", error);
|
|
9035
|
+
return null;
|
|
9036
|
+
}
|
|
9037
|
+
},
|
|
9038
|
+
[supabase]
|
|
9039
|
+
);
|
|
9040
|
+
return {
|
|
9041
|
+
addFloorSupabase
|
|
9042
|
+
};
|
|
9043
|
+
};
|
|
9044
|
+
|
|
9045
|
+
// src/services/pos-service/supabase/add-table.ts
|
|
9046
|
+
var import_react48 = require("react");
|
|
9047
|
+
var addTableSupabaseService = () => {
|
|
9048
|
+
const supabase = useSupabaseOptional();
|
|
9049
|
+
const addTableSupabase = (0, import_react48.useCallback)(
|
|
9050
|
+
async (values) => {
|
|
9051
|
+
if (!supabase) {
|
|
9052
|
+
console.error("Supabase client not initialized");
|
|
9053
|
+
return null;
|
|
9054
|
+
}
|
|
9055
|
+
try {
|
|
9056
|
+
const { data, error } = await supabase.from("restaurant_tables" /* RESTAURANT_TABLES */).insert({
|
|
9057
|
+
floor_id: values.floor_id,
|
|
9058
|
+
table_number: values.table_number ?? 0,
|
|
9059
|
+
seats: values.seats ?? 1
|
|
9060
|
+
}).select("id, table_number").single();
|
|
9061
|
+
if (error) {
|
|
9062
|
+
console.error("Error adding table:", error);
|
|
9063
|
+
return null;
|
|
9064
|
+
}
|
|
9065
|
+
return [[data.id, data.table_number]];
|
|
9066
|
+
} catch (error) {
|
|
9067
|
+
console.error("Error adding table:", error);
|
|
9068
|
+
return null;
|
|
9069
|
+
}
|
|
9070
|
+
},
|
|
9071
|
+
[supabase]
|
|
9072
|
+
);
|
|
9073
|
+
return {
|
|
9074
|
+
addTableSupabase
|
|
9075
|
+
};
|
|
9076
|
+
};
|
|
9077
|
+
|
|
9078
|
+
// src/hooks/pos/supabase/use-add-floor.ts
|
|
9079
|
+
var useAddFloor = () => {
|
|
9080
|
+
const { addFloorSupabase } = addFloorSupabaseService();
|
|
9081
|
+
return (0, import_react_query115.useMutation)({
|
|
9082
|
+
mutationFn: addFloorSupabase
|
|
9083
|
+
});
|
|
9084
|
+
};
|
|
9085
|
+
var use_add_floor_default = useAddFloor;
|
|
9086
|
+
|
|
9087
|
+
// src/hooks/pos/supabase/use-add-table.ts
|
|
9088
|
+
var import_react_query116 = require("@tanstack/react-query");
|
|
9089
|
+
var useAddTable = () => {
|
|
9090
|
+
const { addTableSupabase } = addTableSupabaseService();
|
|
9091
|
+
return (0, import_react_query116.useMutation)({
|
|
9092
|
+
mutationFn: addTableSupabase
|
|
9093
|
+
});
|
|
9094
|
+
};
|
|
9095
|
+
var use_add_table_default = useAddTable;
|
|
9096
|
+
|
|
9023
9097
|
// src/provider/service-provider.tsx
|
|
9024
9098
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
9025
|
-
var ServiceContext = (0,
|
|
9099
|
+
var ServiceContext = (0, import_react49.createContext)(null);
|
|
9026
9100
|
var ServiceProvider = ({
|
|
9027
9101
|
children
|
|
9028
9102
|
}) => {
|
|
@@ -9140,12 +9214,14 @@ var ServiceProvider = ({
|
|
|
9140
9214
|
useGetCountry: use_get_country_default,
|
|
9141
9215
|
useGetPartnerTitle: use_get_partner_title_default,
|
|
9142
9216
|
useCompleteCurrentStage: use_complete_current_stage_default,
|
|
9143
|
-
useLoginSupa: use_login_supa_default
|
|
9217
|
+
useLoginSupa: use_login_supa_default,
|
|
9218
|
+
useAddFloor: use_add_floor_default,
|
|
9219
|
+
useAddTable: use_add_table_default
|
|
9144
9220
|
};
|
|
9145
9221
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ServiceContext.Provider, { value: services, children });
|
|
9146
9222
|
};
|
|
9147
9223
|
var useService = () => {
|
|
9148
|
-
const context = (0,
|
|
9224
|
+
const context = (0, import_react49.useContext)(ServiceContext);
|
|
9149
9225
|
if (!context) {
|
|
9150
9226
|
throw new Error("useService must be used within a ServiceProvider");
|
|
9151
9227
|
}
|
|
@@ -9153,7 +9229,7 @@ var useService = () => {
|
|
|
9153
9229
|
};
|
|
9154
9230
|
|
|
9155
9231
|
// src/provider/meta-provider.tsx
|
|
9156
|
-
var
|
|
9232
|
+
var import_react50 = require("react");
|
|
9157
9233
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
9158
9234
|
var MetaProvider = ({ children }) => {
|
|
9159
9235
|
const { env } = useEnv();
|
|
@@ -9202,7 +9278,7 @@ var MetaProvider = ({ children }) => {
|
|
|
9202
9278
|
}
|
|
9203
9279
|
}
|
|
9204
9280
|
}
|
|
9205
|
-
(0,
|
|
9281
|
+
(0, import_react50.useEffect)(() => {
|
|
9206
9282
|
updateMetadata();
|
|
9207
9283
|
}, [env?.defaultCompany]);
|
|
9208
9284
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children });
|
package/dist/provider.mjs
CHANGED
|
@@ -762,6 +762,25 @@ var LoadDataModel = /* @__PURE__ */ ((LoadDataModel2) => {
|
|
|
762
762
|
LoadDataModel2["POS_MAKE_PAYMENT"] = "pos.make.payment";
|
|
763
763
|
return LoadDataModel2;
|
|
764
764
|
})(LoadDataModel || {});
|
|
765
|
+
var MODEL_TO_TABLE = {
|
|
766
|
+
["account.tax" /* ACCOUNT_TAX */]: "account_taxes" /* ACCOUNT_TAXES */,
|
|
767
|
+
["res.company" /* RES_COMPANY */]: "companies" /* COMPANIES */,
|
|
768
|
+
["res.partner" /* RES_PARTNER */]: "customers" /* CUSTOMERS */,
|
|
769
|
+
["res.users" /* RES_USERS */]: "employees" /* EMPLOYEES */,
|
|
770
|
+
["loyalty.program" /* LOYALTY_PROGRAM */]: "loyalty_programs" /* LOYALTY_PROGRAMS */,
|
|
771
|
+
["loyalty.rule" /* LOYALTY_RULE */]: "loyalty_rules" /* LOYALTY_RULES */,
|
|
772
|
+
["loyalty.reward" /* LOYALTY_REWARD */]: "loyalty_rewards" /* LOYALTY_REWARDS */,
|
|
773
|
+
["pos.config" /* POS_CONFIG */]: "pos_configs" /* POS_CONFIGS */,
|
|
774
|
+
["pos.session" /* POS_SESSION */]: "pos_sessions" /* POS_SESSIONS */,
|
|
775
|
+
["pos.order.line" /* POS_ORDER_LINE */]: "order_lines" /* ORDER_LINES */,
|
|
776
|
+
["pos.order" /* POS_ORDER */]: "orders" /* ORDERS */,
|
|
777
|
+
["pos.payment.method" /* POS_PAYMENT_METHOD */]: "payment_methods" /* PAYMENT_METHODS */,
|
|
778
|
+
["pos.payment" /* POS_PAYMENT */]: "payments" /* PAYMENTS */,
|
|
779
|
+
["pos.category" /* POS_CATEGORY */]: "product_categories" /* PRODUCT_CATEGORIES */,
|
|
780
|
+
["product.product" /* PRODUCT_PRODUCT */]: "products" /* PRODUCTS */,
|
|
781
|
+
["restaurant.floor" /* RESTAURANT_FLOOR */]: "restaurant_floors" /* RESTAURANT_FLOORS */,
|
|
782
|
+
["restaurant.table" /* RESTAURANT_TABLE */]: "restaurant_tables" /* RESTAURANT_TABLES */
|
|
783
|
+
};
|
|
765
784
|
|
|
766
785
|
// src/constants/widget/widget-avatar-constant.ts
|
|
767
786
|
var WIDGETAVATAR = /* @__PURE__ */ ((WIDGETAVATAR2) => {
|
|
@@ -5275,8 +5294,13 @@ var addEntityService = (env) => {
|
|
|
5275
5294
|
values,
|
|
5276
5295
|
xNode,
|
|
5277
5296
|
service,
|
|
5278
|
-
isCreateEndpoint = false
|
|
5297
|
+
isCreateEndpoint = false,
|
|
5298
|
+
isSupa = false,
|
|
5299
|
+
supaCallback
|
|
5279
5300
|
}) => {
|
|
5301
|
+
if (isSupa && supaCallback) {
|
|
5302
|
+
return supaCallback(values);
|
|
5303
|
+
}
|
|
5280
5304
|
const jsonData = {
|
|
5281
5305
|
model,
|
|
5282
5306
|
values
|
|
@@ -5420,8 +5444,13 @@ var createEntityService = (env) => {
|
|
|
5420
5444
|
model,
|
|
5421
5445
|
args,
|
|
5422
5446
|
xNode,
|
|
5423
|
-
service
|
|
5447
|
+
service,
|
|
5448
|
+
isSupa = false,
|
|
5449
|
+
supaCallback
|
|
5424
5450
|
}) => {
|
|
5451
|
+
if (isSupa && supaCallback) {
|
|
5452
|
+
return supaCallback(args);
|
|
5453
|
+
}
|
|
5425
5454
|
const jsonData = {
|
|
5426
5455
|
model,
|
|
5427
5456
|
method: "create" /* CREATE */,
|
|
@@ -5987,25 +6016,12 @@ var handleClosingSessionService = (env) => {
|
|
|
5987
6016
|
|
|
5988
6017
|
// src/services/pos-service/load-data-pos-session.ts
|
|
5989
6018
|
import { useCallback as useCallback31 } from "react";
|
|
5990
|
-
var
|
|
5991
|
-
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
["loyalty.rule" /* LOYALTY_RULE */]: "loyalty_rules",
|
|
5997
|
-
["loyalty.reward" /* LOYALTY_REWARD */]: "loyalty_rewards",
|
|
5998
|
-
["pos.config" /* POS_CONFIG */]: "pos_configs",
|
|
5999
|
-
["pos.session" /* POS_SESSION */]: "pos_sessions",
|
|
6000
|
-
["pos.order.line" /* POS_ORDER_LINE */]: "order_lines",
|
|
6001
|
-
["pos.order" /* POS_ORDER */]: "orders",
|
|
6002
|
-
["pos.payment.method" /* POS_PAYMENT_METHOD */]: "payment_methods",
|
|
6003
|
-
["pos.payment" /* POS_PAYMENT */]: "payments",
|
|
6004
|
-
["pos.category" /* POS_CATEGORY */]: "product_categories",
|
|
6005
|
-
["product.product" /* PRODUCT_PRODUCT */]: "products",
|
|
6006
|
-
["restaurant.floor" /* RESTAURANT_FLOOR */]: "restaurant_floors",
|
|
6007
|
-
["restaurant.table" /* RESTAURANT_TABLE */]: "restaurant_tables"
|
|
6008
|
-
};
|
|
6019
|
+
var createModelResult = (modelName, data = []) => ({
|
|
6020
|
+
modelName,
|
|
6021
|
+
data,
|
|
6022
|
+
fields: {},
|
|
6023
|
+
relations: {}
|
|
6024
|
+
});
|
|
6009
6025
|
var loadDataPosSessionService = (env) => {
|
|
6010
6026
|
const supabase = useSupabaseOptional();
|
|
6011
6027
|
const loadDataPosSession = useCallback31(
|
|
@@ -6047,56 +6063,25 @@ var loadDataPosSessionService = (env) => {
|
|
|
6047
6063
|
[env]
|
|
6048
6064
|
);
|
|
6049
6065
|
const loadDataPosSessionSupabase = useCallback31(async () => {
|
|
6066
|
+
if (!supabase) return {};
|
|
6050
6067
|
try {
|
|
6051
6068
|
const allModels = Object.values(LoadDataModel);
|
|
6052
|
-
const
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
return
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
}
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
return {
|
|
6064
|
-
modelName,
|
|
6065
|
-
data: [],
|
|
6066
|
-
fields: {},
|
|
6067
|
-
relations: {}
|
|
6068
|
-
};
|
|
6069
|
-
}
|
|
6070
|
-
const { data, error } = await supabase.from(tableName).select("*");
|
|
6071
|
-
if (error) {
|
|
6072
|
-
console.error(`Error loading ${modelName}:`, error);
|
|
6073
|
-
return {
|
|
6074
|
-
modelName,
|
|
6075
|
-
data: [],
|
|
6076
|
-
fields: {},
|
|
6077
|
-
relations: {}
|
|
6078
|
-
};
|
|
6079
|
-
}
|
|
6080
|
-
return {
|
|
6081
|
-
modelName,
|
|
6082
|
-
data: data || [],
|
|
6083
|
-
fields: {},
|
|
6084
|
-
relations: {}
|
|
6085
|
-
};
|
|
6086
|
-
});
|
|
6087
|
-
const results = await Promise.all(promises);
|
|
6088
|
-
const response = results.reduce(
|
|
6089
|
-
(acc, { modelName, data, fields, relations }) => {
|
|
6090
|
-
acc[modelName] = {
|
|
6091
|
-
data,
|
|
6092
|
-
fields,
|
|
6093
|
-
relations
|
|
6094
|
-
};
|
|
6095
|
-
return acc;
|
|
6096
|
-
},
|
|
6097
|
-
{}
|
|
6069
|
+
const results = await Promise.all(
|
|
6070
|
+
allModels.map(async (modelName) => {
|
|
6071
|
+
const tableName = MODEL_TO_TABLE[modelName];
|
|
6072
|
+
if (!tableName) return createModelResult(modelName);
|
|
6073
|
+
const { data, error } = await supabase.from(tableName).select("*");
|
|
6074
|
+
if (error) {
|
|
6075
|
+
console.error(`Error loading ${modelName}:`, error);
|
|
6076
|
+
return createModelResult(modelName);
|
|
6077
|
+
}
|
|
6078
|
+
return createModelResult(modelName, data || []);
|
|
6079
|
+
})
|
|
6098
6080
|
);
|
|
6099
|
-
return
|
|
6081
|
+
return results.reduce((acc, { modelName, ...rest }) => {
|
|
6082
|
+
acc[modelName] = rest;
|
|
6083
|
+
return acc;
|
|
6084
|
+
}, {});
|
|
6100
6085
|
} catch (error) {
|
|
6101
6086
|
console.error("Error loading data from Supabase:", error);
|
|
6102
6087
|
return {};
|
|
@@ -8975,6 +8960,95 @@ var useCompleteCurrentStage = () => {
|
|
|
8975
8960
|
};
|
|
8976
8961
|
var use_complete_current_stage_default = useCompleteCurrentStage;
|
|
8977
8962
|
|
|
8963
|
+
// src/hooks/pos/supabase/use-add-floor.ts
|
|
8964
|
+
import { useMutation as useMutation88 } from "@tanstack/react-query";
|
|
8965
|
+
|
|
8966
|
+
// src/services/pos-service/supabase/add-floor.ts
|
|
8967
|
+
import { useCallback as useCallback43 } from "react";
|
|
8968
|
+
var addFloorSupabaseService = () => {
|
|
8969
|
+
const supabase = useSupabaseOptional();
|
|
8970
|
+
const addFloorSupabase = useCallback43(
|
|
8971
|
+
async (values) => {
|
|
8972
|
+
if (!supabase) {
|
|
8973
|
+
console.error("Supabase client not initialized");
|
|
8974
|
+
return null;
|
|
8975
|
+
}
|
|
8976
|
+
try {
|
|
8977
|
+
const { data, error } = await supabase.from("restaurant_floors" /* RESTAURANT_FLOORS */).insert({
|
|
8978
|
+
name: values.name,
|
|
8979
|
+
sequence: values.sequence ?? 1,
|
|
8980
|
+
pos_config_ids: values.pos_config_ids ?? [],
|
|
8981
|
+
table_ids: values.table_ids ?? []
|
|
8982
|
+
}).select("id, name").single();
|
|
8983
|
+
if (error) {
|
|
8984
|
+
console.error("Error adding floor:", error);
|
|
8985
|
+
return null;
|
|
8986
|
+
}
|
|
8987
|
+
return [[data.id, data.name]];
|
|
8988
|
+
} catch (error) {
|
|
8989
|
+
console.error("Error adding floor:", error);
|
|
8990
|
+
return null;
|
|
8991
|
+
}
|
|
8992
|
+
},
|
|
8993
|
+
[supabase]
|
|
8994
|
+
);
|
|
8995
|
+
return {
|
|
8996
|
+
addFloorSupabase
|
|
8997
|
+
};
|
|
8998
|
+
};
|
|
8999
|
+
|
|
9000
|
+
// src/services/pos-service/supabase/add-table.ts
|
|
9001
|
+
import { useCallback as useCallback44 } from "react";
|
|
9002
|
+
var addTableSupabaseService = () => {
|
|
9003
|
+
const supabase = useSupabaseOptional();
|
|
9004
|
+
const addTableSupabase = useCallback44(
|
|
9005
|
+
async (values) => {
|
|
9006
|
+
if (!supabase) {
|
|
9007
|
+
console.error("Supabase client not initialized");
|
|
9008
|
+
return null;
|
|
9009
|
+
}
|
|
9010
|
+
try {
|
|
9011
|
+
const { data, error } = await supabase.from("restaurant_tables" /* RESTAURANT_TABLES */).insert({
|
|
9012
|
+
floor_id: values.floor_id,
|
|
9013
|
+
table_number: values.table_number ?? 0,
|
|
9014
|
+
seats: values.seats ?? 1
|
|
9015
|
+
}).select("id, table_number").single();
|
|
9016
|
+
if (error) {
|
|
9017
|
+
console.error("Error adding table:", error);
|
|
9018
|
+
return null;
|
|
9019
|
+
}
|
|
9020
|
+
return [[data.id, data.table_number]];
|
|
9021
|
+
} catch (error) {
|
|
9022
|
+
console.error("Error adding table:", error);
|
|
9023
|
+
return null;
|
|
9024
|
+
}
|
|
9025
|
+
},
|
|
9026
|
+
[supabase]
|
|
9027
|
+
);
|
|
9028
|
+
return {
|
|
9029
|
+
addTableSupabase
|
|
9030
|
+
};
|
|
9031
|
+
};
|
|
9032
|
+
|
|
9033
|
+
// src/hooks/pos/supabase/use-add-floor.ts
|
|
9034
|
+
var useAddFloor = () => {
|
|
9035
|
+
const { addFloorSupabase } = addFloorSupabaseService();
|
|
9036
|
+
return useMutation88({
|
|
9037
|
+
mutationFn: addFloorSupabase
|
|
9038
|
+
});
|
|
9039
|
+
};
|
|
9040
|
+
var use_add_floor_default = useAddFloor;
|
|
9041
|
+
|
|
9042
|
+
// src/hooks/pos/supabase/use-add-table.ts
|
|
9043
|
+
import { useMutation as useMutation89 } from "@tanstack/react-query";
|
|
9044
|
+
var useAddTable = () => {
|
|
9045
|
+
const { addTableSupabase } = addTableSupabaseService();
|
|
9046
|
+
return useMutation89({
|
|
9047
|
+
mutationFn: addTableSupabase
|
|
9048
|
+
});
|
|
9049
|
+
};
|
|
9050
|
+
var use_add_table_default = useAddTable;
|
|
9051
|
+
|
|
8978
9052
|
// src/provider/service-provider.tsx
|
|
8979
9053
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
8980
9054
|
var ServiceContext = createContext3(null);
|
|
@@ -9095,7 +9169,9 @@ var ServiceProvider = ({
|
|
|
9095
9169
|
useGetCountry: use_get_country_default,
|
|
9096
9170
|
useGetPartnerTitle: use_get_partner_title_default,
|
|
9097
9171
|
useCompleteCurrentStage: use_complete_current_stage_default,
|
|
9098
|
-
useLoginSupa: use_login_supa_default
|
|
9172
|
+
useLoginSupa: use_login_supa_default,
|
|
9173
|
+
useAddFloor: use_add_floor_default,
|
|
9174
|
+
useAddTable: use_add_table_default
|
|
9099
9175
|
};
|
|
9100
9176
|
return /* @__PURE__ */ jsx7(ServiceContext.Provider, { value: services, children });
|
|
9101
9177
|
};
|
package/dist/services.d.mts
CHANGED
|
@@ -391,12 +391,14 @@ declare function useDashboardService(): {
|
|
|
391
391
|
};
|
|
392
392
|
|
|
393
393
|
declare const serviceFactories: readonly [(env: any) => {
|
|
394
|
-
addEntity: ({ model, values, xNode, service, isCreateEndpoint, }: {
|
|
394
|
+
addEntity: ({ model, values, xNode, service, isCreateEndpoint, isSupa, supaCallback, }: {
|
|
395
395
|
model: string;
|
|
396
396
|
values: any;
|
|
397
397
|
service?: string;
|
|
398
398
|
xNode?: string;
|
|
399
399
|
isCreateEndpoint?: boolean;
|
|
400
|
+
isSupa?: boolean;
|
|
401
|
+
supaCallback?: (values: any) => Promise<any>;
|
|
400
402
|
}) => any;
|
|
401
403
|
}, (env: any) => {
|
|
402
404
|
getASession: ({ model, args, domain, service, xNode, }: {
|
|
@@ -431,11 +433,13 @@ declare const serviceFactories: readonly [(env: any) => {
|
|
|
431
433
|
withContext?: any;
|
|
432
434
|
}) => Promise<any>;
|
|
433
435
|
}, (env: any) => {
|
|
434
|
-
createEntity: ({ model, args, xNode, service, }: {
|
|
436
|
+
createEntity: ({ model, args, xNode, service, isSupa, supaCallback, }: {
|
|
435
437
|
model: string;
|
|
436
438
|
args: any;
|
|
437
439
|
service?: string;
|
|
438
440
|
xNode?: string;
|
|
441
|
+
isSupa?: boolean;
|
|
442
|
+
supaCallback?: (args: any) => Promise<any>;
|
|
439
443
|
}) => any;
|
|
440
444
|
}, (env: any) => {
|
|
441
445
|
createPosConfig: ({ model, name, modulePosRestaurant, xNode, service, }: {
|
package/dist/services.d.ts
CHANGED
|
@@ -391,12 +391,14 @@ declare function useDashboardService(): {
|
|
|
391
391
|
};
|
|
392
392
|
|
|
393
393
|
declare const serviceFactories: readonly [(env: any) => {
|
|
394
|
-
addEntity: ({ model, values, xNode, service, isCreateEndpoint, }: {
|
|
394
|
+
addEntity: ({ model, values, xNode, service, isCreateEndpoint, isSupa, supaCallback, }: {
|
|
395
395
|
model: string;
|
|
396
396
|
values: any;
|
|
397
397
|
service?: string;
|
|
398
398
|
xNode?: string;
|
|
399
399
|
isCreateEndpoint?: boolean;
|
|
400
|
+
isSupa?: boolean;
|
|
401
|
+
supaCallback?: (values: any) => Promise<any>;
|
|
400
402
|
}) => any;
|
|
401
403
|
}, (env: any) => {
|
|
402
404
|
getASession: ({ model, args, domain, service, xNode, }: {
|
|
@@ -431,11 +433,13 @@ declare const serviceFactories: readonly [(env: any) => {
|
|
|
431
433
|
withContext?: any;
|
|
432
434
|
}) => Promise<any>;
|
|
433
435
|
}, (env: any) => {
|
|
434
|
-
createEntity: ({ model, args, xNode, service, }: {
|
|
436
|
+
createEntity: ({ model, args, xNode, service, isSupa, supaCallback, }: {
|
|
435
437
|
model: string;
|
|
436
438
|
args: any;
|
|
437
439
|
service?: string;
|
|
438
440
|
xNode?: string;
|
|
441
|
+
isSupa?: boolean;
|
|
442
|
+
supaCallback?: (args: any) => Promise<any>;
|
|
439
443
|
}) => any;
|
|
440
444
|
}, (env: any) => {
|
|
441
445
|
createPosConfig: ({ model, name, modulePosRestaurant, xNode, service, }: {
|