Skip to content

Commit 19ed017

Browse files
authored
fix currency && toast && style (#74)
* [Finishes #187584877] Admin should be able to disable an account * [Delivers #187584880]Users should be able to chat
1 parent 4613391 commit 19ed017

15 files changed

+161
-221
lines changed

Diff for: src/assets/styles/Header.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ a {
382382
left: -10%;
383383
padding-right: 10px;
384384
top: 150%;
385-
width: 135%;
385+
width: 145%;
386386
z-index: 500;
387387
box-shadow: 0 5rem 10rem 0 rgba(0, 0, 0, 0.08);
388388

Diff for: src/assets/styles/LandingPage.scss

+3-63
Original file line numberDiff line numberDiff line change
@@ -94,44 +94,29 @@
9494
}
9595

9696
.span {
97-
width: 20rem;
97+
width: 25rem;
9898
}
9999
}
100100

101101
input[type="range"] {
102102
-webkit-appearance: none;
103103
width: 100%;
104104
height: 8px;
105-
background: #ddd;
105+
background: $white-color;
106106
border-radius: 5px;
107107
outline: none;
108108
}
109109

110-
input[type="range"]::-webkit-slider-runnable-track {
111-
width: 100%;
112-
height: 8px;
113-
cursor: pointer;
114-
background: #ddd;
115-
border-radius: 5px;
116-
}
117-
118110
input[type="range"]::-webkit-slider-thumb {
119111
-webkit-appearance: none;
112+
appearance: none;
120113
height: 20px;
121114
width: 20px;
122115
background: #ff6d18;
123116
border-radius: 50%;
124-
margin-top: -6px;
125117
cursor: pointer;
126118
}
127119

128-
input[type="range"]::-moz-range-track {
129-
width: 100%;
130-
height: 8px;
131-
background: #ddd;
132-
border-radius: 5px;
133-
cursor: pointer;
134-
}
135120

136121
input[type="range"]::-moz-range-thumb {
137122
height: 20px;
@@ -141,51 +126,6 @@
141126
cursor: pointer;
142127
}
143128

144-
input[type="range"]::-ms-track {
145-
width: 100%;
146-
height: 5px;
147-
cursor: pointer;
148-
background: transparent;
149-
border-color: transparent;
150-
color: transparent;
151-
}
152-
153-
input[type="range"]::-ms-fill-lower {
154-
background: #ddd;
155-
border-radius: 5px;
156-
}
157-
158-
input[type="range"]::-ms-fill-upper {
159-
background: #ddd;
160-
border-radius: 5px;
161-
}
162-
163-
input[type="range"]::-ms-thumb {
164-
height: 10px;
165-
width: 10px;
166-
background: #ff6d18;
167-
border-radius: 50%;
168-
cursor: pointer;
169-
margin-top: 0;
170-
}
171-
172-
input[type="range"]:focus {
173-
outline: none;
174-
}
175-
176-
input[type="range"]:hover::-webkit-slider-runnable-track {
177-
background: #ccc;
178-
}
179-
180-
input[type="range"]:hover::-moz-range-track {
181-
background: #ccc;
182-
}
183-
184-
input[type="range"]:hover::-ms-fill-lower,
185-
input[type="range"]:hover::-ms-fill-upper {
186-
background: #ccc;
187-
}
188-
189129
.product-list {
190130
display: grid;
191131
justify-items: center;

Diff for: src/assets/styles/Sample.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
color: $white;
55
background-color: $white;
66
gap: 1rem;
7-
height: 40rem;
7+
height: 35rem;
88

99
.sample1, .sample3 {
1010
flex: 1;
1111
display: flex;
1212
flex-direction: column;
1313
width: 20%;
14-
height: 40rem;
14+
height: 35rem;
1515
gap: 1rem;
1616
}
1717

Diff for: src/components/GoogleCallback.tsx

+8-5
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,22 @@ import { googleAuthCallback } from '../store/features/auth/authSlice';
55
import { useNavigate } from 'react-router-dom';
66
import { HashLoader } from 'react-spinners';
77
import { toast } from 'react-toastify';
8+
import { resetAuth } from '../store/features/auth/authSlice';
89

910
const GoogleCallback = () => {
1011
const dispatch = useAppDispatch();
1112
const navigate = useNavigate();
12-
const { isLoading, isSuccess, isError, message ,token} = useAppSelector((state) => state.auth);
13-
13+
const { isLoading, isSuccess,isAuthenticated , isError, message ,token} = useAppSelector((state) => state.auth);
1414
const urlParams = new URLSearchParams(window.location.search);
1515
const code = urlParams.get('code');
1616
const scope = urlParams.get('scope');
1717
const authuser = urlParams.get('authuser');
1818
const prompt = urlParams.get('prompt');
1919

20+
21+
useEffect(() => {
22+
dispatch(resetAuth());
23+
}, [dispatch]);
2024
useEffect(() => {
2125
if (code && scope && authuser && prompt) {
2226
dispatch(googleAuthCallback({ code, scope, authuser, prompt }));
@@ -27,18 +31,17 @@ const GoogleCallback = () => {
2731
}, [code, scope, authuser, prompt, dispatch]);
2832

2933
useEffect(() => {
30-
if (isSuccess) {
34+
if (isSuccess && isAuthenticated) {
3135
localStorage.setItem("token", token);
3236
navigate("/home");
3337
}
3438
if (isError) {
35-
toast.error(message);
3639
navigate("/login");
3740
}
3841
}, [isSuccess, isError, message, navigate]);
3942

4043
return (
41-
<div className="google-callback">
44+
<div className="google-callback" style={{height:"100vh" , width:"100vw"}}>
4245
{isLoading && (
4346
<div style={{display:'flex',justifyContent:'center',alignItems:'center', flexDirection:'column', height:"90vh", gap:"2rem"}}>
4447
<div className="btn-loading">

Diff for: src/components/inputs/SearchInput.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function SearchInput({ className, placeholder }: SearchInputProps) {
3737
e.preventDefault();
3838
if (search.trim()) {
3939
navigate(`/search?name=${search.trim()}`);
40+
setSearch("");
4041
}
4142
};
4243

Diff for: src/components/layout/Header.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@ const Header: React.FC = () => {
229229
<span className="cart__description">
230230
{isAuthenticated
231231
? cartTotalMoney !== null
232-
? `$${cartTotalMoney.toFixed(2)}`
233-
: '$0'
234-
: '$0'}
232+
? `${cartTotalMoney.toFixed(2)} RWF`
233+
: '0 RWF'
234+
: '0 RWF'}
235235
</span>
236236
</div>
237237
</div>

Diff for: src/components/product/Product.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ const Product: React.FC<ProductProps> = ({
194194
{name}
195195
</div>
196196
<div className="product-details">
197-
<p className="product-price">{price}</p>
197+
<p className="product-price">{price} RWF</p>
198198
<p className="product-stock">
199199
<span className="stock">Stock: </span>
200200
{stock}

Diff for: src/pages/LandingPage.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const LandingPage: React.FC = () => {
9494
id={product.id}
9595
images={product.images}
9696
name={product.name}
97-
price={`$${product.price}`}
97+
price={product.price}
9898
stock={Number(product.quantity)}
9999
description={product.description}
100100
discount={Number(product.discount.replace("%", ""))}

Diff for: src/pages/Products.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ const ProductsPage: React.FC = () => {
128128
setPriceRange([priceRange[0], Number(e.target.value)])
129129
}
130130
/>
131-
<span className="span">${priceRange[0]} - ${priceRange[1]}</span>
131+
<span className="span">{priceRange[0]}RWF - {priceRange[1]}RWF</span>
132132
</div>
133133
</div>
134134
<div className="product-list">
@@ -142,7 +142,7 @@ const ProductsPage: React.FC = () => {
142142
id={product.id}
143143
images={product.images}
144144
name={product.name}
145-
price={`$${product.price}`}
145+
price={product.price}
146146
stock={Number(product.quantity)}
147147
description={product.description}
148148
discount={Number(product.discount.replace("%", ""))}

Diff for: src/pages/Search.tsx

+12-13
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ const SearchBar: React.FC = () => {
6666
setMaxPriceOptions([{ label: 'Max', value: '' }, ...priceOptions]);
6767
}
6868

69-
const sortedDiscounts = Array.from(
70-
new Set(products.map((product: any) => { return typeof product.discount === 'string' ? Number(product.discount) : product.discount;}))
69+
const sortedDiscounts: any = Array.from(
70+
new Set(products.map((product: any) => product.discount))
7171
)
72-
.sort((a:number, b:number) => a - b)
73-
.map((discount) => ({ label: `${discount}`, value: String(discount) }));
74-
setDiscountOptions(sortedDiscounts);
72+
.sort((a:string, b:string) => parseInt(a) - parseInt(b))
73+
.map((discount) => ({ label: `${discount}`, value: discount }));
74+
setDiscountOptions([{ label: 'Discount', value: '' },...sortedDiscounts]);
7575
}
7676
}, [products]);
7777

@@ -119,21 +119,20 @@ const SearchBar: React.FC = () => {
119119
.sort((a:number, b:number) => a - b);
120120
setSelectPrice(sortedPrices);
121121

122-
const priceOptions = sortedPrices.map(price => ({ label: `$${price}`, value: price.toString() }));
122+
const priceOptions = sortedPrices.map(price => ({ label: `${price} RWF`, value: price.toString() }));
123123
setMinPriceOptions([{ label: 'Min', value: '' }, ...priceOptions]);
124124

125125
if (sortedPrices.length > 1) {
126126
setMaxPriceOptions([{ label: 'Max', value: '' }, ...priceOptions.slice(1)]);
127127
} else {
128128
setMaxPriceOptions([{ label: 'Max', value: '' }, ...priceOptions]);
129129
}
130-
131-
const sortedDiscounts = Array.from(
132-
new Set(filteredProducts.map((product: any) => { return typeof product.price === 'string' ? Number(product.price) : product.price;}))
130+
const sortedDiscounts: any = Array.from(
131+
new Set(products.map((product: any) => product.discount))
133132
)
134-
.sort((a:number, b:number) => a - b)
135-
.map((discount) => ({ label: `${discount}`, value: String(discount) }));
136-
setDiscountOptions([{label:'Discount', value: ''},...sortedDiscounts]);
133+
.sort((a:string, b:string) => parseInt(a) - parseInt(b))
134+
.map((discount) => ({ label: `${discount}`, value: discount }));
135+
setDiscountOptions([{ label: 'Discount', value: '' },...sortedDiscounts]);
137136
}
138137
}, [filteredProducts]);
139138

@@ -194,7 +193,7 @@ const SearchBar: React.FC = () => {
194193
id={product.id}
195194
images={product.images}
196195
name={product.name}
197-
price={`$${product.price}`}
196+
price={product.price}
198197
stock={Number(product.quantity)}
199198
description={product.description}
200199
discount={Number(product.discount.replace("%", ""))}

0 commit comments

Comments
 (0)