Skip to content

Commit

Permalink
Merge branch 'main' into feature/README_file
Browse files Browse the repository at this point in the history
  • Loading branch information
MargoMarm committed Sep 28, 2023
2 parents 80ddc76 + e3804d3 commit 8b77f58
Show file tree
Hide file tree
Showing 80 changed files with 1,508 additions and 852 deletions.
22 changes: 20 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@
"@mui/x-date-pickers": "^6.14.0",
"@reduxjs/toolkit": "^1.9.5",
"@table-library/react-table-library": "^4.1.7",
"animate.css": "^4.1.1",
"axios": "^1.5.0",
"date-fns": "^2.30.0",
"dayjs": "^1.11.9",
"formik": "^2.4.4",
"lodash.debounce": "^4.0.8",
"modern-normalize": "^2.0.0",
"notiflix": "^3.2.6",
"overlayscrollbars": "^2.3.1",
"overlayscrollbars-react": "^0.5.2",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-countdown-circle-timer": "^3.2.1",
"react-datepicker": "^4.18.0",
"react-dom": "^18.2.0",
"react-infinite-scroller": "^1.2.6",
"react-loader-spinner": "^5.4.5",
"react-redux": "^8.1.2",
"react-responsive": "^9.0.2",
Expand Down
2 changes: 1 addition & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useDispatch } from 'react-redux';
import { fetchCurrentUser } from './redux/auth/operation';

import SharedLayout from './components/SharedLayout/SharedLayout';
// import SharedLayout from './components/SharedLayout/SharedLayout';

import { PrivateRoute, PublicRoute } from './components/Routes';
import { UseAuth } from './hooks/useAuth';

