mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-20 14:54:15 +01:00
linted TS files
This commit is contained in:
parent
a6043fe81e
commit
54c933523d
@ -1,4 +1,6 @@
|
||||
import axios, { AxiosInstance } from 'axios'
|
||||
import axios, { AxiosInstance } from 'axios';
|
||||
|
||||
type Error = { error: string };
|
||||
|
||||
const token: HTMLMetaElement = document.querySelector('[name="csrf-token"]');
|
||||
const client: AxiosInstance = axios.create({
|
||||
@ -21,7 +23,7 @@ client.interceptors.response.use(function (response) {
|
||||
return Promise.reject(extractHumanReadableMessage(message));
|
||||
});
|
||||
|
||||
function extractHumanReadableMessage(error: any): string {
|
||||
function extractHumanReadableMessage (error: string|Error): string {
|
||||
if (typeof error === 'string') {
|
||||
if (error.match(/^<!DOCTYPE html>/)) {
|
||||
// parse ruby error pages
|
||||
@ -40,7 +42,7 @@ function extractHumanReadableMessage(error: any): string {
|
||||
let message = '';
|
||||
if (error instanceof Object) {
|
||||
// API errors
|
||||
if (error.hasOwnProperty('error') && typeof error.error === 'string') {
|
||||
if (Object.prototype.hasOwnProperty.call(error, 'error') && typeof error.error === 'string') {
|
||||
return error.error;
|
||||
}
|
||||
// iterate through all the keys to build the message
|
||||
|
@ -1,6 +1,6 @@
|
||||
import axios, { AxiosInstance } from 'axios'
|
||||
import axios, { AxiosInstance } from 'axios';
|
||||
|
||||
function client(key: string): AxiosInstance {
|
||||
function client (key: string): AxiosInstance {
|
||||
return axios.create({
|
||||
baseURL: 'https://api.stripe.com/v1/',
|
||||
headers: {
|
||||
@ -12,4 +12,3 @@ function client(key: string): AxiosInstance {
|
||||
}
|
||||
|
||||
export default client;
|
||||
|
||||
|
@ -8,4 +8,3 @@ export default class CustomAssetAPI {
|
||||
return res?.data?.custom_asset;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ import { EventTheme } from '../models/event-theme';
|
||||
|
||||
export default class EventThemeAPI {
|
||||
static async index (): Promise<Array<EventTheme>> {
|
||||
const res: AxiosResponse<Array<EventTheme>> = await apiClient.get(`/api/event_themes`);
|
||||
const res: AxiosResponse<Array<EventTheme>> = await apiClient.get('/api/event_themes');
|
||||
return res?.data;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
import stripeClient from '../clients/stripe-client';
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { ListCharges, PIIToken } from '../../models/stripe';
|
||||
|
||||
export default class StripeAPI {
|
||||
/**
|
||||
* @see https://stripe.com/docs/api/tokens/create_pii
|
||||
*/
|
||||
static async createPIIToken(key: string, piiId: string): Promise<any> {
|
||||
static async createPIIToken (key: string, piiId: string): Promise<PIIToken> {
|
||||
const params = new URLSearchParams();
|
||||
params.append('pii[id_number]', piiId);
|
||||
|
||||
@ -13,17 +14,17 @@ export default class StripeAPI {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const res: AxiosResponse = await stripeClient(key).post('tokens', params, config);
|
||||
const res: AxiosResponse<PIIToken> = await stripeClient(key).post('tokens', params, config);
|
||||
return res?.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://stripe.com/docs/api/charges/list
|
||||
*/
|
||||
static async listAllCharges(key: string): Promise<any> {
|
||||
const res: AxiosResponse = await stripeClient(key).get('charges');
|
||||
static async listAllCharges (key: string): Promise<ListCharges> {
|
||||
const res: AxiosResponse<ListCharges> = await stripeClient(key).get('charges');
|
||||
return res?.data;
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,9 @@ export default class GroupAPI {
|
||||
return res?.data;
|
||||
}
|
||||
|
||||
private static filtersToQuery(filters?: GroupIndexFilter): string {
|
||||
private static filtersToQuery (filters?: GroupIndexFilter): string {
|
||||
if (!filters) return '';
|
||||
|
||||
return '?' + Object.entries(filters).map(f => `${f[0]}=${f[1]}`).join('&');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,8 @@ import { PaymentSchedule } from '../models/payment-schedule';
|
||||
import { Invoice } from '../models/invoice';
|
||||
|
||||
export default class LocalPaymentAPI {
|
||||
static async confirmPayment (cart_items: ShoppingCart): Promise<PaymentSchedule|Invoice> {
|
||||
const res: AxiosResponse<PaymentSchedule|Invoice> = await apiClient.post('/api/local_payment/confirm_payment', cart_items);
|
||||
static async confirmPayment (cartItems: ShoppingCart): Promise<PaymentSchedule|Invoice> {
|
||||
const res: AxiosResponse<PaymentSchedule|Invoice> = await apiClient.post('/api/local_payment/confirm_payment', cartItems);
|
||||
return res?.data;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,10 +13,9 @@ export default class MachineAPI {
|
||||
return res?.data;
|
||||
}
|
||||
|
||||
private static filtersToQuery(filters?: MachineIndexFilter): string {
|
||||
private static filtersToQuery (filters?: MachineIndexFilter): string {
|
||||
if (!filters) return '';
|
||||
|
||||
return '?' + Object.entries(filters).map(f => `${f[0]}=${f[1]}`).join('&');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import {
|
||||
|
||||
export default class PaymentScheduleAPI {
|
||||
static async list (query: PaymentScheduleIndexRequest): Promise<Array<PaymentSchedule>> {
|
||||
const res: AxiosResponse = await apiClient.post(`/api/payment_schedules/list`, query);
|
||||
const res: AxiosResponse = await apiClient.post('/api/payment_schedules/list', query);
|
||||
return res?.data;
|
||||
}
|
||||
|
||||
@ -18,17 +18,17 @@ export default class PaymentScheduleAPI {
|
||||
return res?.data;
|
||||
}
|
||||
|
||||
static async cashCheck(paymentScheduleItemId: number): Promise<CashCheckResponse> {
|
||||
static async cashCheck (paymentScheduleItemId: number): Promise<CashCheckResponse> {
|
||||
const res: AxiosResponse = await apiClient.post(`/api/payment_schedules/items/${paymentScheduleItemId}/cash_check`);
|
||||
return res?.data;
|
||||
}
|
||||
|
||||
static async refreshItem(paymentScheduleItemId: number): Promise<RefreshItemResponse> {
|
||||
static async refreshItem (paymentScheduleItemId: number): Promise<RefreshItemResponse> {
|
||||
const res: AxiosResponse = await apiClient.post(`/api/payment_schedules/items/${paymentScheduleItemId}/refresh_item`);
|
||||
return res?.data;
|
||||
}
|
||||
|
||||
static async payItem(paymentScheduleItemId: number): Promise<PayItemResponse> {
|
||||
static async payItem (paymentScheduleItemId: number): Promise<PayItemResponse> {
|
||||
const res: AxiosResponse = await apiClient.post(`/api/payment_schedules/items/${paymentScheduleItemId}/pay_item`);
|
||||
return res?.data;
|
||||
}
|
||||
@ -38,4 +38,3 @@ export default class PaymentScheduleAPI {
|
||||
return res?.data;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import apiClient from './clients/api-client';
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { ShoppingCart, UpdateCardResponse } from '../models/payment';
|
||||
import { ShoppingCart } from '../models/payment';
|
||||
import { User } from '../models/user';
|
||||
import {
|
||||
CheckHashResponse,
|
||||
@ -12,39 +12,38 @@ import { Invoice } from '../models/invoice';
|
||||
import { PaymentSchedule } from '../models/payment-schedule';
|
||||
|
||||
export default class PayzenAPI {
|
||||
|
||||
static async chargeSDKTest(baseURL: string, username: string, password: string): Promise<SdkTestResponse> {
|
||||
static async chargeSDKTest (baseURL: string, username: string, password: string): Promise<SdkTestResponse> {
|
||||
const res: AxiosResponse<SdkTestResponse> = await apiClient.post('/api/payzen/sdk_test', { base_url: baseURL, username, password });
|
||||
return res?.data;
|
||||
}
|
||||
|
||||
static async chargeCreatePayment(cart: ShoppingCart, customer: User): Promise<CreatePaymentResponse> {
|
||||
static async chargeCreatePayment (cart: ShoppingCart, customer: User): Promise<CreatePaymentResponse> {
|
||||
const res: AxiosResponse<CreatePaymentResponse> = await apiClient.post('/api/payzen/create_payment', { cart_items: cart, customer_id: customer.id });
|
||||
return res?.data;
|
||||
}
|
||||
|
||||
static async chargeCreateToken(cart: ShoppingCart, customer: User): Promise<CreateTokenResponse> {
|
||||
const res: AxiosResponse = await apiClient.post('/api/payzen/create_token', { cart_items: cart, customer_id: customer.id });
|
||||
static async chargeCreateToken (cart: ShoppingCart, customer: User): Promise<CreateTokenResponse> {
|
||||
const res: AxiosResponse = await apiClient.post('/api/payzen/create_token', { cart_items: cart, customer_id: customer.id });
|
||||
return res?.data;
|
||||
}
|
||||
|
||||
static async checkHash(algorithm: string, hashKey: string, hash: string, data: string): Promise<CheckHashResponse> {
|
||||
static async checkHash (algorithm: string, hashKey: string, hash: string, data: string): Promise<CheckHashResponse> {
|
||||
const res: AxiosResponse<CheckHashResponse> = await apiClient.post('/api/payzen/check_hash', { algorithm, hash_key: hashKey, hash, data });
|
||||
return res?.data;
|
||||
}
|
||||
|
||||
static async confirm(orderId: string, cart: ShoppingCart): Promise<Invoice> {
|
||||
static async confirm (orderId: string, cart: ShoppingCart): Promise<Invoice> {
|
||||
const res: AxiosResponse<Invoice> = await apiClient.post('/api/payzen/confirm_payment', { cart_items: cart, order_id: orderId });
|
||||
return res?.data;
|
||||
}
|
||||
|
||||
static async confirmPaymentSchedule(orderId: string, transactionUuid: string, cart: ShoppingCart): Promise<PaymentSchedule> {
|
||||
static async confirmPaymentSchedule (orderId: string, transactionUuid: string, cart: ShoppingCart): Promise<PaymentSchedule> {
|
||||
const res: AxiosResponse<PaymentSchedule> = await apiClient.post('/api/payzen/confirm_payment_schedule', { cart_items: cart, order_id: orderId, transaction_uuid: transactionUuid });
|
||||
return res?.data;
|
||||
}
|
||||
|
||||
static async updateToken(payment_schedule_id: number): Promise<CreateTokenResponse> {
|
||||
const res: AxiosResponse<CreateTokenResponse> = await apiClient.post(`/api/payzen/update_token`, { payment_schedule_id });
|
||||
static async updateToken (paymentScheduleId: number): Promise<CreateTokenResponse> {
|
||||
const res: AxiosResponse<CreateTokenResponse> = await apiClient.post('/api/payzen/update_token', { payment_schedule_id: paymentScheduleId });
|
||||
return res?.data;
|
||||
}
|
||||
}
|
||||
|
@ -23,4 +23,3 @@ export default class PlanCategoryAPI {
|
||||
return res?.data;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,7 @@ export default class PlanAPI {
|
||||
}
|
||||
|
||||
static async durations (): Promise<Array<PlansDuration>> {
|
||||
const res: AxiosResponse<Array<PlansDuration>> = await apiClient.get('/api/plans/durations');
|
||||
const res: AxiosResponse<Array<PlansDuration>> = await apiClient.get('/api/plans/durations');
|
||||
return res?.data;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,11 +28,9 @@ export default class PrepaidPackAPI {
|
||||
return res?.data;
|
||||
}
|
||||
|
||||
private static filtersToQuery(filters?: PackIndexFilter): string {
|
||||
private static filtersToQuery (filters?: PackIndexFilter): string {
|
||||
if (!filters) return '';
|
||||
|
||||
return '?' + Object.entries(filters).map(f => `${f[0]}=${f[1]}`).join('&');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ import { ComputePriceResult, Price, PriceIndexFilter } from '../models/price';
|
||||
|
||||
export default class PriceAPI {
|
||||
static async compute (cart: ShoppingCart): Promise<ComputePriceResult> {
|
||||
const res: AxiosResponse<ComputePriceResult> = await apiClient.post(`/api/prices/compute`, cart);
|
||||
const res: AxiosResponse<ComputePriceResult> = await apiClient.post('/api/prices/compute', cart);
|
||||
return res?.data;
|
||||
}
|
||||
|
||||
@ -16,13 +16,12 @@ export default class PriceAPI {
|
||||
|
||||
static async update (price: Price): Promise<Price> {
|
||||
const res: AxiosResponse<Price> = await apiClient.patch(`/api/prices/${price.id}`, { price });
|
||||
return res?.data;
|
||||
return res?.data;
|
||||
}
|
||||
|
||||
private static filtersToQuery(filters?: PriceIndexFilter): string {
|
||||
private static filtersToQuery (filters?: PriceIndexFilter): string {
|
||||
if (!filters) return '';
|
||||
|
||||
return '?' + Object.entries(filters).map(f => `${f[0]}=${f[1]}`).join('&');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import apiClient from './clients/api-client';
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { Setting, SettingBulkResult, SettingError, SettingName } from '../models/setting';
|
||||
import { Setting, SettingBulkResult, SettingError, SettingName, SettingValue } from '../models/setting';
|
||||
|
||||
export default class SettingAPI {
|
||||
static async get (name: SettingName): Promise<Setting> {
|
||||
@ -8,7 +8,7 @@ export default class SettingAPI {
|
||||
return res?.data?.setting;
|
||||
}
|
||||
|
||||
static async query (names: Array<SettingName>): Promise<Map<SettingName, any>> {
|
||||
static async query (names: Array<SettingName>): Promise<Map<SettingName, string>> {
|
||||
const params = new URLSearchParams();
|
||||
params.append('names', `['${names.join("','")}']`);
|
||||
|
||||
@ -16,13 +16,13 @@ export default class SettingAPI {
|
||||
return SettingAPI.toSettingsMap(names, res?.data);
|
||||
}
|
||||
|
||||
static async update (name: SettingName, value: any): Promise<Setting> {
|
||||
static async update (name: SettingName, value: SettingValue): Promise<Setting> {
|
||||
const res: AxiosResponse = await apiClient.patch(`/api/settings/${name}`, { setting: { value } });
|
||||
if (res.status === 304) { return { name, value }; }
|
||||
return res?.data?.setting;
|
||||
if (res.status === 304) { return { name, value: `${value}` }; }
|
||||
return res?.data?.setting;
|
||||
}
|
||||
|
||||
static async bulkUpdate (settings: Map<SettingName, any>, transactional: boolean = false): Promise<Map<SettingName, SettingBulkResult>> {
|
||||
static async bulkUpdate (settings: Map<SettingName, SettingValue>, transactional = false): Promise<Map<SettingName, SettingBulkResult>> {
|
||||
const res: AxiosResponse = await apiClient.patch(`/api/settings/bulk_update?transactional=${transactional}`, { settings: SettingAPI.toObjectArray(settings) });
|
||||
return SettingAPI.toBulkMap(res?.data?.settings);
|
||||
}
|
||||
@ -32,7 +32,7 @@ export default class SettingAPI {
|
||||
return res?.data?.isPresent;
|
||||
}
|
||||
|
||||
private static toSettingsMap(names: Array<SettingName>, data: Object): Map<SettingName, any> {
|
||||
private static toSettingsMap (names: Array<SettingName>, data: Record<string, string|null>): Map<SettingName, string> {
|
||||
const map = new Map();
|
||||
names.forEach(name => {
|
||||
map.set(name, data[name] || '');
|
||||
@ -40,7 +40,7 @@ export default class SettingAPI {
|
||||
return map;
|
||||
}
|
||||
|
||||
private static toBulkMap(data: Array<Setting|SettingError>): Map<SettingName, SettingBulkResult> {
|
||||
private static toBulkMap (data: Array<Setting|SettingError>): Map<SettingName, SettingBulkResult> {
|
||||
const map = new Map();
|
||||
data.forEach(item => {
|
||||
const itemData: SettingBulkResult = { status: true };
|
||||
@ -55,20 +55,19 @@ export default class SettingAPI {
|
||||
itemData.localized = item.localized;
|
||||
}
|
||||
|
||||
map.set(item.name as SettingName, itemData)
|
||||
map.set(item.name as SettingName, itemData);
|
||||
});
|
||||
return map;
|
||||
}
|
||||
|
||||
private static toObjectArray(data: Map<SettingName, any>): Array<Object> {
|
||||
private static toObjectArray (data: Map<SettingName, SettingValue>): Array<Record<string, SettingValue>> {
|
||||
const array = [];
|
||||
data.forEach((value, key) => {
|
||||
array.push({
|
||||
name: key,
|
||||
value
|
||||
})
|
||||
});
|
||||
});
|
||||
return array;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,42 +5,41 @@ import { PaymentSchedule } from '../models/payment-schedule';
|
||||
import { Invoice } from '../models/invoice';
|
||||
|
||||
export default class StripeAPI {
|
||||
static async confirmMethod (stp_payment_method_id: string, cart_items: ShoppingCart): Promise<PaymentConfirmation|Invoice> {
|
||||
const res: AxiosResponse<PaymentConfirmation|Invoice> = await apiClient.post(`/api/stripe/confirm_payment`, {
|
||||
payment_method_id: stp_payment_method_id,
|
||||
cart_items
|
||||
static async confirmMethod (paymentMethodId: string, cartItems: ShoppingCart): Promise<PaymentConfirmation|Invoice> {
|
||||
const res: AxiosResponse<PaymentConfirmation|Invoice> = await apiClient.post('/api/stripe/confirm_payment', {
|
||||
payment_method_id: paymentMethodId,
|
||||
cart_items: cartItems
|
||||
});
|
||||
return res?.data;
|
||||
}
|
||||
|
||||
static async confirmIntent (stp_payment_intent_id: string, cart_items: ShoppingCart): Promise<PaymentConfirmation|Invoice> {
|
||||
const res: AxiosResponse = await apiClient.post(`/api/payments/confirm_payment`, {
|
||||
payment_intent_id: stp_payment_intent_id,
|
||||
cart_items
|
||||
static async confirmIntent (paymentMethodId: string, cartItems: ShoppingCart): Promise<PaymentConfirmation|Invoice> {
|
||||
const res: AxiosResponse = await apiClient.post('/api/payments/confirm_payment', {
|
||||
payment_intent_id: paymentMethodId,
|
||||
cart_items: cartItems
|
||||
});
|
||||
return res?.data;
|
||||
}
|
||||
|
||||
static async setupIntent (user_id: number): Promise<IntentConfirmation> {
|
||||
const res: AxiosResponse<IntentConfirmation> = await apiClient.get(`/api/stripe/setup_intent/${user_id}`);
|
||||
static async setupIntent (userId: number): Promise<IntentConfirmation> {
|
||||
const res: AxiosResponse<IntentConfirmation> = await apiClient.get(`/api/stripe/setup_intent/${userId}`);
|
||||
return res?.data;
|
||||
}
|
||||
|
||||
static async confirmPaymentSchedule (setup_intent_id: string, cart_items: ShoppingCart): Promise<PaymentSchedule> {
|
||||
const res: AxiosResponse<PaymentSchedule> = await apiClient.post(`/api/stripe/confirm_payment_schedule`, {
|
||||
setup_intent_id,
|
||||
cart_items
|
||||
static async confirmPaymentSchedule (setupIntentId: string, cartItems: ShoppingCart): Promise<PaymentSchedule> {
|
||||
const res: AxiosResponse<PaymentSchedule> = await apiClient.post('/api/stripe/confirm_payment_schedule', {
|
||||
setup_intent_id: setupIntentId,
|
||||
cart_items: cartItems
|
||||
});
|
||||
return res?.data;
|
||||
}
|
||||
|
||||
static async updateCard (user_id: number, stp_payment_method_id: string, payment_schedule_id?: number): Promise<UpdateCardResponse> {
|
||||
const res: AxiosResponse<UpdateCardResponse> = await apiClient.post(`/api/stripe/update_card`, {
|
||||
user_id,
|
||||
payment_method_id: stp_payment_method_id,
|
||||
payment_schedule_id
|
||||
static async updateCard (userId: number, paymentMethodId: string, paymentScheduleId?: number): Promise<UpdateCardResponse> {
|
||||
const res: AxiosResponse<UpdateCardResponse> = await apiClient.post('/api/stripe/update_card', {
|
||||
user_id: userId,
|
||||
payment_method_id: paymentMethodId,
|
||||
payment_schedule_id: paymentScheduleId
|
||||
});
|
||||
return res?.data;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,7 @@ import { Theme } from '../models/theme';
|
||||
|
||||
export default class ThemeAPI {
|
||||
static async index (): Promise<Array<Theme>> {
|
||||
const res: AxiosResponse<Array<Theme>> = await apiClient.get(`/api/themes`);
|
||||
const res: AxiosResponse<Array<Theme>> = await apiClient.get('/api/themes');
|
||||
return res?.data;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,12 +3,12 @@ import { UserPack, UserPackIndexFilter } from '../models/user-pack';
|
||||
import { AxiosResponse } from 'axios';
|
||||
|
||||
export default class UserPackAPI {
|
||||
static async index(filters: UserPackIndexFilter): Promise<Array<UserPack>> {
|
||||
static async index (filters: UserPackIndexFilter): Promise<Array<UserPack>> {
|
||||
const res: AxiosResponse<Array<UserPack>> = await apiClient.get(`/api/user_packs${this.filtersToQuery(filters)}`);
|
||||
return res?.data;
|
||||
}
|
||||
|
||||
private static filtersToQuery(filters?: UserPackIndexFilter): string {
|
||||
private static filtersToQuery (filters?: UserPackIndexFilter): string {
|
||||
if (!filters) return '';
|
||||
|
||||
return '?' + Object.entries(filters).map(f => `${f[0]}=${f[1]}`).join('&');
|
||||
|
@ -3,9 +3,8 @@ import { AxiosResponse } from 'axios';
|
||||
import { Wallet } from '../models/wallet';
|
||||
|
||||
export default class WalletAPI {
|
||||
static async getByUser (user_id: number): Promise<Wallet> {
|
||||
const res: AxiosResponse = await apiClient.get(`/api/wallet/by_user/${user_id}`);
|
||||
static async getByUser (userId: number): Promise<Wallet> {
|
||||
const res: AxiosResponse = await apiClient.get(`/api/wallet/by_user/${userId}`);
|
||||
return res?.data;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,6 @@ import Switch from 'react-switch';
|
||||
import { react2angular } from 'react2angular';
|
||||
import { IApplication } from '../../models/application';
|
||||
|
||||
declare var Application: IApplication;
|
||||
declare let Application: IApplication;
|
||||
|
||||
Application.Components.component('switch', react2angular(Switch, ['checked', 'onChange', 'id', 'className', 'disabled']));
|
||||
|
@ -1,7 +1,7 @@
|
||||
import moment from 'moment';
|
||||
import { IFablab } from '../models/fablab';
|
||||
|
||||
declare var Fablab: IFablab;
|
||||
declare let Fablab: IFablab;
|
||||
|
||||
export default class FormatLib {
|
||||
/**
|
||||
@ -15,6 +15,6 @@ export default class FormatLib {
|
||||
* Return the formatted localized amount for the given price (eg. 20.5 => "20,50 €")
|
||||
*/
|
||||
static price = (price: number): string => {
|
||||
return new Intl.NumberFormat(Fablab.intl_locale, {style: 'currency', currency: Fablab.intl_currency}).format(price);
|
||||
return new Intl.NumberFormat(Fablab.intl_locale, { style: 'currency', currency: Fablab.intl_currency }).format(price);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import HttpApi from 'i18next-http-backend';
|
||||
import { initReactI18next } from 'react-i18next';
|
||||
import { IFablab } from '../models/fablab';
|
||||
|
||||
declare var Fablab: IFablab;
|
||||
declare let Fablab: IFablab;
|
||||
|
||||
i18n
|
||||
.use(ICU)
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { IModule } from "angular";
|
||||
import { IModule } from 'angular';
|
||||
|
||||
export interface IApplication {
|
||||
Components: IModule,
|
||||
|
@ -21,8 +21,8 @@ export interface IFablab {
|
||||
translations: {
|
||||
app: {
|
||||
shared: {
|
||||
buttons: Object,
|
||||
messages: Object,
|
||||
buttons: Record<string, string>,
|
||||
messages: Record<string, string>,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ export interface CreateTokenResponse {
|
||||
orderId: string
|
||||
}
|
||||
|
||||
export interface CreatePaymentResponse extends CreateTokenResponse {}
|
||||
export type CreatePaymentResponse = CreateTokenResponse
|
||||
|
||||
export interface CheckHashResponse {
|
||||
validity: boolean
|
||||
@ -88,10 +88,10 @@ export interface PaymentTransaction {
|
||||
detailedErrorCode? : string,
|
||||
detailedErrorMessage?: string,
|
||||
detailedStatus?: 'ACCEPTED' | 'AUTHORISED' | 'AUTHORISED_TO_VALIDATE' | 'CANCELLED' | 'CAPTURED' | 'EXPIRED' | 'PARTIALLY_AUTHORISED' | 'REFUSED' | 'UNDER_VERIFICATION' | 'WAITING_AUTHORISATION' | 'WAITING_AUTHORISATION_TO_VALIDATE' | 'ERROR',
|
||||
effectiveStrongAuthentication?: 'ENABLED' | 'DISABLED' ,
|
||||
effectiveStrongAuthentication?: 'ENABLED' | 'DISABLED',
|
||||
errorCode?: string,
|
||||
errorMessage?: string,
|
||||
metadata?: any,
|
||||
metadata?: unknown,
|
||||
operationType?: 'DEBIT' | 'CREDIT' | 'VERIFICATION',
|
||||
orderDetails?: OrderDetails,
|
||||
paymentMethodToken?: string,
|
||||
@ -106,13 +106,13 @@ export interface PaymentTransaction {
|
||||
mid?: string,
|
||||
parentTransactionUuid?: string,
|
||||
sequenceNumber?: string,
|
||||
cardDetails?: any,
|
||||
fraudManagement?: any,
|
||||
cardDetails?: unknown,
|
||||
fraudManagement?: unknown,
|
||||
taxAmount?: number,
|
||||
taxRate?: number,
|
||||
preTaxAmount?: number,
|
||||
externalTransactionId?: number,
|
||||
dcc?: any,
|
||||
dcc?: unknown,
|
||||
nsu?: string,
|
||||
tid?: string,
|
||||
acquirerNetwork?: string,
|
||||
@ -149,7 +149,7 @@ export interface KryptonError {
|
||||
detailedErrorMessage: string,
|
||||
errorCode: string,
|
||||
errorMessage: string,
|
||||
field: any,
|
||||
field: unknown,
|
||||
formId: string,
|
||||
metadata: {
|
||||
answer: ProcessPaymentAnswer,
|
||||
@ -179,12 +179,14 @@ export interface KryptonConfig {
|
||||
}
|
||||
|
||||
type DefaultCallback = () => void
|
||||
type BrandChangedCallback = (event: {KR: KryptonClient, cardInfo: {brand: string}}) => void
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
type BrandChangedCallback = (event: { KR: KryptonClient, cardInfo: { brand: string } }) => void
|
||||
type ErrorCallback = (event: KryptonError) => void
|
||||
type FocusCallback = (event: KryptonFocus) => void
|
||||
type InstallmentChangedCallback = (event: {KR: KryptonClient, installmentInfo: {brand: string, hasInterests: boolean, installmentCount: number, totalAmount: number}}) => void
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
type InstallmentChangedCallback = (event: { KR: KryptonClient, installmentInfo: { brand: string, hasInterests: boolean, installmentCount: number, totalAmount: number } }) => void
|
||||
type SubmitCallback = (event: ProcessPaymentAnswer) => boolean
|
||||
type ClickCallback = (event: any) => boolean
|
||||
type ClickCallback = (event: unknown) => boolean
|
||||
|
||||
export interface KryptonClient {
|
||||
addForm: (selector: string) => Promise<{KR: KryptonClient, result: {formId: string}}>,
|
||||
|
@ -112,6 +112,8 @@ export enum SettingName {
|
||||
RenewPackThreshold = 'renew_pack_threshold',
|
||||
}
|
||||
|
||||
export type SettingValue = string|boolean|number;
|
||||
|
||||
export interface Setting {
|
||||
name: SettingName,
|
||||
localized?: string,
|
||||
@ -128,7 +130,7 @@ export interface SettingError {
|
||||
|
||||
export interface SettingBulkResult {
|
||||
status: boolean,
|
||||
value?: any,
|
||||
value?: string,
|
||||
error?: string,
|
||||
localized?: string,
|
||||
}
|
||||
|
52
app/frontend/src/javascript/models/stripe.ts
Normal file
52
app/frontend/src/javascript/models/stripe.ts
Normal file
@ -0,0 +1,52 @@
|
||||
export interface PIIToken {
|
||||
id: string,
|
||||
object: 'token',
|
||||
client_ip: string,
|
||||
created: number,
|
||||
livemode: boolean,
|
||||
type: 'pii',
|
||||
used: boolean
|
||||
}
|
||||
|
||||
export interface Charge {
|
||||
id: string,
|
||||
object: 'charge',
|
||||
amount: number,
|
||||
amount_captured: number,
|
||||
amount_refunded: number,
|
||||
application?: string,
|
||||
application_fee?: string,
|
||||
application_fee_amount?: number,
|
||||
calculated_statement_descriptor: string,
|
||||
captured: boolean,
|
||||
created: Date,
|
||||
failure_code?: string
|
||||
failure_message?: string,
|
||||
fraud_details: Record<string, unknown>,
|
||||
livemode: boolean
|
||||
on_behalf_of?: string,
|
||||
order?: string,
|
||||
outcome?: Record<string, unknown>,
|
||||
paid: boolean,
|
||||
payment_method: string,
|
||||
receipt_number?: string,
|
||||
receipt_url: string,
|
||||
refunds: {
|
||||
object: 'list',
|
||||
data: Array<unknown>,
|
||||
has_more: boolean,
|
||||
url: string
|
||||
},
|
||||
review?: string
|
||||
source_transfer?: string,
|
||||
transfer?: string,
|
||||
transfer_data?: Record<string, unknown>,
|
||||
transfer_group?: string,
|
||||
}
|
||||
|
||||
export interface ListCharges {
|
||||
object: 'list',
|
||||
url: string,
|
||||
has_more: boolean,
|
||||
data: Array<Charge>
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
import { Plan } from './plan';
|
||||
import { PaymentMethod } from './payment';
|
||||
|
||||
export interface Subscription {
|
||||
id: number,
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { Plan } from './plan';
|
||||
|
||||
|
||||
export enum UserRole {
|
||||
Member = 'member',
|
||||
Manager = 'manager',
|
||||
|
@ -1,4 +1,5 @@
|
||||
declare module "*.png" {
|
||||
declare module '*.png' {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const value: any;
|
||||
export default value;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user