Skip to content

Commit

Permalink
implements removing cash
Browse files Browse the repository at this point in the history
  • Loading branch information
ijcnvv committed Jul 23, 2023
1 parent edea14f commit 1682c18
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 87 deletions.
15 changes: 9 additions & 6 deletions src/pages/user/popups/modules/edit/choice.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
import React from "react";
import PropTypes from "prop-types";
import Button from "components/shared/button/button";
import React from 'react';
import PropTypes from 'prop-types';
import Button from 'components/shared/button/button';

const Choice = ({ setPath }) => {
return (
<div className="wrapper">
<Button className="btn" onClick={() => setPath("add")}>
<Button className="btn" onClick={() => setPath('add')}>
Добавить
</Button>
<Button className="btn-flat" onClick={() => setPath("edit")}>
<Button className="btn" onClick={() => setPath('remove')}>
Вычесть
</Button>
<Button className="btn-flat" onClick={() => setPath('edit')}>
Редактировать
</Button>
</div>
);
};

Choice.propTypes = {
setPath: PropTypes.func.isRequired
setPath: PropTypes.func.isRequired,
};

export default Choice;
6 changes: 6 additions & 0 deletions src/pages/user/popups/modules/edit/edit.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

.wrapper {
display: flex;
flex-direction: column;
gap: 15px;
align-items: center;
justify-content: space-between;
margin: 10px 0;
Expand All @@ -13,6 +15,10 @@
margin-right: 15px;
cursor: pointer;
}

button + button {
margin: 0;
}
}

.input-field {
Expand Down
10 changes: 5 additions & 5 deletions src/pages/user/popups/modules/edit/removeCustom.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from "react";
import PropTypes from "prop-types";
import PopupForm from "../form";
import React from 'react';
import PropTypes from 'prop-types';
import PopupForm from '../form';

const RemoveCustomCashValue = ({ setPath, onChange }) => {
return (
<PopupForm
className="wrapper"
onBack={() => setPath("remove")}
onChange={(count) => onChange("remove", count)}
onBack={() => setPath(null)}
onChange={(count) => onChange('remove', count)}
title="Вычесть"
/>
);
Expand Down
20 changes: 0 additions & 20 deletions src/pages/user/popups/modules/editCaptcha/index.js

This file was deleted.

35 changes: 0 additions & 35 deletions src/pages/user/popups/modules/editCaptcha/modules/addDefault.js

This file was deleted.

14 changes: 8 additions & 6 deletions src/pages/user/popups/modules/editCash/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import React, { useState } from "react";
import AddDefaultValue from "./modules/addDefault";
import AddCustomValue from "../edit/addCustom";
import SetCustomValue from "../edit/setCustom";
import Choice from "../edit/choice";
import React, { useState } from 'react';
import AddDefaultValue from './modules/addDefault';
import AddCustomValue from '../edit/addCustom';
import RemoveCustomValue from '../edit/removeCustom';
import SetCustomValue from '../edit/setCustom';
import Choice from '../edit/choice';

const CashPopup = ({ ...rest }) => {
const [path, setPath] = useState(null);
const components = {
add: AddDefaultValue,
remove: RemoveCustomValue,
edit: SetCustomValue,
addCustom: AddCustomValue,
default: Choice,
};
const Component = components[path || "default"];
const Component = components[path || 'default'];

return <Component setPath={setPath} {...rest} />;
};
Expand Down
23 changes: 8 additions & 15 deletions src/pages/users/modules/listItem.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { useHistory } from "react-router-dom";
import PropTypes from "prop-types";
import "./listItem.scss";
import React from 'react';
import { useHistory } from 'react-router-dom';
import PropTypes from 'prop-types';
import './listItem.scss';

const User = ({ user }) => {
const history = useHistory();
Expand All @@ -12,16 +12,10 @@ const User = ({ user }) => {

return (
<div className="list-item" onClick={clickHandler}>
<img
className="list-item__icon"
src={`/images/${user.network}.png`}
alt="icon"
/>
<img className="list-item__icon" src={`/images/${user.network}.png`} alt="icon" />
<div className="list-item__title">
<div className="list-item__name">{user.name}</div>
{user.email ? (
<div className="list-item__email">({user.email})</div>
) : null}
{user.email ? <div className="list-item__email">({user.email})</div> : null}
</div>
<div className="list-item__cash">{user.cash} руб.</div>
</div>
Expand All @@ -32,10 +26,9 @@ User.propTypes = {
user: PropTypes.shape({
id: PropTypes.number.isRequired,
name: PropTypes.string.isRequired,
email: PropTypes.string.isRequired,
network: PropTypes.string.isRequired,
cash: PropTypes.number.isRequired
})
cash: PropTypes.number.isRequired,
}),
};

export default User;

0 comments on commit 1682c18

Please sign in to comment.