@duely/client
Advanced tools
Comparing version 0.0.27 to 0.0.28
@@ -7,3 +7,3 @@ "use strict"; | ||
exports.query = query; | ||
exports.agency_services_Q = exports.subdomain_public_Q = exports.current_user_agencies_Q = exports.agency_stripe_account_update_url_Q = exports.services_agreement_Q = exports.country_codes_Q = exports.current_user_Q = void 0; | ||
exports.agency_services_Q = exports.current_subdomain_Q = exports.subdomain_public_Q = exports.current_user_agencies_Q = exports.agency_stripe_account_update_url_Q = exports.services_agreement_Q = exports.country_codes_Q = exports.current_user_Q = void 0; | ||
@@ -201,2 +201,35 @@ var _client = require("@apollo/client"); | ||
exports.subdomain_public_Q = subdomain_public_Q; | ||
var current_subdomain_Q = _objectSpread(_objectSpread({}, subdomain_public_Q), {}, { | ||
variables: { | ||
subdomain_name: resolveSubdomain() | ||
} | ||
}); | ||
exports.current_subdomain_Q = current_subdomain_Q; | ||
function resolveSubdomain() { | ||
var domain = window.location.hostname.toLowerCase(); | ||
var subdomain = null; | ||
if (process.env.NODE_ENV === 'production') { | ||
if (domain !== 'duely.app') { | ||
if (domain.endsWith('.duely.app')) { | ||
subdomain = domain.slice(0, -'.duely.app'.length); | ||
} else { | ||
// TODO: check from database | ||
throw new Error('Not implemented.'); | ||
} | ||
} | ||
} else { | ||
var _name$toLowerCase; | ||
var url = new URL(window.location.href); | ||
var name = url.searchParams.get('subdomain'); | ||
subdomain = (_name$toLowerCase = name === null || name === void 0 ? void 0 : name.toLowerCase()) !== null && _name$toLowerCase !== void 0 ? _name$toLowerCase : 'test'; | ||
} | ||
return subdomain; | ||
} | ||
var agency_services_Q = { | ||
@@ -203,0 +236,0 @@ query: (0, _client.gql)(_templateObject7()), |
{ | ||
"name": "@duely/client", | ||
"type": "module", | ||
"version": "0.0.27", | ||
"version": "0.0.28", | ||
"repository": "github:uoleevi/duely", | ||
@@ -6,0 +6,0 @@ "description": "GraphQL client by Duely (wrapper for @apollo/client)", |
@@ -180,2 +180,31 @@ import { gql } from '@apollo/client'; | ||
export const current_subdomain_Q = { | ||
...subdomain_public_Q, | ||
variables: { | ||
subdomain_name: resolveSubdomain() | ||
} | ||
} | ||
function resolveSubdomain() { | ||
const domain = window.location.hostname.toLowerCase(); | ||
let subdomain = null; | ||
if (process.env.NODE_ENV === 'production') { | ||
if (domain !== 'duely.app') { | ||
if (domain.endsWith('.duely.app')) { | ||
subdomain = domain.slice(0, -'.duely.app'.length); | ||
} else { | ||
// TODO: check from database | ||
throw new Error('Not implemented.'); | ||
} | ||
} | ||
} else { | ||
const url = new URL(window.location.href); | ||
let name = url.searchParams.get('subdomain'); | ||
subdomain = name?.toLowerCase() ?? 'test'; | ||
} | ||
return subdomain; | ||
} | ||
export const agency_services_Q = { | ||
@@ -182,0 +211,0 @@ query: gql` |
Sorry, the diff of this file is not supported yet
138808
2532
8