This commit is contained in:
pawan-dot 2022-08-09 16:43:28 +05:30
parent 70e20f4ca8
commit 518502f62b
22 changed files with 53 additions and 37 deletions

View File

@ -43,9 +43,9 @@ const App = () => {
Authorization: `Bearer ${token}`,
},
})
//console.log(response)
// console.log(response.data)
const data = response.data
if (data.success) {
if (data.success && data.user.role === 'admin') {
setUserData(data.user);
} else {
@ -77,10 +77,10 @@ const App = () => {
{/* <Route path="/" name="Home" render={(props) => (
userdata && userdata?._id ? <DefaultLayout {...props} /> :
<Route path="/" name="Home" render={(props) => (
userdata?.role === "admin" ? <DefaultLayout {...props} /> :
userdata === false ? <Login {...props} /> : <div></div>
)} /> */}
)} />
<Route path="/" name="Home" render={(props) => <DefaultLayout {...props} />} />

View File

@ -6,7 +6,7 @@ const AppFooter = () => {
<CFooter>
<div>
<span className="ms-1">{new Date().getFullYear()} &copy; CMP.</span>
<span className="ms-1">{new Date().getFullYear()} &copy; Sales Champions.</span>
</div>
</CFooter>

View File

@ -32,7 +32,7 @@ const AppHeader = () => {
<CIcon icon={cilMenu} size="lg" />
</CHeaderToggler>
<CHeaderBrand className="mx-auto d-md-none" to="/">
<h1>CMP</h1>
<h2>Sales Champions</h2>
</CHeaderBrand>
<CHeaderNav className="d-none d-md-flex me-auto">
<CNavItem>

View File

@ -31,7 +31,7 @@ const AppSidebar = () => {
>
<CSidebarBrand className="d-none bg-info d-md-flex" to="/">
{/* <CIcon className="sidebar-brand-full" icon={logoNegative} height={35} /> */}
<h1>CMP</h1>
<h3>Sales Champions</h3>
{/* <CIcon className="sidebar-brand-narrow" height={35} /> */}
<CIcon className="sidebar-brand-narrow" icon={sygnet} height={35} />
</CSidebarBrand>

View File

@ -11,8 +11,8 @@ import store from './store'
import axios from 'axios'
const setupAxios = () => {
axios.defaults.baseURL = 'https://cms-api-dashboard.herokuapp.com/';
// axios.defaults.baseURL = 'http://localhost:5000'
// axios.defaults.baseURL = 'https://cms-api-dashboard.herokuapp.com/';
axios.defaults.baseURL = 'http://localhost:5000'
axios.defaults.headers = {
'Cache-Control': 'no-cache,no-store',
'Pragma': 'no-cache',

View File

@ -185,7 +185,7 @@ const AddBanner = () => {
<option value="1">--Select SubCategory--</option>
{category.map((item, index) => (
<option value={item.name}>{item.name}</option>
<option key={index} value={item.name}>{item.name}</option>
))}
{/* <option value="6">--select--</option> */}

View File

@ -106,7 +106,7 @@ function banner() {
</thead>
<tbody>
{banner && banner.map((item, index) =>
<tr>
<tr key={index}>
<td>{item?.title}</td>
<td>
<img src={`${item?.image.url}`} width="50" alt="" /></td>

View File

@ -200,7 +200,7 @@ const EditBanner = () => {
<option value="1">--Select SubCategory--</option>
{category.map((item, index) => (
<option value={item.name}>{item.name}</option>
<option key={index} value={item.name}>{item.name}</option>
))}
{/* <option value="6">--select--</option> */}

View File

@ -126,7 +126,7 @@ function Products() {
</thead>
<tbody>
{category && category.map((item, index) =>
<tr>
<tr key={index}>
<td>{item?.name}</td>
<td>
<img src={`${item?.image.url}`} width="50" alt="" /></td>

View File

@ -385,8 +385,8 @@ const Add_Business = () => {
className="form-control input-field"
>
<option value="">--select--</option>
{categoryName && categoryName.map(item =>
<option>{item?.name}</option>
{categoryName && categoryName.map((item, index) =>
<option key={index}>{item?.name}</option>
)}
</select>

View File

@ -102,9 +102,9 @@ const Bisuness = () => {
</tr>
</thead>
<tbody>
{bisuness.map((item) =>
{bisuness.map((item, index) =>
<tr>
<tr key={index}>
<td>{item?.name} </td>
<td>{item?.category}</td>
<td>{item?.city}</td>

View File

@ -398,8 +398,8 @@ const EditBisuness = () => {
className="form-control input-field"
>
<option value="">--select--</option>
{categoryName && categoryName.map(item =>
<option>{item?.name}</option>
{categoryName && categoryName.map((item, index) =>
<option key={index}>{item?.name}</option>
)}
</select>

View File

@ -25,7 +25,7 @@ const View_Bisuness = () => {
},
}
);
console.log(res.data.directory)
// console.log(res.data.directory)
setBisuness(res.data.directory)
// changeState({
// ...res.data,

View File

@ -21,7 +21,7 @@ function Event() {
},
}
);
console.log(res.data)
// console.log(res.data)
setEvent(res.data.Event)
@ -108,7 +108,7 @@ function Event() {
</thead>
<tbody>
{event && event.map((item, index) =>
<RegisterUser item={item} handleDelete={handleDelete} formatAMPM={formatAMPM} />
<RegisterUser key={index} item={item} handleDelete={handleDelete} formatAMPM={formatAMPM} />
)}
</tbody>
</table>

View File

@ -9,7 +9,6 @@ import { isAutheticated } from "../../auth";
function ViewEvent() {
const [event, setEvent] = useState([])
const { id } = useParams();
console.log(id)
const token = isAutheticated();
const getEvent = useCallback(async () => {

View File

@ -103,7 +103,7 @@ function News() {
</thead>
<tbody>
{news && news.map((item, index) =>
<tr>
<tr key={index}>
<td>{item?.title}</td>
<td>
<img src={`${item?.image.url}`} width="50" alt="" /></td>

View File

@ -9,7 +9,6 @@ import { isAutheticated } from "../../auth";
function ViewNews() {
const [news, setNews] = useState([])
const { id } = useParams();
console.log(id)
const token = isAutheticated();
const getNews = useCallback(async () => {
@ -21,7 +20,7 @@ function ViewNews() {
},
}
);
console.log(res.data.news)
setNews(res.data.news)

View File

@ -173,8 +173,8 @@ const AddOffer = () => {
>
<option value="1">--select--</option>
{bisunessName.map(item =>
<option>{item?.name}</option>
{bisunessName.map((item, index) =>
<option key={index}>{item?.name}</option>
)}
</select>

View File

@ -180,8 +180,8 @@ const EditOffer = () => {
>
<option value="1">--select--</option>
{bisunessName.map(item =>
<option>{item?.name}</option>
{bisunessName.map((item, index) =>
<option key={index}>{item?.name}</option>
)}
</select>

View File

@ -98,7 +98,7 @@ function Offer() {
</thead>
<tbody>
{offer && offer.map((item, index) =>
<tr>
<tr key={index}>
<td>{item?.title}</td>
<td>

View File

@ -9,7 +9,6 @@ import { isAutheticated } from "../../auth";
function ViewOffer() {
const [offer, setOffer] = useState([])
const { id } = useParams();
console.log(id)
const token = isAutheticated();
const getOffer = useCallback(async () => {

View File

@ -42,9 +42,23 @@ const Login = () => {
const res = await axios.post("/api/v1/user/login/", auth);
if (res.data.success == true) {
localStorage.setItem("authToken", res.data.token)
history.push('/dashboard')
setLoading(false);
window.location.reload()
let response = await axios.get(`/api/v1/user/details`, {
headers: {
Authorization: `Bearer ${res.data.token}`,
},
})
// console.log(response.data)
const data = response.data
if (data.user.role === 'admin') {
history.push('/dashboard')
setLoading(false);
window.location.reload()
}
else {
alert("please try with admin credential!!")
setLoading(false);
}
}
@ -70,7 +84,7 @@ const Login = () => {
<CCardBody>
<CForm>
<h1>Login</h1>
<p className="text-medium-emphasis">Sign In to Your CMP Dashboard Account.</p>
<p className="text-medium-emphasis">Sign In to Your Sales Champions Dashboard Account.</p>
<CInputGroup className="mb-3">
<CInputGroupText>
<CIcon icon={cilUser} />
@ -129,3 +143,8 @@ const Login = () => {
}
export default Login
// < Route path = "/" name = "Home" render = {(props) => (
// userdata && userdata.role === 'admin' ? <DefaultLayout {...props} /> :
// <><Login {...props} /></>
// )} />