Skip to content

Commit 12838da

Browse files
committed
bug fixed
1 parent f77f508 commit 12838da

File tree

12 files changed

+184
-113
lines changed

12 files changed

+184
-113
lines changed

src/Redux/Actions/SyllabusActions.jsx

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,53 @@
11
import AdminApi from "../../utils/ApiRouters/AdminApis";
22
import ApiRoutes from "../../utils/ApiRoutes";
33
import AxiosService from "../../utils/AxiosService";
4-
import { getSyllabusFail, getSyllabusRequest, getSyllabusSuccess, paidSyllabusFail, paidSyllabusRequest, paidSyllabusSuccess, syllabusFail, syllabusRequest, syllabusSuccess } from "../Slices/SyllabusSlicer";
4+
import {
5+
getSyllabusFail,
6+
getSyllabusRequest,
7+
getSyllabusSuccess,
8+
paidSyllabusFail,
9+
paidSyllabusRequest,
10+
paidSyllabusSuccess,
11+
syllabusFail,
12+
syllabusRequest,
13+
syllabusSuccess,
14+
} from "../Slices/SyllabusSlicer";
515

616
export const getSyllabus = (id) => async (dispatch) => {
7-
try {
8-
dispatch(syllabusRequest());
9-
const { data } = await AxiosService.get(`${ApiRoutes.GET_SYLLABUS_BY_COURSE_ID.path}/${id}`);
10-
dispatch(syllabusSuccess(data));
11-
} catch (error) {
12-
dispatch(syllabusFail(error.response.data.message));
13-
}
17+
try {
18+
dispatch(syllabusRequest());
19+
const { data } = await AxiosService.get(
20+
`${ApiRoutes.GET_SYLLABUS_BY_COURSE_ID.path}/${id}`
21+
);
22+
dispatch(syllabusSuccess(data));
23+
} catch (error) {
24+
dispatch(syllabusFail(error.response.data.message));
25+
}
1426
};
1527
export const getPaidSyllabus = (id) => async (dispatch) => {
16-
try {
17-
dispatch(paidSyllabusRequest());
18-
const { data } = await AxiosService.get(`${ApiRoutes.GET_PAID_SYLLABUS_BY_COURSE_ID.path}/${id}`);
19-
dispatch(paidSyllabusSuccess(data));
20-
} catch (error) {
21-
dispatch(paidSyllabusFail(error.response.data.message));
22-
}
28+
try {
29+
dispatch(paidSyllabusRequest());
30+
const { data } = await AxiosService.get(
31+
`${ApiRoutes.GET_PAID_SYLLABUS_BY_COURSE_ID.path}/${id}`
32+
);
33+
dispatch(paidSyllabusSuccess(data));
34+
} catch (error) {
35+
dispatch(paidSyllabusFail(error.response.data.message));
36+
}
2337
};
2438

2539
//Admin Actions
2640

27-
export const getSyllabusById = (id) => async(dispatch) =>{
28-
try {
29-
dispatch(getSyllabusRequest())
30-
const {data} = await AxiosService.get(`${AdminApi.SYLLABUS_BY_ID.path}/${id}`)
31-
dispatch(getSyllabusSuccess(data))
32-
} catch (error) {
33-
dispatch(getSyllabusFail(error.response.data.message))
34-
}
35-
}
41+
export const getSyllabusById = (id) => async (dispatch) => {
42+
try {
43+
dispatch(getSyllabusRequest());
44+
const { data } = await AxiosService.get(
45+
`${AdminApi.SYLLABUS_BY_ID.path}/${id}`
46+
);
47+
dispatch(getSyllabusSuccess(data));
48+
} catch (error) {
49+
dispatch(getSyllabusFail(error.response.data.message));
50+
}
51+
};
52+
53+

