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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -42,9 +42,23 @@ const Login = () => {
const res = await axios.post("/api/v1/user/login/", auth); const res = await axios.post("/api/v1/user/login/", auth);
if (res.data.success == true) { if (res.data.success == true) {
localStorage.setItem("authToken", res.data.token) localStorage.setItem("authToken", res.data.token)
history.push('/dashboard') let response = await axios.get(`/api/v1/user/details`, {
setLoading(false); headers: {
window.location.reload() 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> <CCardBody>
<CForm> <CForm>
<h1>Login</h1> <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"> <CInputGroup className="mb-3">
<CInputGroupText> <CInputGroupText>
<CIcon icon={cilUser} /> <CIcon icon={cilUser} />
@ -129,3 +143,8 @@ const Login = () => {
} }
export default Login export default Login
// < Route path = "/" name = "Home" render = {(props) => (
// userdata && userdata.role === 'admin' ? <DefaultLayout {...props} /> :
// <><Login {...props} /></>
// )} />