Skip to content

Commit 8478ec3

Browse files
committed
added redirects
1 parent 582a857 commit 8478ec3

File tree

7 files changed

+71
-42
lines changed

7 files changed

+71
-42
lines changed

Diff for: componets/list.jsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ const List = function (props) {
2121

2222
<div className="list-title">
2323

24-
<h1>Hi, Harsh!</h1>
25-
<p>Here is the list of all your unfinished tasks ,</p>
24+
<h1>Welcome !</h1>
25+
<p>Here is the list of all your tasks ,</p>
2626

27-
<p><span> {props.data.todos.length} Unfinished tasks</span></p>
27+
<p><span> {props.data.todos.length} tasks</span></p>
2828

2929
</div>
3030

Diff for: config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
3+
4+
url:"https://django-todo-list-api.herokuapp.com"//localhost:8000
5+
}

Diff for: pages/index.js

+11-19
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
11
import Head from "next/head";
2+
import styles from "../styles/Home.module.css";
3+
import {useEffect} from 'react'
4+
import {useRouter} from 'next/router';
5+
export default function Home() {
26

3-
const HeadTag = function () {
4-
return (
5-
<Head>
6-
<title>Create Next App</title>
7-
<link rel="icon" href="/favicon.ico" />
8-
</Head>
9-
);
10-
};
7+
const router= useRouter();
118

12-
const Greeting = function () {
13-
return <h1> Hello world</h1>;
14-
};
159

16-
export default function Home() {
10+
useEffect(() => {
11+
12+
router.replace('/login');
13+
},[])
14+
1715
return (
18-
<div>
19-
<HeadTag />
20-
<main>
21-
<Greeting />
16+
<div className={styles.container}>
2217

23-
<Greeting />
24-
<Greeting />
25-
</main>
2618
</div>
2719
);
2820
}

Diff for: pages/login.jsx

+23-11
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
import Head from 'next/head'
33
import { useState, useEffect } from 'react';
4-
5-
let url = "http://localhost:8000"//"https://django-todo-list-api.herokuapp.com"
4+
import {useRouter} from 'next/router'
5+
const {url} = require('../config')
66
const HeadTag = function () {
77

88

@@ -54,9 +54,25 @@ const HeadTag = function () {
5454

5555
const Login = function () {
5656

57+
const router = useRouter();
58+
5759
const [formData, setForm] = useState({ username: 'Damon', password: '123456' })
5860
useEffect(async () => {
59-
})
61+
62+
let req = await fetch(`${url}/api/todo/` ,{credentials:'include'});
63+
64+
if(req.status ==200){
65+
66+
67+
router.replace('/todo')
68+
}
69+
70+
71+
72+
73+
74+
75+
} ,[])
6076

6177

6278
const submitForm = async function () {
@@ -65,7 +81,7 @@ const Login = function () {
6581

6682
// return console.log(form);
6783

68-
const req = await fetch('https://django-todo-list-api.herokuapp.com/api/login/', {
84+
const req = await fetch(`${url}/api/login/`, {
6985

7086
method: 'POST',
7187
headers: {
@@ -83,17 +99,15 @@ const Login = function () {
8399

84100
if (req.status === 200) {
85101

86-
let res = await req.json()
87-
88-
console.log(req.status, res);
89-
102+
let res = await req.json()
90103

104+
console.log(res);
91105
}
92106

93107

94108
else {
95109

96-
alert("Something went wrong")
110+
alert("Something went wrong from server")
97111
}
98112

99113

@@ -118,7 +132,6 @@ const Login = function () {
118132

119133
<HeadTag />
120134

121-
<main>
122135

123136

124137
<div className="container">
@@ -174,7 +187,6 @@ const Login = function () {
174187

175188
</div>
176189

177-
</main>
178190
</div>
179191

180192
)

Diff for: public/css/login.css

+24-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
.container {
2-
width: 100%;
2+
width: 100% !important;
3+
min-width: 100% !important;
4+
max-width: 100% !important;
5+
margin: 0 !important;
6+
padding: 0 !important;
37
height: 100vh;
48
display: flex;
59
flex-direction: row;
@@ -24,7 +28,8 @@
2428

2529
.login-tab h2 {
2630
font-size: 28px;
27-
color: rgb(214, 59, 59);
31+
color: #232840;
32+
;
2833

2934
font-weight: 300;
3035

@@ -42,7 +47,9 @@
4247
font-size: 13px;
4348
padding: 10px;
4449

45-
color: rgb(214, 59, 59);
50+
color: #232840;
51+
text-align: center;
52+
;
4653
}
4754

4855
.input-tab input {
@@ -51,7 +58,9 @@
5158
border-radius: 20px;
5259

5360
border-width: 1px;
54-
border-color: rgb(214, 59, 59);
61+
border-color: #232840;
62+
text-align: center;
63+
;
5564
}
5665

5766
.input-tab input:focus {
@@ -69,8 +78,10 @@
6978
width: 50%;
7079
padding: 10px 20px;
7180
border-radius: 20px;
72-
background-color: rgb(214, 59, 59);
73-
border: 1px solid rgb(214, 59, 59);
81+
background-color: #232840;
82+
;
83+
border: 1px solid #232840;
84+
;
7485

7586
color: white;
7687
}
@@ -79,14 +90,19 @@
7990
cursor: pointer;
8091

8192
background-color: white;
82-
color: rgb(214, 59, 59);
93+
color: #232840;
94+
;
95+
color: #232840;
96+
8397
}
8498

8599
.canvas {
86100
width: 60%;
87101
height: 100%;
88102

89-
background-color: rgb(214, 59, 59);
103+
background-color: #232840;
104+
;
105+
background-color: #232840;
90106

91107
background-image: url("/images/login-bg.png");
92108
padding: 35px;

Diff for: public/css/todo.css

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
justify-content: flex-start;
2626
align-items: center;
2727
background-color: #232840;
28+
/* background-color: rgb(214, 59, 59); */
29+
2830
}
2931

3032
.add-box {

Diff for: styles/todo.css

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
width: 100%;
33
height: 100vh;
44

5-
background-color: white;
5+
background-color: #ffffff;
66
background-color: #232840;
77
overflow: hidden;
88
}
@@ -25,6 +25,8 @@
2525
justify-content: flex-start;
2626
align-items: center;
2727
background-color: #232840;
28+
background-color: rgb(214, 59, 59) !important;
29+
2830
}
2931

3032
.add-box {

0 commit comments

Comments
 (0)