141 lines
4.1 KiB
JavaScript
141 lines
4.1 KiB
JavaScript
const RetailApiurl = import.meta.env.ENV_API_URL;
|
|
|
|
const MobileMultiPdfPrintTrigger = async ({
|
|
preferenceDetails,
|
|
printDatas,
|
|
PrintOrderDetails,
|
|
PrinterDetails,
|
|
SessionData,
|
|
bookingTypePreference,
|
|
}) => {
|
|
const BranchId = SessionData?.BranchId;
|
|
const AppId = SessionData?.AppId;
|
|
const CompId = SessionData?.CompId;
|
|
const UserId = SessionData?.UserId;
|
|
const UserType = SessionData?.UserType;
|
|
const AuthToken = SessionData?.AuthToken;
|
|
const SessionMobileNo = SessionData?.SessionMobileNo;
|
|
const TokenOnly = preferenceDetails?.filter(
|
|
(i) => i.SettingIdName?.toLowerCase() === 'tokenonly'
|
|
)?.[0];
|
|
const takeAwayPreference = bookingTypePreference?.some(
|
|
(type) =>
|
|
type?.PreferredSubCatName?.toLowerCase() === 'take away' &&
|
|
type?.PreferredStatus === 'Y'
|
|
);
|
|
|
|
const IndividualToken = preferenceDetails?.filter(
|
|
(i) => i.SettingIdName?.toLowerCase() === 'allproductindividualtoken'
|
|
)?.[0];
|
|
const PrintLogo = preferenceDetails?.filter(
|
|
(i) => i.SettingIdName?.toLowerCase() === 'printlogo'
|
|
)?.[0];
|
|
const PrintGreeting = preferenceDetails?.filter(
|
|
(i) => i.SettingIdName?.toLowerCase() === 'printgreetings'
|
|
)?.[0];
|
|
const EstimateHeader = preferenceDetails?.filter(
|
|
(i) => i.SettingIdName?.toLowerCase() === 'estimateprintheader'
|
|
)?.[0];
|
|
const weightasquantity = preferenceDetails?.filter(
|
|
(i) => i.SettingIdName?.toLowerCase() === 'weightasquantity'
|
|
)?.[0];
|
|
const SalesMode = preferenceDetails?.filter(
|
|
(i) => i.SettingIdName?.toLowerCase() === 'sales mode'
|
|
)?.[0];
|
|
const Tokenthere = TokenOnly?.SettingValue === 'Y';
|
|
const Individual = IndividualToken?.SettingValue === 'Y';
|
|
const PrintGrettingthere = PrintGreeting?.SettingValue === 'Y';
|
|
const Printlogothere = PrintLogo?.SettingValue === 'Y';
|
|
const EstimateHeaderthere = EstimateHeader?.SettingValue === 'Y';
|
|
const SalesModethere = SalesMode?.SettingValue === 'Y';
|
|
const weightasquantitythere = weightasquantity?.SettingValue === 'Y';
|
|
const orderidlist = PrintOrderDetails?.[0]?.OrderDetails?.map((item) => ({
|
|
OrderId: item.OrderId,
|
|
}));
|
|
const filesJson = JSON.stringify(PrinterDetails);
|
|
console.log(PrinterDetails, 'PrinterDetails');
|
|
const Stylename = printDatas?.StyleName ? printDatas?.StyleName : 'Style 1';
|
|
const PrintSize = printDatas?.PageSize ? printDatas?.PageSize : '3inch';
|
|
const isCreditDetailsAvailable = printDatas?.FieldDetails?.some(
|
|
(item) => String(item?.ConfigName || '').toLowerCase() === 'credit details'
|
|
);
|
|
console.log(printDatas, 'printDatasprintDatas');
|
|
var receiptText = '';
|
|
var textEncoded = encodeURI(receiptText);
|
|
var scheme = 'pozoprinter';
|
|
var packageName = 'com.example.pozoprinter';
|
|
window.location.href =
|
|
scheme +
|
|
'://' +
|
|
textEncoded +
|
|
'#Intent;scheme=' +
|
|
scheme +
|
|
';package=' +
|
|
packageName +
|
|
'AppIdS' +
|
|
AppId +
|
|
'AppIdE' +
|
|
'CompIdS' +
|
|
CompId +
|
|
'CompIdE' +
|
|
'BranchIdS' +
|
|
BranchId +
|
|
'BranchIdE' +
|
|
'UserIdS' +
|
|
UserId +
|
|
'UserIdE' +
|
|
'ApiClientS' +
|
|
RetailApiurl +
|
|
'ApiClientE' +
|
|
'InvoiceOrderIdS' +
|
|
JSON.stringify(orderidlist) +
|
|
'InvoiceOrderIdE' +
|
|
'MobileNoS' +
|
|
SessionMobileNo +
|
|
'MobileNoE' +
|
|
'AuthTokenS' +
|
|
AuthToken +
|
|
'AuthTokenE' +
|
|
'PrintSizeS' +
|
|
PrintSize +
|
|
'PrintSizeE' +
|
|
'PrintTypeS' +
|
|
Stylename +
|
|
'PrintTypeE' +
|
|
'TokenOnlyS' +
|
|
Tokenthere +
|
|
'TokenOnlyE' +
|
|
'AllProductindividualTokenS' +
|
|
Individual +
|
|
'AllProductindividualTokenE' +
|
|
'PrintGreetingsS' +
|
|
PrintGrettingthere +
|
|
'PrintGreetingsE' +
|
|
'PrintLogoS' +
|
|
Printlogothere +
|
|
'PrintLogoE' +
|
|
'CustomerCreditPrintS' +
|
|
isCreditDetailsAvailable +
|
|
'CustomerCreditPrintE' +
|
|
'EstimatePrintHeaderS' +
|
|
EstimateHeaderthere +
|
|
'EstimatePrintHeaderE' +
|
|
'SalesModeS' +
|
|
SalesModethere +
|
|
'SalesModeE' +
|
|
'TakeAwayPreferenceS' +
|
|
takeAwayPreference +
|
|
'TakeAwayPreferenceE' +
|
|
'WeightasquantityS' +
|
|
weightasquantitythere +
|
|
'WeightasquantityE' +
|
|
'IpS' +
|
|
filesJson +
|
|
'IpE' +
|
|
'ConfigurationS' +
|
|
true +
|
|
'ConfigurationE' +
|
|
';end;';
|
|
};
|
|
export default MobileMultiPdfPrintTrigger;
|