diff --git a/src/components/dashboard/dashboard.functions.ts b/src/components/dashboard/dashboard.functions.ts index e794a2b..85f7a86 100644 --- a/src/components/dashboard/dashboard.functions.ts +++ b/src/components/dashboard/dashboard.functions.ts @@ -12,7 +12,9 @@ export const toHTML = (key: string) => { return /* html */ `
  • ${model.title} - 12.06.2023 + + ${new Date(model.dateTable).toLocaleDateString()} ${new Date(model.dateTable).toLocaleTimeString()} +
  • `; }; diff --git a/src/components/excel/Excel.ts b/src/components/excel/Excel.ts index d6fec02..478c54c 100644 --- a/src/components/excel/Excel.ts +++ b/src/components/excel/Excel.ts @@ -3,6 +3,7 @@ import { IExcelComponent } from '@src/core/excelComponent/ExcelComponent'; import Observer from '@src/core/observer/Observer'; import StoreSubscriber from '@src/core/storeSubscriber/StoreSubscriber'; import { TActions } from '@src/store/action.types'; +import { updateDate } from '@src/store/actions'; import { IReturnCreateStore, IRootState } from '@src/store/store.types'; interface IExcelOptions { @@ -49,6 +50,7 @@ class Excel { } init() { + this.store.dispatch(updateDate()); this.subscriber.subscribeComponents(this.objectComponents); this.objectComponents.forEach((component) => { component.init(); diff --git a/src/store/action.types.ts b/src/store/action.types.ts index 498b9fe..de1ed5d 100644 --- a/src/store/action.types.ts +++ b/src/store/action.types.ts @@ -23,12 +23,17 @@ export interface IChangeTitle { payload: string; } +export interface IUpdateDate { + readonly type: 'UPDATE_DATE'; +} + export type TTableActions = | ITableResizeActionCreator | IChangeTextActionCreator | IApplyStyle | ICurrentStyles | IChangeTitle + | IUpdateDate | { type: '__INIT__'; payload: any }; export type TActions = TTableActions; diff --git a/src/store/actions.ts b/src/store/actions.ts index c189861..5812fbc 100644 --- a/src/store/actions.ts +++ b/src/store/actions.ts @@ -6,6 +6,7 @@ import { IChangeTitle, ICurrentStyles, ITableResizeActionCreator, + IUpdateDate, } from './action.types'; export const tableResizeActionCreator = (data: ITableResize): ITableResizeActionCreator => ({ @@ -32,3 +33,7 @@ export const changeTitle = (data: string): IChangeTitle => ({ type: 'CHANGE_TITLE', payload: data, }); + +export const updateDate = (): IUpdateDate => ({ + type: 'UPDATE_DATE', +}); diff --git a/src/store/initialState.ts b/src/store/initialState.ts index b4094c2..cddf983 100644 --- a/src/store/initialState.ts +++ b/src/store/initialState.ts @@ -11,6 +11,7 @@ export const defaultState: IRootState = { currentText: '', currentStyles: initialToolbarState, title: DEFAULT_TITLE, + dateTable: new Date().toJSON(), }; const localStorageState = localStorageFn(EXCEL_STATE); diff --git a/src/store/rootReducer.ts b/src/store/rootReducer.ts index 21e5b0f..e15c8e8 100644 --- a/src/store/rootReducer.ts +++ b/src/store/rootReducer.ts @@ -47,6 +47,9 @@ const rootReducer = (state: IRootState, action: TActions): IRootState => { case 'CHANGE_TITLE': return { ...state, title: action.payload }; + case 'UPDATE_DATE': + return { ...state, dateTable: new Date().toJSON() }; + default: return state; } diff --git a/src/store/store.types.ts b/src/store/store.types.ts index 68367b3..04c2a2b 100644 --- a/src/store/store.types.ts +++ b/src/store/store.types.ts @@ -18,4 +18,5 @@ export interface IRootState { currentText: string; currentStyles: IToolbarState; title: string; + dateTable: string; }