Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I love to fix bugs #110

Merged
merged 3 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/components/MoodGraph/MoodGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface Props {
conditionsData?: UserConditionRecieved[];
}


export const MoodGraph = ({conditionsData}: Props) => {
const [data, setData] = useState <BarDatum[]>([{ x: 0, y: 0 }]);
const [conditionValues, setConditionValues] = useState<UserConditionRecieved[]>([]);
Expand Down Expand Up @@ -49,7 +50,7 @@ export const MoodGraph = ({conditionsData}: Props) => {
})
}

if (monthFilteredArray) {
if (monthFilteredArray.length !== 0) {

monthFilteredArray.forEach((item) => {
const day = new Date(item.date).getUTCDate();
Expand Down Expand Up @@ -85,7 +86,7 @@ export const MoodGraph = ({conditionsData}: Props) => {
}

useEffect(() => {
if (conditionsData) {
if (conditionsData && conditionsData.length !== 0) {
setConditionValues(conditionsData.slice(0));
} else if (pathname === "/main" && conditionsRecieved) {
setConditionValues(conditionsRecieved.slice(0));
Expand Down Expand Up @@ -132,8 +133,9 @@ export const MoodGraph = ({conditionsData}: Props) => {
<img src={worriedIcon} alt="смайлик плохого настроения"/>
</div>

{ data.length !== 0 &&
<ResponsiveBar
data={data}
data={ data}
margin={{ top: 50, right: 0, bottom: 40, left: 30 }}
padding={0.35}
// xScale={{ type: "point" }}
Expand All @@ -152,8 +154,8 @@ export const MoodGraph = ({conditionsData}: Props) => {
id: 'gradient',
type: 'linearGradient',
colors: [
{ offset: 0, color: '#BA99FF' },
{ offset: 100, color: '#DCCDFC' },
{ offset: 0, color: '#BA99FF' },
{ offset: 100, color: '#DCCDFC' },
],
},
]}
Expand All @@ -163,8 +165,9 @@ export const MoodGraph = ({conditionsData}: Props) => {
axisLeft={null}
axisBottom={{
tickSize: 0,
}}
}}
/>
}
</div>
);
};
9 changes: 6 additions & 3 deletions src/pages/profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,12 @@ export const Profile = ({ handleAddMeetingInfo }: Props): ReactElement => {
<div className={styles.statics}>
<h2 className={styles.staticsTitle}>Статистика</h2>
<BurnoutLevel burnOutData={burnOutData && burnOutData} />
<MoodGraph
conditionsData={conditionsData && conditionsData}
/>
{
conditionsData && conditionsData.length !== 0 &&
<MoodGraph
conditionsData={conditionsData}
/>
}
<div className={styles.circleChartsSection}>
<div className={styles.pieChartContainer}>
<h3 className={styles.pieChartTitle}>Деятельность</h3>
Expand Down
1 change: 1 addition & 0 deletions src/pages/profile/components/About/about.module.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import '@/shared/styles/mixins.scss';

.about {
word-wrap: break-word;
width: 100%;
border-radius: 20px;
padding: 12px 20px 16px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const AddMeetingForm = ({closePopup, userId, handleAddMeetingInfo, update
const [moodStates] = useRequest(() => getMentalStates());
const [disabledButton, setDisabledButton] = useState<boolean>(true);

const regex = /^[\w\s\d\x20-\x7EА-Яа-яЁё]{2,256}$/;
const regex = /^[а-яА-Яa-zA-Z0-9\s!"#$%&'()*+,-./:;<=>?@[\\\]^_`{|}~]*$/;

useEffect(() => {
if(value && selectedDate && comment && !commentError) {
Expand Down Expand Up @@ -81,7 +81,7 @@ export const AddMeetingForm = ({closePopup, userId, handleAddMeetingInfo, update
setCommentError("Максимальное количество символов: 256");
setDisabledButton(true);
} else if (!regex.test(value)) {
setCommentError("");
setCommentError("Можно вводить только заглавные и строчные буквы русского и английского алфавита, цифры, символы и пробелы.");
setDisabledButton(true);
} else {
setCommentError("");
Expand Down