Skip to content

Commit

Permalink
change some style and fix a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pourya-asrzad committed Feb 13, 2023
1 parent 1f1c840 commit f9287dc
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/components/header-search/HeaderSearch.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
}
.headersearchinput:focus-visible{
border: none;
outline-color: #c5bfbf;
}
@media (max-width:795px){
.headersearchinput{
Expand Down
5 changes: 3 additions & 2 deletions src/components/tabel/Tr.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@ import Button from 'react-bootstrap/Button';
import { compareAsc, format, newDate } from 'date-fns-jalali'
import { useDispatch } from 'react-redux';
import { uiActions } from '../../store/ui-slice';
import { getDateToJalaliFormat } from '../../utils/functions.utils';
import { getDateToJalaliFormat, numberWithCommas } from '../../utils/functions.utils';

const TrComponent = ({ username, OrderRegistrationTime, prices, lastname, setModalShow, id }) => {
const dispatch = useDispatch()
const jalaliDate = getDateToJalaliFormat(OrderRegistrationTime)
function showModalHandeling(dataId) {
dispatch(uiActions.showOrderMenu(dataId))
}
const pricesWithComma = numberWithCommas(prices)
return (
<tr>
<td>
<Button id={id} onClick={(e) => showModalHandeling(e.target.id)} variant="primary">بررسی سفارش</Button>
</td>
<td>{jalaliDate}</td>
<td>{prices}</td>
<td>{pricesWithComma}</td>
<td>{username + " " + lastname} </td>
</tr>
);
Expand Down
4 changes: 3 additions & 1 deletion src/configs/variables.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const API_BASE_URL =
process.env.REACT_APP_BASE_API || "http://localhost:3001/";
export const username = JSON.parse(localStorage.getItem("userinfo")).username;
export const username =
localStorage.getItem("userinfo") &&
JSON.parse(localStorage.getItem("userinfo")).username;
2 changes: 0 additions & 2 deletions src/hooks/useLocalStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export function useLocalStorage(key, initialValue) {
return item ? JSON.parse(item) : initialValue;
} catch (error) {
// If error also return initialValue
console.log(error);
return initialValue;
}
});
Expand All @@ -34,7 +33,6 @@ export function useLocalStorage(key, initialValue) {
}
} catch (error) {
// A more advanced implementation would handle the error case
console.log(error);
}
};
return [storedValue, setValue];
Expand Down
3 changes: 1 addition & 2 deletions src/layouts/header/header.layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ const Header = () => {
const [notification, setNotification] = useState(0)
useEffect(() => {
let cartSum = 0
console.log("I'm notification")
axios.get(`${API_BASE_URL}mockusers?username=${username}`).then((res) => {
res.data && res.data[0].cart.map((product) => {
res.data && res.data[0].cart && res.data[0].cart.map((product) => {
cartSum += product.count
})
setNotification(cartSum)
Expand Down
4 changes: 2 additions & 2 deletions src/pages/cart/cart.page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ const Cart = () => {
const [afterChange, setAfterChange] = useState()
const [changeinCount, setChangeinCount] = useState()
const { data, isLoading, isError, isSuccess } = useFetchCartProductQuery({ afterChange, changeinCount })
// let userData = data && data[0].cart

const [userData, setUserData] = useState()
// let prices = 0;

const [cartSum, setCartSum] = useState()
const [prices, setPrices] = useState(0);
useEffect(() => {
Expand Down
10 changes: 9 additions & 1 deletion src/pages/home/home.page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@ import ProductionContainer from "./production-card-home-container/ProductionCont
import { getAppTitle } from "../../utils/functions.utils";
import SecondCategory from "./second-category/SecondCategory.component";
import ProductionScroller from "../../components/productions-scroller/ProductionScroller";
import { useEffect } from "react";



const Home = () => {


const appTitle = getAppTitle()

useEffect(() => {
localStorage.setItem('userinfo',
JSON.stringify({
username: 'puria-asr',
id: 1
})
)
}, [])

return (
<>
Expand Down

0 comments on commit f9287dc

Please sign in to comment.