Skip to content

Commit 2bc9447

Browse files
committed
removed drive video , added youtube video link
1 parent bde0945 commit 2bc9447

File tree

8 files changed

+98
-65
lines changed

8 files changed

+98
-65
lines changed

app/api/projects/[projectId]/route.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export async function GET(request , { params }){
66
const { projectId } = params;
77
try {
88
const project = await Project.findOne({_id:projectId});
9+
//console.log(project);
910
return NextResponse.json(project,{
1011
success:true,
1112
status:200,

app/api/projects/route.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ export async function GET(request){
4747
}
4848
}
4949
export async function POST(request){
50-
const { title , content , userId , status , ProjectType , Mentor , ProjectLink , members , technologyUsed , images , DrivePdfId , DriveVideoId} = await request.json();
50+
const { title , content , userId , status , ProjectType , Mentor , ProjectLink , members , technologyUsed , images , DrivePdfId , DriveVideoId , youtubeLink} = await request.json();
5151
console.log("DriveVideoId : " , DriveVideoId)
52+
console.log("Drivepdf : " , DrivePdfId)
53+
console.log("Technology : " , technologyUsed)
54+
console.log("youtubelink : " , youtubeLink)
5255

5356
// const loginToken = request.cookies.get("loginToken")?.value;
5457
// const data = jwt.verify(loginToken , process.env.JWT_KEY);
@@ -66,7 +69,8 @@ export async function POST(request){
6669
technologiesUsed : technologyUsed ,
6770
images,
6871
DrivePdfId,
69-
DriveVideoId
72+
DriveVideoId,
73+
youtubeLink,
7074
});
7175
const createdProject = await project.save();
7276
return NextResponse.json(createdProject , {

app/project/[projectId]/page.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ export default function specificProject() {
7474
console.log("NO DATA FOUND");
7575
setProjectExist(false);
7676
}else{
77-
// console.log(data);
77+
console.log(data);
7878
setmyData(data);
7979
setLoading(false);
80-
// console.log(mydata);
80+
//console.log(mydata);
8181
}
8282

8383
}, []);
@@ -174,7 +174,7 @@ export default function specificProject() {
174174
m={"lg"}
175175
onClick={(event) => {
176176
event.preventDefault();
177-
window.location.href = `https://drive.google.com/file/d/${mydata.DriveVideoId}/view`
177+
window.location.href = `${mydata.youtubeLink}`
178178
}}
179179
>
180180
<IconVideo />

components/addingProject/addProject.tsx

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type MainObject = {
3131
video: FileWithPath[];
3232
videoFile: any;
3333
DriveVideoId: string;
34+
youtubeLink:string;
3435
};
3536
const mainObject: MainObject = {
3637
title: "",
@@ -53,6 +54,7 @@ const mainObject: MainObject = {
5354
video: [],
5455
videoFile: {},
5556
DriveVideoId: "",
57+
youtubeLink:""
5658
};
5759

5860
function convertToBase64(file: FileWithPath) {
@@ -88,6 +90,7 @@ export default function AddProject() {
8890
images: [""],
8991
DrivePdfId: "",
9092
DriveVideoId: "",
93+
youtubeLink:""
9194
});
9295
const resetProject = () => {
9396
Project.Mentor = "";
@@ -101,6 +104,7 @@ export default function AddProject() {
101104
Project.images = [];
102105
Project.DrivePdfId = "";
103106
Project.DriveVideoId = "";
107+
Project.youtubeLink = "";
104108

105109
mainObject.Mentor = "none";
106110
mainObject.ProjectLink = "";
@@ -118,6 +122,7 @@ export default function AddProject() {
118122
mainObject.title = "";
119123
mainObject.DrivePdfId = "";
120124
mainObject.DriveVideoId = "";
125+
mainObject.youtubeLink = "";
121126
};
122127
const RegisterProject = async () => {
123128
const base64: Array<string> = [];
@@ -161,47 +166,49 @@ export default function AddProject() {
161166
setPdfUploadSuccess(-1);
162167
}
163168
if (pdfUploadResult.success == true) {
169+
console.log(pdfUploadResult.docId)
164170
mainObject.DrivePdfId = pdfUploadResult.docId;
171+
saveProject()
165172
setPdfUploadLoading(false);
166173
}
167174
} else {
168175
setPdfUploadSuccess(-1);
169176
}
170177
};
171178

172-
const uploadVideo = async () => {
179+
// const uploadVideo = async () => {
173180

174-
let formData = new FormData();
175-
if(mainObject.videoFile.data != undefined || mainObject.videoFile.data != null){
176-
formData.append("file", mainObject.videoFile.data);
177-
formData.append("fileName", mainObject.videoFile.data.name);
178-
console.log("videoFile form addProject", mainObject.videoFile);
179-
console.log("videoFile.data form addProject", mainObject.videoFile.data);
181+
// let formData = new FormData();
182+
// if(mainObject.videoFile.data != undefined || mainObject.videoFile.data != null){
183+
// formData.append("file", mainObject.videoFile.data);
184+
// formData.append("fileName", mainObject.videoFile.data.name);
185+
// console.log("videoFile form addProject", mainObject.videoFile);
186+
// console.log("videoFile.data form addProject", mainObject.videoFile.data);
180187

181-
const response = await fetch("/api/upload/video", {
182-
method: "POST",
183-
body: formData,
184-
});
185-
const videoUploadResult = await response.json();
186-
console.log("videoUploadResult : ", videoUploadResult);
187-
if (videoUploadResult.success == false) {
188-
setVideoUploadSuccess(-1);
189-
}
190-
if (videoUploadResult.success == true) {
191-
console.log("videoUploadResult.docId : ", videoUploadResult.docId);
192-
mainObject.DriveVideoId = videoUploadResult.docId;
193-
Project.DriveVideoId = videoUploadResult.docId;
194-
setVideoUploadLoading(false);
195-
saveProject().then(() => {
196-
RegisterProject();
197-
});
198-
}
199-
}
200-
else{
201-
setVideoUploadSuccess(-1);
202-
}
188+
// const response = await fetch("/api/upload/video", {
189+
// method: "POST",
190+
// body: formData,
191+
// });
192+
// const videoUploadResult = await response.json();
193+
// console.log("videoUploadResult : ", videoUploadResult);
194+
// if (videoUploadResult.success == false) {
195+
// setVideoUploadSuccess(-1);
196+
// }
197+
// if (videoUploadResult.success == true) {
198+
// console.log("videoUploadResult.docId : ", videoUploadResult.docId);
199+
// mainObject.DriveVideoId = videoUploadResult.docId;
200+
// Project.DriveVideoId = videoUploadResult.docId;
201+
// setVideoUploadLoading(false);
202+
// saveProject().then(() => {
203+
// RegisterProject();
204+
// });
205+
// }
206+
// }
207+
// else{
208+
// setVideoUploadSuccess(-1);
209+
// }
203210

204-
};
211+
// };
205212

206213
const saveProject = async () => {
207214
Project.title = step1Object.title;
@@ -214,7 +221,7 @@ export default function AddProject() {
214221
Project.technologyUsed = step4Object.technologyUsed;
215222
Project.DrivePdfId = mainObject.DrivePdfId;
216223
Project.DriveVideoId = mainObject.DriveVideoId;
217-
224+
Project.youtubeLink = step3Object.youtubeLink;
218225
// console.log("base 64 : " , Project.images)
219226
};
220227
const [active, setActive] = useState(0);
@@ -262,7 +269,7 @@ export default function AddProject() {
262269
)
263270
}
264271
/>
265-
<Stepper.Step
272+
{/* <Stepper.Step
266273
label="Step 2"
267274
description="uploading video"
268275
loading={videoUploadLoading && !pdfUploadLoading}
@@ -272,14 +279,14 @@ export default function AddProject() {
272279
<IconCircleX style={{ width: rem(20), height: rem(20) }} />
273280
)
274281
}
275-
/>
282+
/> */}
276283
<Stepper.Step
277-
label="Step 3"
284+
label="Step 2"
278285
description="Creating project"
279286
loading={
280287
active == 4 &&
281288
success == 0 &&
282-
!videoUploadLoading &&
289+
//!videoUploadLoading &&
283290
!pdfUploadLoading
284291
}
285292
color={active == 4 && success == -1 ? "red" : ""}
@@ -356,7 +363,8 @@ export default function AddProject() {
356363
variant="default"
357364
onClick={() => {
358365
uploadPdf().then(() => {
359-
uploadVideo();
366+
//uploadVideo();
367+
RegisterProject();
360368
});
361369
nextStep();
362370
}}

components/addingProject/addProjectStep3.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const step3Object = {
1515
ProjectLink: "",
1616
Mentor: "",
1717
members: [{name : "" , id : ""}],
18+
youtubeLink:""
1819
};
1920
export function AddProjectStep3() {
2021
const [data, setData] = useState(mainObject.members);
@@ -26,6 +27,7 @@ export function AddProjectStep3() {
2627
const [Project, setProject] = useState({
2728
ProjectLink: mainObject.ProjectLink,
2829
Mentor: mainObject.Mentor,
30+
youtubeLink:mainObject.youtubeLink
2931
});
3032
let rows = data.map((row) => (
3133
<Table.Tr key={row.name}>
@@ -51,6 +53,8 @@ export function AddProjectStep3() {
5153
mainObject.ProjectLink = Project.ProjectLink;
5254
step3Object.members = data;
5355
mainObject.members = data;
56+
step3Object.youtubeLink = Project.youtubeLink;
57+
mainObject.youtubeLink = Project.youtubeLink;
5458
};
5559

5660
return (
@@ -79,6 +83,17 @@ export function AddProjectStep3() {
7983
setProject({ ...Project, ProjectLink: e.target.value });
8084
}}
8185
/>
86+
<TextInput
87+
m={"sm"}
88+
withAsterisk
89+
label="Youtube description Video Link"
90+
placeholder="Video description Link"
91+
required
92+
value={Project.youtubeLink}
93+
onChange={(e) => {
94+
setProject({ ...Project, youtubeLink: e.target.value });
95+
}}
96+
/>
8297
<TextInput
8398
m={"sm"}
8499
withAsterisk

components/addingProject/addProjectStep4.tsx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ export default function AddProjectStep4(props: Partial<DropzoneProps>) {
3939
}
4040

4141

42-
const handleVideoChange = (e : any)=>{
43-
const file = {
44-
preview: URL.createObjectURL(e.target.files[0]),
45-
data: e.target.files[0],
46-
};
42+
// const handleVideoChange = (e : any)=>{
43+
// const file = {
44+
// preview: URL.createObjectURL(e.target.files[0]),
45+
// data: e.target.files[0],
46+
// };
4747

48-
console.log("file : " , file)
49-
setVideoFile(video)
50-
mainObject.videoFile = file;
51-
step4Object.videoFile = file;
52-
}
48+
// console.log("file : " , file)
49+
// setVideoFile(video)
50+
// mainObject.videoFile = file;
51+
// step4Object.videoFile = file;
52+
// }
5353

5454
const previews = files.map((file, index) => {
5555
const imageUrl = URL.createObjectURL(file);
@@ -72,16 +72,16 @@ export default function AddProjectStep4(props: Partial<DropzoneProps>) {
7272
</>
7373
)
7474
})
75-
const videoPreview = video.map((file , index)=>{
76-
return(
77-
<>
78-
<Text key={index}>
79-
Video selected :
80-
{file.name}
81-
</Text>
82-
</>
83-
)
84-
})
75+
// const videoPreview = video.map((file , index)=>{
76+
// return(
77+
// <>
78+
// <Text key={index}>
79+
// Video selected :
80+
// {file.name}
81+
// </Text>
82+
// </>
83+
// )
84+
// })
8585

8686
const [value, setValue] = useState<string[]>(
8787
mainObject.technologyUsed[0] == "" ? [] : mainObject.technologyUsed
@@ -213,7 +213,7 @@ export default function AddProjectStep4(props: Partial<DropzoneProps>) {
213213

214214

215215

216-
<Dropzone
216+
{/* <Dropzone
217217
m={"sm"}
218218
activateOnDrag = {true}
219219
maxFiles={1}
@@ -257,7 +257,7 @@ export default function AddProjectStep4(props: Partial<DropzoneProps>) {
257257
stroke={1.5}
258258
/>
259259
</Dropzone.Reject>
260-
</Dropzone>
260+
</Dropzone> */}
261261

262262

263263
{/* <SimpleGrid

models/projectModel.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ const ProjectSchema = new mongoose.Schema({
5252
type : String ,
5353
default : ""
5454
},
55-
DriveVideoId : {
56-
type : String ,
55+
// DriveVideoId : {
56+
// type : String ,
57+
// default : ""
58+
// }
59+
youtubeLink : {
60+
type : String,
5761
default : ""
5862
}
5963
});

next.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
const nextConfig = {
33
reactStrictMode: true,
44
swcMinify: true,
5+
reactStrictMode:false
56
};
67

78
export default nextConfig;

0 commit comments

Comments
 (0)