1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00

(typing) use TDateISO for typing dates

This commit is contained in:
Sylvain 2022-04-26 09:31:26 +02:00
parent b4ae80457e
commit 814ebfe52d
13 changed files with 56 additions and 38 deletions

View File

@ -1,9 +1,10 @@
import React, { useEffect, useState } from 'react';
import { LabelledInput } from './base/labelled-input';
import { useTranslation } from 'react-i18next';
import { TDateISODate } from '../typings/date-iso';
interface DocumentFiltersProps {
onFilterChange: (value: { reference: string, customer: string, date: Date }) => void
onFilterChange: (value: { reference: string, customer: string, date: TDateISODate }) => void
}
/**
@ -13,11 +14,11 @@ export const DocumentFilters: React.FC<DocumentFiltersProps> = ({ onFilterChange
const { t } = useTranslation('admin');
// stores the value of reference input
const [referenceFilter, setReferenceFilter] = useState('');
const [referenceFilter, setReferenceFilter] = useState<string>('');
// stores the value of the customer input
const [customerFilter, setCustomerFilter] = useState('');
const [customerFilter, setCustomerFilter] = useState<string>('');
// stores the value of the date input
const [dateFilter, setDateFilter] = useState(null);
const [dateFilter, setDateFilter] = useState<TDateISODate>(null);
/**
* When any filter changes, trigger the callback with the current value of all filters

View File

@ -9,6 +9,7 @@ import { User } from '../../models/user';
import { PaymentSchedule } from '../../models/payment-schedule';
import { IApplication } from '../../models/application';
import PaymentScheduleAPI from '../../api/payment-schedule';
import { TDateISODate } from '../../typings/date-iso';
declare const Application: IApplication;
@ -36,7 +37,7 @@ const PaymentSchedulesList: React.FC<PaymentSchedulesListProps> = ({ currentUser
// current filter, by customer's name, for the schedules
const [customerFilter, setCustomerFilter] = useState<string>(null);
// current filter, by date, for the schedules and the deadlines
const [dateFilter, setDateFilter] = useState<Date>(null);
const [dateFilter, setDateFilter] = useState<TDateISODate>(null);
/**
* Fetch from the API the payments schedules matching the given filters and reset the results table with the new schedules.

View File

@ -1,3 +1,5 @@
import { TDateISO } from '../typings/date-iso';
export interface Event {
id: number,
title: string,
@ -22,18 +24,18 @@ export interface Event {
age_range: {
name: string
},
start_date: Date,
start_time: Date,
end_date: Date,
end_time: Date,
start_date: TDateISO,
start_time: TDateISO,
end_date: TDateISO,
end_time: TDateISO,
month: string;
month_id: number,
year: number,
all_day: boolean,
availability: {
id: number,
start_at: Date,
end_at: Date
start_at: TDateISO,
end_at: TDateISO
},
availability_id: number,
amount: number,

View File

@ -1,7 +1,9 @@
import { TDateISO } from '../typings/date-iso';
export interface HistoryValue {
id: number,
value: string,
created_at: Date
created_at: TDateISO
user: {
id: number,
name: string

View File

@ -1,8 +1,10 @@
import { TDateISO } from '../typings/date-iso';
export interface Invoice {
id: number,
created_at: Date,
created_at: TDateISO,
reference: string,
avoir_date: Date,
avoir_date: TDateISO,
description: string
user_id: number,
total: number,
@ -11,7 +13,7 @@ export interface Invoice {
is_avoir: boolean,
is_subscription_invoice: boolean,
is_online_card: boolean,
date: Date,
date: TDateISO,
chained_footprint: boolean,
main_object: {
type: string,

View File

@ -1,3 +1,5 @@
import { TDateISO, TDateISODate } from '../typings/date-iso';
export enum PaymentScheduleItemState {
New = 'new',
Pending = 'pending',
@ -17,7 +19,7 @@ export enum PaymentMethod {
export interface PaymentScheduleItem {
id: number,
amount: number,
due_date: Date,
due_date: TDateISO,
state: PaymentScheduleItemState,
invoice_id: number,
payment_method: PaymentMethod,
@ -31,7 +33,7 @@ export interface PaymentSchedule {
reference?: string,
payment_method: PaymentMethod,
items?: Array<PaymentScheduleItem>,
created_at?: Date,
created_at?: TDateISO,
chained_footprint?: boolean,
main_object?: {
type: string,
@ -53,7 +55,7 @@ export interface PaymentScheduleIndexRequest {
query: {
reference?: string,
customer?: string,
date?: Date,
date?: TDateISODate,
page: number,
size: number
}
@ -74,5 +76,5 @@ export interface PayItemResponse {
}
export interface CancelScheduleResponse {
canceled_at: Date
canceled_at: TDateISO
}

View File

@ -1,5 +1,6 @@
import { Reservation } from './reservation';
import { SubscriptionRequest } from './subscription';
import { TDateISO } from '../typings/date-iso';
export interface PaymentConfirmation {
requires_action?: boolean,
@ -26,7 +27,7 @@ export enum PaymentMethod {
export type CartItem = { reservation: Reservation }|
{ subscription: SubscriptionRequest }|
{ prepaid_pack: { id: number } }|
{ free_extension: { end_at: Date } };
{ free_extension: { end_at: TDateISO } };
export interface ShoppingCart {
customer_id: number,

View File

@ -1,3 +1,5 @@
import { TDateISO } from '../typings/date-iso';
export interface PriceIndexFilter {
priceable_type?: string,
priceable_id?: number,
@ -20,7 +22,7 @@ export interface ComputePriceResult {
price_without_coupon: number,
details?: {
slots: Array<{
start_at: Date,
start_at: TDateISO,
price: number,
promo: boolean
}>
@ -29,7 +31,7 @@ export interface ComputePriceResult {
schedule?: {
items: Array<{
amount: number,
due_date: Date
due_date: TDateISO
}>
}
}

View File

@ -1,7 +1,9 @@
import { TDateISO } from '../typings/date-iso';
export interface ReservationSlot {
id?: number,
start_at: Date,
end_at: Date,
start_at: TDateISO,
end_at: TDateISO,
availability_id: number,
offered: boolean
}

View File

@ -1,4 +1,5 @@
import { HistoryValue } from './history-value';
import { TDateISO } from '../typings/date-iso';
export enum SettingName {
AboutTitle = 'about_title',
@ -127,7 +128,7 @@ export interface Setting {
name: SettingName,
localized?: string,
value: string,
last_update?: Date,
last_update?: TDateISO,
history?: Array<HistoryValue>
}

View File

@ -23,7 +23,7 @@ export interface Charge {
application_fee_amount?: number,
calculated_statement_descriptor: string,
captured: boolean,
created: Date,
created: number,
failure_code?: string
failure_message?: string,
fraud_details: Record<string, unknown>,
@ -61,7 +61,7 @@ export interface Price {
object: 'price',
active: boolean,
billing_scheme: 'per_unit' | 'tiered',
created: Date,
created: number,
currency: string,
livemode: boolean,
lookup_key: string,
@ -108,7 +108,7 @@ export interface TaxRate {
metadata: Record<string, unknown>,
percentage: number,
state: string,
created: Date,
created: number,
livemode: boolean,
tax_type: 'vat' | 'sales_tax' | string
}
@ -120,7 +120,7 @@ export interface SubscriptionItem {
billing_thresholds: {
usage_gte: number,
},
created: Date,
created: number,
metadata: Record<string, unknown>,
price: Price,
quantity: number,
@ -142,8 +142,8 @@ export interface Invoice {
lines: [],
metadata: Record<string, unknown>,
payment_intent: PaymentIntent,
period_end: Date,
period_start: Date,
period_end: number,
period_start: number,
status: 'draft' | 'open' | 'paid' | 'uncollectible' | 'void',
subscription: string,
total: number
@ -154,8 +154,8 @@ export interface Subscription {
id: string,
object: 'subscription',
cancel_at_period_end: boolean,
current_period_end: Date,
current_period_start: Date,
current_period_end: number,
current_period_start: number,
customer: string,
default_payment_method: string,
items: [

View File

@ -1,21 +1,22 @@
import { Plan } from './plan';
import { TDateISO } from '../typings/date-iso';
export interface Subscription {
id: number,
plan_id: number,
expired_at: Date,
canceled_at?: Date,
expired_at: TDateISO,
canceled_at?: TDateISO,
plan: Plan
}
export interface SubscriptionRequest {
plan_id: number,
start_at?: Date
start_at?: TDateISO
}
export interface UpdateSubscriptionRequest {
id: number,
expired_at: Date,
expired_at: TDateISO,
free: boolean
}

View File

@ -1,3 +1,4 @@
import { TDateISO } from '../typings/date-iso';
export interface UserPackIndexFilter {
user_id?: number,
@ -7,7 +8,7 @@ export interface UserPackIndexFilter {
export interface UserPack {
minutes_used: number,
expires_at: Date,
expires_at: TDateISO,
prepaid_pack: {
minutes: number,
}