create topping and material page
This commit is contained in:
parent
4ca8b3b270
commit
bd239cf71b
9 changed files with 2606 additions and 57 deletions
|
|
@ -395,59 +395,59 @@ const handlers: Record<string, (payload: any) => void> = {
|
|||
|
||||
lastRequestSheetPrice.set(lastRequestPriceInstance);
|
||||
},
|
||||
raw_stream: (p) => {
|
||||
let streamRawInstance = get(streamingRawData);
|
||||
let sub_type = p.sub_type;
|
||||
let request_id = p.request_id;
|
||||
let size_per_chunk = p.size_per_chunk;
|
||||
let total_chunks = p.total_chunks;
|
||||
let idx = p.idx;
|
||||
// raw_stream: (p) => {
|
||||
// let streamRawInstance = get(streamingRawData);
|
||||
// let sub_type = p.sub_type;
|
||||
// let request_id = p.request_id;
|
||||
// let size_per_chunk = p.size_per_chunk;
|
||||
// let total_chunks = p.total_chunks;
|
||||
// let idx = p.idx;
|
||||
|
||||
switch (sub_type) {
|
||||
case 'price':
|
||||
streamingRawMeta.set({
|
||||
id: request_id,
|
||||
total_size: total_chunks,
|
||||
chunk_size: size_per_chunk,
|
||||
progress: 0
|
||||
});
|
||||
break;
|
||||
case 'chunk_price':
|
||||
streamingRawMeta.set({
|
||||
id: request_id,
|
||||
total_size: total_chunks,
|
||||
chunk_size: size_per_chunk,
|
||||
progress: idx
|
||||
});
|
||||
// switch (sub_type) {
|
||||
// case 'price':
|
||||
// streamingRawMeta.set({
|
||||
// id: request_id,
|
||||
// total_size: total_chunks,
|
||||
// chunk_size: size_per_chunk,
|
||||
// progress: 0
|
||||
// });
|
||||
// break;
|
||||
// case 'chunk_price':
|
||||
// streamingRawMeta.set({
|
||||
// id: request_id,
|
||||
// total_size: total_chunks,
|
||||
// chunk_size: size_per_chunk,
|
||||
// progress: idx
|
||||
// });
|
||||
|
||||
let raw_payload = p.raw ?? '';
|
||||
streamRawInstance[request_id] += raw_payload;
|
||||
streamingRawData.set(streamRawInstance);
|
||||
// let raw_payload = p.raw ?? '';
|
||||
// streamRawInstance[request_id] += raw_payload;
|
||||
// streamingRawData.set(streamRawInstance);
|
||||
|
||||
break;
|
||||
case 'end_price':
|
||||
let lastRequestPriceInstance = get(lastRequestSheetPrice);
|
||||
let country = lastRequestPriceInstance[request_id];
|
||||
// break;
|
||||
// case 'end_price':
|
||||
// let lastRequestPriceInstance = get(lastRequestSheetPrice);
|
||||
// let country = lastRequestPriceInstance[request_id];
|
||||
|
||||
try {
|
||||
let raw_payload = JSON.parse(streamRawInstance[request_id]);
|
||||
let ref_from_raw = raw_payload.payload.ref ?? '';
|
||||
let from_service_raw = raw_payload.payload.from ?? '';
|
||||
let parsed_payload = raw_payload.payload ?? '';
|
||||
// try {
|
||||
// let raw_payload = JSON.parse(streamRawInstance[request_id]);
|
||||
// let ref_from_raw = raw_payload.payload.ref ?? '';
|
||||
// let from_service_raw = raw_payload.payload.from ?? '';
|
||||
// let parsed_payload = raw_payload.payload ?? '';
|
||||
|
||||
if (from_service_raw == 'sheet-service') {
|
||||
handleSheetResponseFromNoti(parsed_payload, ref_from_raw, country);
|
||||
delete streamRawInstance[request_id];
|
||||
streamingRawData.set(streamRawInstance);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(`end price process error: ${e}`);
|
||||
}
|
||||
// if (from_service_raw == 'sheet-service') {
|
||||
// handleSheetResponseFromNoti(parsed_payload, ref_from_raw, country);
|
||||
// delete streamRawInstance[request_id];
|
||||
// streamingRawData.set(streamRawInstance);
|
||||
// }
|
||||
// } catch (e) {
|
||||
// console.log(`end price process error: ${e}`);
|
||||
// }
|
||||
|
||||
break;
|
||||
default:
|
||||
}
|
||||
},
|
||||
// break;
|
||||
// default:
|
||||
// }
|
||||
// },
|
||||
heartbeat: (p) => {
|
||||
socketConnectionOfflineCount.set(0);
|
||||
socketAlreadySendHeartbeat.set(0);
|
||||
|
|
@ -486,12 +486,12 @@ export function handleIncomingMessages(raw: string) {
|
|||
}
|
||||
|
||||
// raw streaming type
|
||||
if (msg.type.startsWith('raw_stream')) {
|
||||
// convert
|
||||
let sub_type = msg.type.replace('raw_stream_', '');
|
||||
msg.payload.sub_type = sub_type;
|
||||
msg.type = 'raw_stream';
|
||||
}
|
||||
// if (msg.type.startsWith('raw_stream')) {
|
||||
// // convert
|
||||
// let sub_type = msg.type.replace('raw_stream_', '');
|
||||
// msg.payload.sub_type = sub_type;
|
||||
// msg.type = 'raw_stream';
|
||||
// }
|
||||
|
||||
handlers[msg.type]?.(msg.payload);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,29 @@ export function requestCatalogs(country: string): boolean {
|
|||
});
|
||||
}
|
||||
|
||||
export function requestPriceSlots(country: string): boolean {
|
||||
return sendCommandRequest('sheet', {
|
||||
country: country,
|
||||
param: 'priceslot'
|
||||
});
|
||||
}
|
||||
|
||||
export function updatePriceSlot(
|
||||
country: string,
|
||||
content: {
|
||||
slot: number;
|
||||
name: string;
|
||||
description: string;
|
||||
products: { product_code: string; price: number | null; row_index?: number }[];
|
||||
}
|
||||
): boolean {
|
||||
return sendCommandRequest('sheet', {
|
||||
country: country,
|
||||
content: content,
|
||||
param: 'update/priceslot'
|
||||
});
|
||||
}
|
||||
|
||||
export function enterRoom(country: string, catalog: string): boolean {
|
||||
return sendCommandRequest('sheet', {
|
||||
country: country,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,24 @@ export interface CatalogsResponse {
|
|||
export const sheetCatalogs = writable<Catalog[]>([]);
|
||||
export const sheetCatalogsLoading = writable<boolean>(false);
|
||||
|
||||
export interface PriceSlotProduct {
|
||||
product_code: string;
|
||||
name: string;
|
||||
price: number | null;
|
||||
row_index?: number;
|
||||
}
|
||||
|
||||
export interface PriceSlot {
|
||||
slot: number;
|
||||
name: string;
|
||||
description: string;
|
||||
products: PriceSlotProduct[];
|
||||
}
|
||||
|
||||
export const priceSlots = writable<Record<string, PriceSlot[]>>({});
|
||||
export const priceSlotsLoading = writable<boolean>(false);
|
||||
export const priceSlotsError = writable<string | null>(null);
|
||||
|
||||
export const countryPrimaryLanguageMap: Record<string, string> = {
|
||||
THAI: 'Thai',
|
||||
tha: 'Thai',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue