Skip to content

Commit

Permalink
Merge pull request #691 from MAIF/jobAnonReports
Browse files Browse the repository at this point in the history
Remove toaster -> toast and now using date-fns
  • Loading branch information
quentinovega authored May 7, 2024
2 parents 4e28013 + 7086d7c commit 3cdaf48
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {useContext, useEffect, useState} from 'react';
import { useDaikokuBackOffice } from '../../../contexts';
import {I18nContext} from "../../../contexts/i18n-context";
import {toast} from "sonner";
import {Can, daikoku, manage} from "../../utils";
import {BooleanInput} from "@maif/react-forms";
import * as Services from '../../../services';
Expand All @@ -27,7 +28,6 @@ export const AnonymousReporting = () => {
} else {
toast.error(translate("anonymous.reporting.error"))
setIsAnonEnabled(!value)

}
}

Expand Down
11 changes: 6 additions & 5 deletions daikoku/javascript/src/components/frontend/team/MyHome.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useQuery } from '@tanstack/react-query';
import { useContext, useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';

import { subMonths } from 'date-fns';
import { toast } from 'sonner';

import { I18nContext, ModalContext } from '../../../contexts';
import { GlobalContext } from '../../../contexts/globalContext';
Expand All @@ -12,8 +13,9 @@ import {
isError
} from '../../../types';
import { api as API, CanIDoAction, manage, Spinner, teamGQLToSimple } from '../../utils';
import { GlobalContext } from '../../../contexts/globalContext';
import { ModalContext } from "../../../contexts";
import { ApiList } from './ApiList';
import { toast } from 'sonner';

export const MyHome = () => {

Expand All @@ -31,8 +33,7 @@ export const MyHome = () => {
const [daikokuId, setDaikokuId] = useState<string>()
const [lastResponseDate, setLastResponseDate] = useState<number>()
const currentDate = new Date();
const sixMonthsAgo = new Date(new Date().setMonth(currentDate.getMonth() - 6));

const sixMonthAgo = subMonths(currentDate, 6);


useEffect(() => {
Expand All @@ -44,7 +45,7 @@ export const MyHome = () => {
}, []);

useEffect(() => {
if(isAnonEnabled === false && connectedUser.isDaikokuAdmin && daikokuId && (!lastResponseDate || new Date(lastResponseDate) < sixMonthsAgo)) {
if(isAnonEnabled === false && connectedUser.isDaikokuAdmin && daikokuId && (!lastResponseDate || new Date(lastResponseDate) < sixMonthAgo)) {
confirm({title: translate('anonymous.reporting.enable'), message: <div>{translate('anonymous.reporting.popup.info')}<a href="https://maif.github.io/daikoku/docs/getstarted/setup/reporting" target="_blank" rel="noopener noreferrer"> Daikoku documentation</a></div>, okLabel: translate('Yes') })
.then((ok) => {
if (ok) {
Expand Down

0 comments on commit 3cdaf48

Please sign in to comment.