Skip to content

Commit

Permalink
feat: add toast
Browse files Browse the repository at this point in the history
  • Loading branch information
ialexanderbrito committed Apr 13, 2022
1 parent fd81853 commit d3abd96
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/pages/Horarios/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@ import { Button } from 'components/Button';
import { Header } from 'components/Header';

import { useTheme } from 'contexts/Theme';
import { useToast } from 'contexts/Toast';

import { useHorarios } from 'hooks/useHorarios';

import styles from './Horarios.module.scss';

export function Horarios() {
const { toast } = useToast();
const { theme } = useTheme();
const { formikHorarios } = useHorarios();

function addNewScheduleItem() {
const newSchedule = [...formikHorarios.values.schedules, { week_day: '', from: '', to: '' }];
if (newSchedule.length > 7) {
toast.error('Você não pode adicionar mais horários.', { id: 'toast' });
newSchedule.splice(newSchedule.length - 1, 1);
}
formikHorarios.setFieldValue('schedules', newSchedule);
Expand Down

0 comments on commit d3abd96

Please sign in to comment.