Expand Down
Binary file removed src/assets/11.png
Binary file not shown.
17 changes: 17 additions & 0 deletions src/assets/sprite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 9 additions & 3 deletions src/components/AddExerciseForm/AddExerciseForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import {

import formatDate from '../../utils/formatDate';
import { AddButton } from '../AddProductForm/AddProductForm.styled';
import { useDispatch } from 'react-redux';
import { changeStatusTimer } from '../../redux/exercises/slice';

export default function AddExerciseForm({ data, addExercise }) {
const {
Expand All @@ -36,6 +38,8 @@ export default function AddExerciseForm({ data, addExercise }) {
const [isPlaying, setIsPlaying] = useState(false);
const [intervalId, setIntervalId] = useState(null);

const dispatch = useDispatch();

const countCalory = (calory, time, exTime) => {
const burnedCalory = Math.floor((exTime * calory) / (time * 60));
setBurnedCalory(burnedCalory);
Expand All @@ -53,6 +57,7 @@ export default function AddExerciseForm({ data, addExercise }) {
const intervalId = setInterval(writeTime, 1000);
setIntervalId(intervalId);
setIsPlaying(true);
dispatch(changeStatusTimer(true));
};

const stopExercise = () => {
Expand Down Expand Up @@ -121,14 +126,15 @@ export default function AddExerciseForm({ data, addExercise }) {
<AddButton
disabled={burnedCalory > 10 ? false : true}
type="button"
onClick={() =>
onClick={() => {
addExercise({
id: _id,
date,
time: exTime,
burnedCalories: burnedCalory,
})
}
});
dispatch(changeStatusTimer(false));
}}
>
Add to diary
</AddButton>
Expand Down
1 change: 0 additions & 1 deletion src/components/AddProductForm/AddProductForm.styled.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ export const AddButton = styled.button`
color: ${colors.textWhite06};
background: ${colors.orangeSecondary};
cursor: not-allowed;
}
`;

Expand Down
145 changes: 81 additions & 64 deletions src/components/AuthForm/AuthForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export default function AuthForm({ nameIsShown, btnTitle, onSubmit }) {
const authSchema = Yup.object().shape({
name: validateName(nameIsShown),
email: Yup.string()
.matches(emailLyout, { message: 'Email must be valid! For example: [email protected]' })
.matches(emailLyout, {
message: 'Email must be valid! For example: [email protected]',
})
.email('Invalid email')
.required('Email is required'),
password: Yup.string()
Expand Down Expand Up @@ -68,13 +70,82 @@ export default function AuthForm({ nameIsShown, btnTitle, onSubmit }) {
onSubmit={onSubmit}
validationSchema={authSchema}
>
<FormContainer>
<InputContainer>
{nameIsShown && (
{({ handleBlur, touched, errors }) => (
<FormContainer>
<InputContainer>
{nameIsShown && (
<InputWrapper>
<TextInput
id="name"
type="text"
placeholder="name"
name="name"
onBlur={handleBlur}
data-touch={touched.name && !errors.name}
/>
<Warning>
<ErrorMessage name="name">
{msg => (
<Error>
<svg width="20" height="20">
<use
href={sprite + `#icon-checkbox-circle-fill`}
></use>
</svg>
{msg}
</Error>
)}
</ErrorMessage>
</Warning>
</InputWrapper>
)}
<InputWrapper>
<TextInput
id="email"
type="email"
placeholder="Email"
name="email"
onBlur={handleBlur}
data-touch={touched.email && !errors.email}
/>
<Warning>
<ErrorMessage name="email">
{msg => (
<Error>
<svg width="20" height="20">
<use href={sprite + `#icon-checkbox-circle-fill`}></use>
</svg>
{msg}
</Error>
)}
</ErrorMessage>
</Warning>
</InputWrapper>
<InputWrapper>
<TextInput id="name" type="text" placeholder="Name" name="name" />
<TextInput
id="password"
type={typePasswordInput}
placeholder="Password"
name="password"
onBlur={handleBlur}
data-touch={touched.password && !errors.password}
/>
<ButtonIconForInput
type="button"
right="16px"
onClick={toglePassword}
>
<svg width="20" height="20">
<use
href={
sprite +
`${isPasswordShown ? `#icon-eye-off` : `#icon-eye`}`
}
></use>
</svg>
</ButtonIconForInput>
<Warning>
<ErrorMessage name="name">
<ErrorMessage name="password">
{msg => (
<Error>
<svg width="20" height="20">
Expand All @@ -86,64 +157,10 @@ export default function AuthForm({ nameIsShown, btnTitle, onSubmit }) {
</ErrorMessage>
</Warning>
</InputWrapper>
)}
<InputWrapper>
<TextInput
id="email"
type="email"
placeholder="Email"
name="email"
/>
<Warning>
<ErrorMessage name="email">
{msg => (
<Error>
<svg width="20" height="20">
<use href={sprite + `#icon-checkbox-circle-fill`}></use>
</svg>
{msg}
</Error>
)}
</ErrorMessage>
</Warning>
</InputWrapper>
<InputWrapper>
<TextInput
id="password"
type={typePasswordInput}
placeholder="Password"
name="password"
/>
<ButtonIconForInput
type="button"
right="16px"
onClick={toglePassword}
>
<svg width="20" height="20">
<use
href={
sprite +
`${isPasswordShown ? `#icon-eye-off` : `#icon-eye`}`
}
></use>
</svg>
</ButtonIconForInput>
<Warning>
<ErrorMessage name="password">
{msg => (
<Error>
<svg width="20" height="20">
<use href={sprite + `#icon-checkbox-circle-fill`}></use>
</svg>
{msg}
</Error>
)}
</ErrorMessage>
</Warning>
</InputWrapper>
</InputContainer>
<BtnSubmit title={btnTitle} fontSize="20px" />
</FormContainer>
</InputContainer>
<BtnSubmit title={btnTitle} fontSize="20px" />
</FormContainer>
)}
</Formik>
);
}
Expand Down
28 changes: 23 additions & 5 deletions src/components/AuthForm/AuthForm.styled.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@ export const InputContainer = styled.div`
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 28px;
margin-bottom: 28px;
gap: 32px;
margin-bottom: 32px;
${mq.mobile} {
gap: 33px;
margin-bottom: 34px;
}
${mq.tablet} {
gap: 32px;
margin-bottom: 64px;
gap: 34px;
margin-bottom: 54px;
}
`;

Expand Down Expand Up @@ -51,12 +57,24 @@ export const TextInput = styled(Field)`
&:focus-visible {
border: 1px solid ${colors.orange};
}
&[data-touch=true]{
border-color: ${colors.textSuccess};
}
`;

export const Warning = styled.div`
position: absolute;
${mq.smallMobile} {
bottom: -24px;
bottom: -28px;
}
${mq.Mobile} {
bottom: -29px;
}
${mq.tablet} {
bottom: -30px;
}
`;

Expand Down
Loading

0 comments on commit 8b77f58

Please sign in to comment.