-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
73 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,14 @@ | ||
from django.conf.urls import url, include | ||
from allauth.account.views import ConfirmEmailView, LoginView | ||
from django.urls import path | ||
from . import views | ||
from .views import FacebookLogin | ||
|
||
urlpatterns = [ | ||
# Override urls | ||
url(r'^registration/account-email-verification-sent/', | ||
views.null_view, name='account_email_verification_sent'), | ||
path('login/', LoginView.as_view(), name='account_login'), | ||
path('auth/registration/', LoginView.as_view(), name='account_signup'), | ||
url(r'^registration/account-confirm-email/(?P<key>[-:\w]+)/$', | ||
ConfirmEmailView.as_view(), name='account_confirm_email'), | ||
url(r'^registration/complete/$', views.complete_view, | ||
name='account_confirm_complete'), | ||
url(r'^password-reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', | ||
views.null_view, name='password_reset_confirm'), | ||
# Default urls | ||
path('facebook/', FacebookLogin.as_view(), name='fb_login') | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,74 @@ | ||
import { authAxios } from '../utils' | ||
import { orderSummaryURL, removeFromCartURL, addToCartURL } from '../constants'; | ||
import { authAxios } from "../utils"; | ||
import { orderSummaryURL, removeFromCartURL, addToCartURL } from "../constants"; | ||
|
||
export const FETCH_CART = 'FETCH_CART'; | ||
export const CART_START = 'CART_START'; | ||
export const CART_FAIL = 'CART_FAIL'; | ||
export const ERROR = 'ERROR'; | ||
export const SUCCESS_MESSAGE = 'SUCCESS_MESSAGE'; | ||
export const SIGN_IN_TO_ADD_ITEMS = 'SIGN_IN_TO_ADD_ITEMS' | ||
export const FETCH_CART = "FETCH_CART"; | ||
export const CART_START = "CART_START"; | ||
export const CART_FAIL = "CART_FAIL"; | ||
export const ERROR = "ERROR"; | ||
export const SUCCESS_MESSAGE = "SUCCESS_MESSAGE"; | ||
export const SIGN_IN_TO_ADD_ITEMS = "SIGN_IN_TO_ADD_ITEMS"; | ||
|
||
export const signInToAddItems = dispatch => { | ||
dispatch({ | ||
type: SIGN_IN_TO_ADD_ITEMS, | ||
payload: 'Sign In to add items to the cart' | ||
}) | ||
} | ||
|
||
export const fetchCart = (cb) => dispatch => { | ||
authAxios.get(orderSummaryURL) | ||
.then(res => { | ||
dispatch({ | ||
type: FETCH_CART, | ||
payload: res.data | ||
}) | ||
if (typeof cb === "function") cb(); | ||
}) | ||
.catch(error => { | ||
if (error.response !== undefined) { | ||
console.log(error.response.data) | ||
} | ||
export const signInToAddItems = (dispatch) => { | ||
dispatch({ | ||
type: SIGN_IN_TO_ADD_ITEMS, | ||
payload: "Sign In to add items to the cart", | ||
}); | ||
}; | ||
|
||
console.log(error) | ||
|
||
dispatch({ | ||
type: CART_FAIL, | ||
}) | ||
}) | ||
export const fetchCart = (cb) => (dispatch) => { | ||
authAxios | ||
.get(orderSummaryURL) | ||
.then((res) => { | ||
dispatch({ | ||
type: FETCH_CART, | ||
payload: res.data, | ||
}); | ||
if (typeof cb === "function") cb(); | ||
}) | ||
.catch((error) => { | ||
if (error.response !== undefined) { | ||
console.log(error.response.data); | ||
} | ||
|
||
} | ||
console.log(error.response); | ||
|
||
dispatch({ | ||
type: CART_FAIL, | ||
}); | ||
}); | ||
}; | ||
|
||
export const addToCart = (slug, cb) => dispatch => { | ||
authAxios.post(addToCartURL, { | ||
slug: slug | ||
export const addToCart = (slug, cb) => (dispatch) => { | ||
authAxios | ||
.post(addToCartURL, { | ||
slug: slug, | ||
}) | ||
.then(res => { | ||
fetchCart(); | ||
dispatch({ | ||
type: SUCCESS_MESSAGE, | ||
payload: res.data.message | ||
}) | ||
cb(); | ||
}) | ||
.catch(error => { | ||
if (error.response !== undefined) { | ||
dispatch({ | ||
type: ERROR, | ||
payload: error.response.data.errormessage | ||
}) | ||
} | ||
else console.log(error) | ||
}) | ||
} | ||
|
||
|
||
export const removeCart = id => { | ||
authAxios.delete(removeFromCartURL + `${id}/delete/`) | ||
.then(res => { | ||
console.log(res); | ||
fetchCart(); | ||
}) | ||
.catch(err => { | ||
console.log(err); | ||
}) | ||
} | ||
.then((res) => { | ||
fetchCart(); | ||
dispatch({ | ||
type: SUCCESS_MESSAGE, | ||
payload: res.data.message, | ||
}); | ||
cb(); | ||
}) | ||
.catch((error) => { | ||
if (error.response !== undefined) { | ||
dispatch({ | ||
type: ERROR, | ||
payload: error.response.data.errormessage, | ||
}); | ||
} else console.log(error); | ||
}); | ||
}; | ||
|
||
export const removeCart = (id) => { | ||
authAxios | ||
.delete(removeFromCartURL + `${id}/delete/`) | ||
.then((res) => { | ||
console.log(res); | ||
fetchCart(); | ||
}) | ||
.catch((err) => { | ||
console.log(err); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters