-
Notifications
You must be signed in to change notification settings - Fork 0
Rifaq expense list feature #6
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| .add-form { | ||
| background: #71ccca; | ||
| box-shadow: 20px 20px 60px #60adac, -20px -20px 60px #82ebe8; | ||
| margin: 6px 12px; | ||
| padding: 24px; | ||
| display: flex; | ||
| flex-direction: column; | ||
| flex: 1; | ||
| height: 60vh; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. group the css |
||
| } | ||
| .form-item { | ||
| margin: 12px 0px; | ||
| width: 70%; | ||
| padding: 4px; | ||
| border-radius: 6px; | ||
| background-color: white; | ||
| } | ||
| .form-item label { | ||
| background-color: lightgrey; | ||
| padding: 2px 12px; | ||
| border-radius: 0px 4px 4px 0px; | ||
| } | ||
| .form-item input { | ||
| font-size: 16px; | ||
| border: none; | ||
| width: 70%; | ||
| outline: none; | ||
| } | ||
| .category-container-parent { | ||
| display: flex; | ||
| flex-direction: column; | ||
| flex: 1; | ||
| } | ||
| .category { | ||
| position: relative; | ||
| width: 40%; | ||
| } | ||
| .category-dropdown { | ||
| display: flex; | ||
| justify-content: space-between; | ||
| align-items: center; | ||
| margin: 12px 0px; | ||
| background-color: white; | ||
| border-radius: 6px; | ||
| padding: 4px; | ||
| } | ||
| .category-dropdown i { | ||
| display: flex; | ||
| align-items: center; | ||
| } | ||
|
|
||
| .category-container { | ||
| display: flex; | ||
| position: absolute; | ||
| width: 100%; | ||
| flex-direction: column; | ||
| background: #ffffff; | ||
| } | ||
|
|
||
| .category-item { | ||
| width: 98%; | ||
| display: flex; | ||
| justify-content: space-between; | ||
| padding: 8px 0px; | ||
| cursor: pointer; | ||
| } | ||
| .category-item img { | ||
| height: 32px; | ||
| margin-right: 20px; | ||
| } | ||
|
|
||
| .form-add-button { | ||
| display: flex; | ||
| justify-content: flex-end; | ||
| } | ||
| .form-add-button div { | ||
| display: flex; | ||
| border: 1px solid black; | ||
| padding: 2px 8px; | ||
| border-radius: 6px; | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| .form-add-button div i { | ||
| display: flex; | ||
| align-items: center; | ||
| margin-left: 6px; | ||
| } | ||
|
|
||
| @media only screen and (max-width: 1024px) { | ||
| .form-item { | ||
| width: 100%; | ||
| } | ||
| .form-item input { | ||
| width: 70%; | ||
| } | ||
| .amount-input { | ||
| width: 50% !important; | ||
| } | ||
| .category { | ||
| width: 80%; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,113 @@ | ||||||
| import React, { useState } from "react"; | ||||||
| import { categories } from "../../constants/add-expense"; | ||||||
| import "react-toastify/dist/ReactToastify.css"; | ||||||
| import "./add-form.css"; | ||||||
| import { toast, ToastContainer } from "react-toastify"; | ||||||
| import { useDispatch } from "react-redux"; | ||||||
| import { addExpense } from "./../../redux/action/expenses"; | ||||||
| import SuccessModal from "./success-modal"; | ||||||
|
|
||||||
| const AddForm = () => { | ||||||
| const [categoryOpen, setCategoryOpen] = useState(false); | ||||||
| const cat = categories; | ||||||
| const [title, setTitle] = useState(""); | ||||||
| const [amount, setAmount] = useState(""); | ||||||
| const [category, setCategory] = useState(); | ||||||
| const dispatch = useDispatch(); | ||||||
| const [modalOpen, setModalOpen] = useState(false); | ||||||
| const handleTitle = (e) => { | ||||||
| setTitle(e.target.value); | ||||||
| }; | ||||||
| const handleAmount = (e) => { | ||||||
| const val = parseFloat(e.target.value); | ||||||
| if (isNaN(val)) { | ||||||
| setAmount(""); | ||||||
| return; | ||||||
| } | ||||||
| setAmount(val); | ||||||
| }; | ||||||
| const handleCategory = (category) => { | ||||||
| setCategory(category); | ||||||
| setCategoryOpen(false); | ||||||
| }; | ||||||
|
|
||||||
| const handleSubmit = () => { | ||||||
| if (title === "" || amount === "" || !category) { | ||||||
| const notify = () => toast("Please enter complete data"); | ||||||
| notify(); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cant we directly call |
||||||
| return; | ||||||
| } | ||||||
| const data = { | ||||||
| title, | ||||||
| amount, | ||||||
| category, | ||||||
| createdAt: new Date(), | ||||||
| }; | ||||||
| dispatch(addExpense(data)); | ||||||
| setModalOpen(!modalOpen); | ||||||
| }; | ||||||
|
|
||||||
| return ( | ||||||
| <div className="add-form"> | ||||||
| <SuccessModal modalOpen={modalOpen} /> | ||||||
| <ToastContainer | ||||||
| position="bottom-left" | ||||||
| autoClose={1500} | ||||||
| hideProgressBar={false} | ||||||
| newestOnTop={false} | ||||||
| closeOnClick | ||||||
| /> | ||||||
| <div className="form-item"> | ||||||
| <label>Title</label> | ||||||
| <input | ||||||
| placeholder="Give a name to your expenditure" | ||||||
| value={title} | ||||||
| onChange={(e) => handleTitle(e)} | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| /> | ||||||
| </div> | ||||||
| <div className="form-item"> | ||||||
| <label>Amount ₹</label> | ||||||
| <input | ||||||
| placeholder="Enter Amount" | ||||||
| className="amount-input" | ||||||
| onChange={(e) => handleAmount(e)} | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| value={amount} | ||||||
| /> | ||||||
| </div> | ||||||
| <div className="category-container-parent"> | ||||||
| <div className="category"> | ||||||
| <div | ||||||
| className="category-dropdown" | ||||||
| onClick={() => setCategoryOpen(!categoryOpen)} | ||||||
| > | ||||||
| <label>{category ? category.title : "Category"}</label> | ||||||
| <i className="fas fa-chevron-down"></i> | ||||||
| </div> | ||||||
| {categoryOpen && ( | ||||||
| <div className="category-container"> | ||||||
| {cat.map((category) => ( | ||||||
| <div | ||||||
| className="category-item" | ||||||
| style={{ borderRight: `5px solid ${category.color}` }} | ||||||
| key={category.id} | ||||||
| onClick={() => handleCategory(category)} | ||||||
| > | ||||||
| <label>{category.title}</label> | ||||||
| <img src={category.icon.default} alt={category.title} /> | ||||||
| </div> | ||||||
| ))} | ||||||
| </div> | ||||||
| )} | ||||||
| </div> | ||||||
| </div> | ||||||
| <div className="form-add-button"> | ||||||
| <div onClick={handleSubmit}> | ||||||
| <label>Add</label> | ||||||
| <i className="fab fa-telegram-plane" /> | ||||||
| </div> | ||||||
| </div> | ||||||
| </div> | ||||||
| ); | ||||||
| }; | ||||||
|
|
||||||
| export default AddForm; | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| .modal-inner { | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| } | ||
| .added-image { | ||
| height: 360px; | ||
| } | ||
|
|
||
| .take-home-button { | ||
| border: 1px solid black; | ||
| padding: 4px 8px; | ||
| border-radius: 6px; | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| } | ||
| .take-home-button i { | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| margin-right: 6px; | ||
| } | ||
|
|
||
| @media only screen and (max-width: 1024px) { | ||
| .added-image { | ||
| height: 320px; | ||
| } | ||
| } | ||
| @media only screen and (max-width: 512px) { | ||
| .added-image { | ||
| height: 240px; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prettier setting ?