-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kial Jinnah <kialj876@gmail.com>
- Loading branch information
Showing
20 changed files
with
423 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// following docs: https://nuxt.com/docs/guide/recipes/custom-usefetch | ||
export function useBcrosFetch<T>(url: string, options: any) { | ||
return useFetch<T>(url, { | ||
...options, | ||
watch: false, | ||
$fetch: useNuxtApp().$bcrosFetch | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,54 @@ | ||
// FUTURE: add in full list | ||
export enum BusinessTypeModernizedE { | ||
COOPERATIVE_ASSOCIATION = 'CP', | ||
BENEFIT_COMPANY = 'BEN', | ||
GENERAL_PARTNERSHIP = 'GP', | ||
SOLE_PROPRIETOR = 'SP' | ||
} | ||
|
||
export enum BusinessTypeE { | ||
// Corporations | ||
BC = 'BC', | ||
BEN = 'BEN', | ||
CCC = 'CCC', | ||
ULC = 'ULC', | ||
// Firms | ||
GP = 'GP', | ||
SP = 'SP', | ||
// Other | ||
CP = 'CP', | ||
EXTRA_PRO_A = 'A', | ||
EXTRA_PRO_B = 'B', | ||
BC_COMPANY = 'BC', | ||
BENEFIT_COMPANY = 'BEN', | ||
CONTINUE_IN = 'C', | ||
BC_CCC = 'CC', | ||
CEMETARY = 'CEM', | ||
COOP = 'CP', | ||
CONT_IN_SOCIETY = 'CS', | ||
ULC_CONTINUE_IN = 'CUL', | ||
EXTRA_PRO_REG = 'EPR', | ||
FINANCIAL = 'FI', | ||
FOREIGN = 'FOR', | ||
PARTNERSHIP = 'GP', | ||
LIBRARY = 'LIB', | ||
LICENSED = 'LIC', | ||
LL_PARTNERSHIP = 'LL', | ||
LIMITED_CO = 'LLC', | ||
LIM_PARTNERSHIP = 'LP', | ||
MISC_FIRM = 'MF', | ||
PRIVATE_ACT = 'PA', | ||
PARISHES = 'PAR', | ||
PENSION_FUND_SOCIETY = 'PFS', | ||
CO_1860 = 'QA', | ||
CO_1862 = 'QB', | ||
CO_1878 = 'QC', | ||
CO_1890 = 'QD', | ||
CO_1897 = 'QE', | ||
REGISTRATION = 'REG', | ||
RAILWAYS = 'RLY', | ||
SOCIETY = 'S', | ||
SOCIETY_BRANCH = 'SB', | ||
SOLE_PROP = 'SP', | ||
TRUST = 'T', | ||
TRAMWAYS = 'TMY', | ||
BC_ULC_COMPANY = 'ULC', | ||
ULC_CO_1860 = 'UQA', | ||
ULC_CO_1862 = 'UQB', | ||
ULC_CO_1878 = 'UQC', | ||
ULC_CO_1890 = 'UQD', | ||
ULC_CO_1897 = 'UQE', | ||
XPRO_COOP= 'XCP', | ||
XPRO_LL_PARTNR = 'XL', | ||
XPRO_LIM_PARTNR = 'XP', | ||
XPRO_SOCIETY = 'XS' | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// custom fetch docs: https://nuxt.com/docs/guide/recipes/custom-usefetch | ||
|
||
const addHeader = (headers: HeadersInit, key: string, value: string) => { | ||
if (Array.isArray(headers)) { | ||
headers.push([key, value]) | ||
} else if (headers instanceof Headers) { | ||
headers.set(key, value) | ||
} else { | ||
headers[key] = value | ||
} | ||
} | ||
|
||
const headerExists = (headers: HeadersInit, key: string) => { | ||
if (Array.isArray(headers)) { | ||
return !!headers.find(val => val[0] === key) | ||
} | ||
return Object.keys(headers).includes(key) | ||
} | ||
|
||
export default defineNuxtPlugin(() => { | ||
const bcrosFetch = $fetch.create({ | ||
onRequest({ options }) { | ||
const headers = options.headers ||= {} | ||
|
||
if (!headerExists(headers, 'Authorization') && useBcrosKeycloak().kc?.token) { | ||
addHeader(headers, 'Authorization', `Bearer ${useBcrosKeycloak().kc.token}`) | ||
} | ||
|
||
if (!headerExists(headers, 'Account-Id') && useBcrosAccount().currentAccount?.id) { | ||
addHeader(headers, 'Account-Id', (useBcrosAccount().currentAccount.id).toString()) | ||
} | ||
|
||
if (!headerExists(headers, 'Accept')) { | ||
addHeader(headers, 'Accept', 'application/json') | ||
} | ||
} | ||
}) | ||
|
||
// Expose to useNuxtApp().$bcrosFetch | ||
return { | ||
provide: { | ||
bcrosFetch | ||
} | ||
} | ||
}) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.