src/Redux/Actions/UserActions.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const clearAuthError = (dispatch) => {
3838
export const signup = (userData) => async (dispatch) => {
3939
try {
4040
dispatch(signupRequest());
41-
const { data } = await AxiosService.post(SIGN_UP.path, { userData });
41+
const { data } = await AxiosService.post(SIGN_UP.path, userData);
4242
dispatch(signupSuccess(data));
4343
} catch (error) {
4444
dispatch(signupFail(error.response.data.message));

src/Redux/Slices/AuthSlicer.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ const AuthSlicer = createSlice({
4242
signupSuccess(state, action) {
4343
return {
4444
loading: false,
45-
isAuthenticated: true,
4645
user: action.payload.user,
4746
};
4847
},

src/Redux/Slices/SyllabusSlicer.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ const syllabusSlicer = createSlice({
5656
error: action.payload,
5757
};
5858
},
59+
getSyllabusByCourseIdReq(state, action){
60+
return {
61+
...state,
62+
loading: true
63+
};
64+
}
5965
},
6066
});
6167

src/animation/EmailVerifyAnim.jsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@ import animationData from './json/SuccessAnimation.json'
44
import { toast } from 'react-toastify'
55
import AxiosService from '../utils/AxiosService'
66
import ApiRoutes from '../utils/ApiRoutes'
7+
import { useSelector } from 'react-redux'
8+
import { useNavigate } from 'react-router-dom'
79

810
const EmailVerifyAnim = () => {
11+
const navigate = useNavigate()
12+
const {user, isAuthenticated} = useSelector(state => state.authState)
13+
const email = sessionStorage.getItem('email')
914
const handleResendEmail = async () =>{
1015
const {email, name} = sessionStorage
1116
try {
@@ -30,6 +35,11 @@ const EmailVerifyAnim = () => {
3035
autoplay: true,
3136
});
3237
}, []); // Run the effect once when the component mounts
38+
useEffect(()=>{
39+
if(isAuthenticated && user){
40+
navigate("/")
41+
}
42+
},[isAuthenticated, user])
3343
return (
3444
<>
3545
{/* The container for the Lottie animation */}
@@ -39,6 +49,7 @@ const EmailVerifyAnim = () => {
3949
<h1>Verify Your Email</h1> <br />
4050
<p className="lh-1" >Please check your email for a link to verify your email adress</p>
4151
<p className="lh-1">Once verified, you'll be able to continue.</p>
52+
<p className="lh-1 text-primary">{email}</p>
4253
</div>
4354
{/* This is a animation */}
4455
<div id='animation-container' className='overflow-hidden' style={{height: '400px', width: '400px', position: "fixed", transition: "none"}}></div>

src/components/EditProfile.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const EditProfile = () => {
1313
const {user, error, loading} = useSelector(state => state.authState)
1414
const navigate = useNavigate()
1515
const [avatar, setAvatar] = useState("");
16-
const [avatarPreview, setAvatarPreview] = useState("../../public/defaultProfile.png");
16+
const [avatarPreview, setAvatarPreview] = useState("https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_1280.png");
1717

1818

1919
let [initialValues, setInitialValues] = useState(
@@ -23,7 +23,7 @@ const EditProfile = () => {
2323
email: "",
2424
gender: "",
2525
dob: "",
26-
}
26+
}
2727
)
2828

2929

@@ -87,7 +87,7 @@ useEffect(()=>{
8787
<div className="row">
8888
<div className="card-body col-md-4 border-right">
8989
<div className="d-flex flex-column align-items-center text-center p-3 py-5">
90-
<img className="rounded-circle user-profile-image mt-5 object-fit-cover" src={user && user.avatar ? user.avatar : "../../public/defaultProfile.png"} height="150" width="150" />
90+
<img className="rounded-circle user-profile-image mt-5 object-fit-cover" src={user && user.avatar ? user.avatar : "https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_1280.png"} height="150" width="150" />
9191
<span className="font-weight-bold text-light">{user && user.name}</span>
9292
<span className="text-primary">{user && user.email}</span>
9393
{/* <span>United States</span> */}
@@ -167,7 +167,7 @@ useEffect(()=>{
167167
</figure>
168168
</div>
169169
<div className='custom-file'>
170-
<input type='file' name='avatar' className='custom-file-input' id='customFile' accept='image/' onChange={onChangeAvatar}/>
170+
<input type='file' name='avatar' className='custom-file-input' id='customFile' accept='image/*' onChange={onChangeAvatar}/>
171171
<label className='custom-file-label col-form-label' htmlFor='customFile'>Choose Avatar</label>
172172
</div>
173173
</div>

0 commit comments

Comments
 (0)