Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
fix(app): fix dateformat deps after version update
Browse files Browse the repository at this point in the history
  • Loading branch information
rhahao committed Feb 9, 2022
1 parent f3ca4d0 commit aac993a
Show file tree
Hide file tree
Showing 12 changed files with 550 additions and 424 deletions.
3 changes: 1 addition & 2 deletions src/components/schedule/DialogAssignmentDelete.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react';
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil';
import { useTranslation } from 'react-i18next';
import dateFormat from 'dateformat';
import Button from '@mui/material/Button';
import Dialog from '@mui/material/Dialog';
import DialogActions from '@mui/material/DialogActions';
Expand All @@ -22,8 +23,6 @@ import {
shortDateFormatState,
} from '../../appStates/appSettings';

const dateFormat = require('dateformat');

const DialogAssignmentDelete = () => {
const { t } = useTranslation();

Expand Down
8 changes: 4 additions & 4 deletions src/components/settings/DialogDbBackup.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const DialogDbBackup = () => {
let abortCont = useMemo(() => new AbortController(), []);

const [isDisabled, setIsDisabled] = useState(true);
const [dateFormat, setDateFormat] = useState('');
const [formatDate, setFormatDate] = useState('');
const [backupCreatePwd, setBackupCreatePwd] = useState('');
const [backupConfirmPwd, setBackupConfirmPwd] = useState('');
const [backupNewDevice, setBackupNewDevice] = useState('');
Expand Down Expand Up @@ -234,7 +234,7 @@ const DialogDbBackup = () => {
if (backupDate !== '') {
var timestamp = backupDate;
var date = new Date(timestamp);
setDateFormat(
setFormatDate(
date.toLocaleDateString() + ' ' + date.toLocaleTimeString()
);
}
Expand Down Expand Up @@ -630,7 +630,7 @@ const DialogDbBackup = () => {
sx={{ fontSize: '11px' }}
align='center'
>
{dateFormat}
{formatDate}
</Typography>
</Box>
</Box>
Expand Down Expand Up @@ -726,7 +726,7 @@ const DialogDbBackup = () => {
{backupDevice.split('|')[1]}
</Typography>
<Typography sx={{ fontSize: '11px' }} align='center'>
{dateFormat}
{formatDate}
</Typography>
</Box>
<Box
Expand Down
3 changes: 1 addition & 2 deletions src/components/sourceMaterial/WeekList.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react';
import { useRecoilState, useRecoilValue } from 'recoil';
import { useTranslation } from 'react-i18next';
import dateFormat from 'dateformat';
import MenuItem from '@mui/material/MenuItem';
import TextField from '@mui/material/TextField';
import {
Expand All @@ -16,8 +17,6 @@ import {
yearsListState,
} from '../../appStates/appSourceMaterial';

const dateFormat = require('dateformat');

const WeekList = () => {
const { t } = useTranslation();

Expand Down
4 changes: 2 additions & 2 deletions src/components/students/StudentCard.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ReactComponent as maleIcon } from '../../img/student_male.svg';
import { ReactComponent as femaleIcon } from '../../img/student_female.svg';
import maleIcon from '../../img/student_male.svg';
import femaleIcon from '../../img/student_female.svg';
import { useSetRecoilState } from 'recoil';
import { useTranslation } from 'react-i18next';
import {
Expand Down
4 changes: 2 additions & 2 deletions src/components/students/StudentDetails.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useEffect, useState } from 'react';
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil';
import { useTranslation } from 'react-i18next';
import { ReactComponent as maleIcon } from '../../img/student_male.svg';
import { ReactComponent as femaleIcon } from '../../img/student_female.svg';
import maleIcon from '../../img/student_male.svg';
import femaleIcon from '../../img/student_female.svg';
import Avatar from '@mui/material/Avatar';
import Box from '@mui/material/Box';
import Button from '@mui/material/Button';
Expand Down
3 changes: 1 addition & 2 deletions src/epub/epubParser.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import loadEPUB from 'jw-epub-parser';
import dateFormat from 'dateformat';
import { promiseGetRecoil } from 'recoil-outside';
import { dbSaveSrcData } from '../indexedDb/dbSourceMaterial';
import { monthNamesState } from '../appStates/appSettings';
import { assTypeLocalState } from '../appStates/appSourceMaterial';

const dateFormat = require('dateformat');

export const addEpubDataToDb = async (fileEPUB) => {
try {
const data = await loadEPUB(fileEPUB);
Expand Down
4 changes: 1 addition & 3 deletions src/indexedDb/dbAssignment.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { getI18n } from 'react-i18next';
import { promiseGetRecoil } from 'recoil-outside';
import dateFormat from 'dateformat';
import { dbGetAppSettings } from './dbAppSettings';
import { dbGetStudentDetails } from './dbPersons';
import { dbGetScheduleData } from './dbSchedule';
import { dbGetSourceMaterial, dbGetWeekListBySched } from './dbSourceMaterial';
import appDb from './mainDb';
import { assTypeLocalState } from '../appStates/appSourceMaterial';

const dateFormat = require('dateformat');

const { t } = getI18n();

export const dbGetAssType = async (assType, appLang) => {
Expand Down Expand Up @@ -77,7 +76,6 @@ export const dbHistoryAssignment = async () => {
var person = {};

const weekData = await dbGetSourceMaterial(appData[i].weekOf);
var dateFormat = require('dateformat');
const [varMonth, varDay, varYear] = appData[i].weekOf.split('/');
const lDate = new Date(varYear, varMonth - 1, varDay);
const dateFormatted = dateFormat(lDate, 'dd/mm/yyyy');
Expand Down
3 changes: 1 addition & 2 deletions src/indexedDb/dbPersons.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import dateFormat from 'dateformat';
import { dbGetAppSettings } from './dbAppSettings';
import { dbGetSourceMaterial } from './dbSourceMaterial';
import { getI18n } from 'react-i18next';
import appDb from './mainDb';

const dateFormat = require('dateformat');

const { t } = getI18n();

export const dbGetStudents = async () => {
Expand Down
4 changes: 1 addition & 3 deletions src/indexedDb/dbSourceMaterial.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import appDb from './mainDb';
import { promiseGetRecoil } from 'recoil-outside';
import dateFormat from 'dateformat';
import { appLangState } from '../appStates/appSettings';
import { assTypeLocalState } from '../appStates/appSourceMaterial';

Expand Down Expand Up @@ -212,7 +213,6 @@ const dbSaveSchedData = async (weekOf, weekType, noMeeting, isOverride) => {

export const hasCurrentWeek = async () => {
var varBool = true;
var dateFormat = require('dateformat');
var today = new Date();
var day = today.getDay();
var diff = today.getDate() - day + (day === 0 ? -6 : 1);
Expand All @@ -228,7 +228,6 @@ export const hasCurrentWeek = async () => {
export const checkSrcUpdate = async () => {
var checkCurrentWeek = await hasCurrentWeek();
if (checkCurrentWeek === false) {
var dateFormat = require('dateformat');
var today = new Date();
var day = today.getDay();
var diff = today.getDate() - day + (day === 0 ? -6 : 1);
Expand Down Expand Up @@ -357,7 +356,6 @@ export const dbAddManualSource = async () => {
const year = lastWeek.split('/')[2];
var result = new Date(year, month - 1, day);
result.setDate(result.getDate() + 7);
var dateFormat = require('dateformat');
const fMonday = dateFormat(result, 'mm/dd/yyyy');
await dbAddWeekToSource(fMonday);
await dbAddWeekToSchedule(fMonday);
Expand Down
3 changes: 1 addition & 2 deletions src/pages/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
import { useRecoilValue } from 'recoil';
import { useTranslation } from 'react-i18next';
import { styled } from '@mui/styles';
import dateFormat from 'dateformat';
import Box from '@mui/material/Box';
import CircularProgress from '@mui/material/CircularProgress';
import Container from '@mui/material/Container';
Expand All @@ -20,8 +21,6 @@ import {
import { classCountState } from '../appStates/appCongregation';
import { shortDateFormatState } from '../appStates/appSettings';

const dateFormat = require('dateformat');

const sharedStyles = {
typoLineHeight: {
lineHeight: 1.3,
Expand Down
3 changes: 1 addition & 2 deletions src/pages/Schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
import { useHistory } from 'react-router-dom';
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil';
import { useTranslation } from 'react-i18next';
import dateFormat from 'dateformat';
import AssignmentIcon from '@mui/icons-material/Assignment';
import Box from '@mui/material/Box';
import Button from '@mui/material/Button';
Expand Down Expand Up @@ -35,8 +36,6 @@ import {
weekListSchedState,
} from '../appStates/appSchedule';

const dateFormat = require('dateformat');

const sharedStyles = {
btnSchedule: {
margin: '0 2px 2px 0',
Expand Down
Loading

0 comments on commit aac993a

Please sign in to comment.