Skip to content

Commit

Permalink
Fix Environment
Browse files Browse the repository at this point in the history
  • Loading branch information
deathcave committed Dec 3, 2024
1 parent 1afafaf commit d489801
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ const combineEmailPhone = {
true: 'true',
false: 'false',
};

const environment = {
Production: 'prod',
Stage: 'stage',
};
const onChange = (event: CustomEvent) => {
console.log(event.detail);
};
Expand All @@ -115,6 +120,7 @@ const props = () => {
'false'
),
combineEmailPhone: select('Combine Email Phone', combineEmailPhone, 'true'),
environment: select('Environment', environment, 'prod'),
};
};

Expand All @@ -132,6 +138,7 @@ export const Default = (args) => {
ncTeleDetail,
ncEmailDetail,
combineEmailPhone,
environment,
} = args?.NoticeChoice ?? {};
return html`
<c4d-notice-choice
Expand All @@ -147,6 +154,7 @@ export const Default = (args) => {
.nc-tele-detail="${ncTeleDetail}"
.nc-email-detail="${ncEmailDetail}"
combine-email-phone="${combineEmailPhone}"
environment="${environment}"
@c4d-notice-choice-change=${onChange}></c4d-notice-choice>
`;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ class NoticeChoice extends StableSelectorMixin(LitElement) {
@property({ type: Boolean, attribute: 'combine-email-phone' })
combineEmailPhone = false;

@property({ type: String, attribute: 'environment' })
environment = 'prod';

@property({ type: Object, attribute: false })
checkboxes = {};

Expand Down Expand Up @@ -153,6 +156,7 @@ class NoticeChoice extends StableSelectorMixin(LitElement) {
defaultLoadContent() {
loadContent(
'en',
this.environment,
(ncData) => {
this.ncData = ncData;
this.prepareCheckboxes();
Expand Down Expand Up @@ -194,6 +198,7 @@ class NoticeChoice extends StableSelectorMixin(LitElement) {
);
loadContent(
defaultLanguage,
this.environment,
(ncData) => {
this.ncData = ncData;
this.prepareCheckboxes();
Expand Down Expand Up @@ -297,7 +302,8 @@ class NoticeChoice extends StableSelectorMixin(LitElement) {
}
break;
}
case 'language': {
case 'language':
case 'environment': {
// load content when locale changed.
const [language] = newVal.split(/[-_]/);

Expand All @@ -311,6 +317,7 @@ class NoticeChoice extends StableSelectorMixin(LitElement) {
if (hasValue && oldVal !== newVal) {
loadContent(
defaultLanguage,
this.environment,
(ncData) => {
this.ncData = ncData;
this.prepareCheckboxes();
Expand Down
11 changes: 9 additions & 2 deletions packages/web-components/src/components/notice-choice/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@
* LICENSE file in the root directory of this source tree.
*/

export function loadContent(locale: string, onSuccess: any, onError: any) {
export function loadContent(
locale: string,
env: string,
onSuccess: any,
onError: any
) {
const script = document.createElement('script');
const environment = env === 'prod' ? '1.www.s81c.com' : '1.wwwstage.s81c.com';
console.log(environment, 'env', env);
script.async = false;
script.charset = 'utf-8';
script.src = `https://1.wwwstage.s81c.com/common/translations/notice/v23/${locale.toLocaleLowerCase()}/ncContent_v23.js`; // URL for the third-party library being loaded.
script.src = `https://${environment}/common/translations/notice/v23/${locale.toLocaleLowerCase()}/ncContent_v23.js`; // URL for the third-party library being loaded.
document.body.appendChild(script);
script.onload = () => {
try {
Expand Down

0 comments on commit d489801

Please sign in to comment.