Inject JS in templates with correct domains
Signed-off-by: Egor Savkin <es@m-labs.hk>
This commit is contained in:
parent
7c06c58e62
commit
33c7936e72
File diff suppressed because one or more lines are too long
|
@ -1,8 +1,8 @@
|
|||
import React from "react";
|
||||
import {DEFAULT_DOMAIN, INTL_DOMAIN, USE_INTL_DOMAIN} from "./utils";
|
||||
import {DOMAIN} from "./utils";
|
||||
|
||||
|
||||
export function DomainedEmail({address}) {
|
||||
const target = `${address}@${USE_INTL_DOMAIN ? INTL_DOMAIN : DEFAULT_DOMAIN}`;
|
||||
const target = `${address}@${DOMAIN}`;
|
||||
return <a href={"mailto:" + target}>{target}</a>
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
import {createWithEqualityFn} from "zustand/traditional";
|
||||
import {data as shared_data, itemsUnfoldedList, USE_INTL_DOMAIN} from "./utils";
|
||||
import {DATA as shared_data, itemsUnfoldedList, API_RFQ} from "./utils";
|
||||
import {FillExtCrateData, FillExtOrderData, true_type_of} from "./options/utils";
|
||||
import {v4 as uuidv4} from "uuid";
|
||||
import {FillResources} from "./count_resources";
|
||||
|
@ -229,7 +229,7 @@ const useSubmitForm = ((set, get) => ({
|
|||
status: Validation.OK,
|
||||
message: ""
|
||||
},
|
||||
API_RFQ: USE_INTL_DOMAIN ? shared_data.INTL_API_RFQ : shared_data.API_RFQ,
|
||||
API_RFQ: API_RFQ,
|
||||
email: {
|
||||
value: "",
|
||||
error: null
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
export const data = window.shop_data;
|
||||
export const itemsUnfoldedList = Array.from(data.columns.catalog.categories.map(groupId => groupId.itemIds).flat());
|
||||
export const DATA = window.shop_data;
|
||||
export const DOMAIN = window.DOMAIN;
|
||||
export const API_RFQ = window.API_RFQ;
|
||||
export const itemsUnfoldedList = Array.from(DATA.columns.catalog.categories.map(groupId => groupId.itemIds).flat());
|
||||
|
||||
export const productStyle = (style, snapshot, removeAnim, hovered, selected, cart=false) => {
|
||||
const custom = {
|
||||
|
@ -92,12 +94,3 @@ export function compareObjectsEmptiness(a, b) {
|
|||
return (!a && !b) || (!(!a !== !b) && Object.getPrototypeOf(a) === Object.getPrototypeOf(b) &&
|
||||
(Object.getPrototypeOf(a) !== Object.getPrototypeOf([]) || !!Object.keys(a).length === !!Object.keys(b).length))
|
||||
}
|
||||
|
||||
export const INTL_DOMAIN = "m-labs-intl.com";
|
||||
export const DEFAULT_DOMAIN = "m-labs.hk";
|
||||
|
||||
// #!if intl_domain
|
||||
export const USE_INTL_DOMAIN = true;
|
||||
// #!else
|
||||
export const USE_INTL_DOMAIN = window.location.hostname === INTL_DOMAIN;
|
||||
// #!endif
|
|
@ -1,7 +1,4 @@
|
|||
const shop_data = {
|
||||
|
||||
API_RFQ: 'https://hooks.m-labs.hk/rfq',
|
||||
INTL_API_RFQ: 'https://m-labs-intl.com/api/rfq',
|
||||
currency: 'USD',
|
||||
|
||||
crateModes: {
|
||||
|
|
|
@ -46,6 +46,17 @@
|
|||
<!-- Load Data -->
|
||||
<script src="{{ get_url(path='js/shop_data.js', cachebust=true) }}"></script>
|
||||
|
||||
<script>
|
||||
{% if "m-labs-intl.com" == get_env(name="DOMAINNAME", default="m-labs.hk") %}
|
||||
|
||||
window.DOMAIN = 'm-labs-intl.com';
|
||||
window.API_RFQ = `https://${window.DOMAIN}/rfq`;
|
||||
{% else %}
|
||||
window.DOMAIN = 'm-labs.hk';
|
||||
window.API_RFQ = `https://hooks.${window.DOMAIN}/rfq`;
|
||||
{% endif %}
|
||||
</script>
|
||||
|
||||
<!-- Load our React component. -->
|
||||
<!-- <script type="text/babel" src="{{ get_url(path='js/shop.jsx', cachebust=true) }}"></script> -->
|
||||
<script src="{{ get_url(path='js/shop.bundle.js', cachebust=true) }}"></script>
|
||||
|
|
Loading…
Reference in New Issue