Skip to content

Commit

Permalink
Merge pull request #292 from mumin-khan/fix-multiple-instances-of-sin…
Browse files Browse the repository at this point in the history
…gleton

fixed multiple instances of singleton
  • Loading branch information
hkirat authored Apr 1, 2024
2 parents e92ebe3 + 959712b commit be5b6b4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/components/Courses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { Course } from '@prisma/client';
import { CourseCard } from './CourseCard';
import { useRouter } from 'next/navigation';
import { RefreshDb } from './RefreshDb';

export const Courses = ({ courses }: { courses: Course[] }) => {
const router = useRouter();
Expand All @@ -27,7 +26,6 @@ export const Courses = ({ courses }: { courses: Course[] }) => {
/>
))}
</div>
<RefreshDb />
</section>
);
};
9 changes: 8 additions & 1 deletion src/components/MyCourses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { authOptions } from '@/lib/auth';
import { getPurchases } from '@/utiles/appx';
import { getServerSession } from 'next-auth';
import { Logout } from './Logout';
import { RefreshDb } from './RefreshDb';
import { refreshDb } from '@/actions/refresh-db';
const getCourses = async () => {
const session = await getServerSession(authOptions);
const purchases = await getPurchases(session?.user.email || '');
Expand All @@ -22,5 +24,10 @@ export const MyCourses = async () => {
<Logout />
</div>
);
return <Courses courses={purchases} />;
return (
<>
<Courses courses={purchases} />
<RefreshDb refreshDb={refreshDb} />
</>
);
};
6 changes: 3 additions & 3 deletions src/components/RefreshDb.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use client';
import { refreshDb } from '@/actions/refresh-db';
import { Button } from './ui/button';
import { toast } from 'sonner';
import { useSession } from 'next-auth/react';

export function RefreshDb() {
//@ts-ignore
export function RefreshDb({ refreshDb }) {
const session = useSession();
console.log(session);

Expand All @@ -21,7 +21,7 @@ export function RefreshDb() {
if (session.status === 'loading') return <>Loading...</>;

return (
<div className="flex flex-col gap-2">
<div className="flex flex-col gap-2 mx-auto">
<h1>Don't see all your courses?</h1>
<Button className="dark:text-white" onClick={handleClick}>
Refresh Database
Expand Down

0 comments on commit be5b6b4

Please sign in to comment.