Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions app/(Root)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
// import {Image} from "next/image"
import Link from "next/link";
import Image from "next/image";

import React from 'react'
import {Button} from '@/components/ui/button'
import InterviewCard from "@/components/interviewCard";
import { Interview } from "@/types";
// import { Link } from 'lucide-react'



const page = () => {
const userInterviews: Interview[] = [];
const allInterview: Interview[] = [];
const user = { id: "1" };
const hasPastInterviews = userInterviews.length > 0;
const hasUpcomingInterviews = allInterview.length > 0;
return (
<>
<section className="card-cta">
Expand Down Expand Up @@ -37,7 +43,7 @@ const page = () => {

<div className="interviews-section">
{hasPastInterviews ? (
userInterviews?.map((interview) => (
userInterviews?.map((interview: Interview) => (
<InterviewCard
key={interview.id}
userId={user?.id}
Expand All @@ -59,7 +65,7 @@ const page = () => {

<div className="interviews-section">
{hasUpcomingInterviews ? (
allInterview?.map((interview) => (
allInterview?.map((interview: Interview) => (
<InterviewCard
key={interview.id}
userId={user?.id}
Expand Down
7 changes: 6 additions & 1 deletion components/AuthForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,16 @@ const AuthForm = ({ type }: { type: FormType }) => {
return;
}

await signIn({
const result = await signIn({
email,
idToken,
});

if (!result.success) {
toast.error(result.message);
return;
}

toast.success("Signed in successfully.");
router.push("/");
}
Expand Down
2 changes: 1 addition & 1 deletion components/interviewCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Button } from "./ui/button";
import DisplayTechIcons from "./DisplayTechIcons";

import { cn, getRandomInterviewCover } from "@/lib/utils";
import { getFeedbackByInterviewId } from "@lib/actions/general.action";
import { getFeedbackByInterviewId } from "@/lib/actions/general.action";
import { InterviewCardProps } from "@/types";
// @/lib/actions/general.action

Expand Down
6 changes: 5 additions & 1 deletion lib/actions/auth.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@ export async function signIn(params: SignInParams) {
};

await setSessionCookie(idToken);

return {
success: true,
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
console.log("");
console.log(error);

return {
success: false,
Expand Down
38 changes: 38 additions & 0 deletions lib/actions/general.action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"use server";

import { db } from "@/firebase/admin";
import { Feedback, GetFeedbackByInterviewIdParams } from "@/types";

export async function getFeedbackByInterviewId(
params: GetFeedbackByInterviewIdParams
): Promise<Feedback | null> {
try {
const { userId, interviewId } = params;

const feedbackRef = await db
.collection("users")
.doc(userId)
.collection("interviews")
.doc(interviewId)
.collection("feedbacks")
.get();

if (feedbackRef.empty) return null;

const feedback = feedbackRef.docs[0].data();

return {
id: feedbackRef.docs[0].id,
interviewId: feedback.interviewId,
totalScore: feedback.totalScore,
categoryScores: feedback.categoryScores,
strengths: feedback.strengths,
areasForImprovement: feedback.areasForImprovement,
finalAssessment: feedback.finalAssessment,
createdAt: feedback.createdAt.toDate(),
};
} catch (error) {
console.log(error);
return null;
}
}