Skip to content

Commit

Permalink
chore: Update shared-components subproject commit and remove unused f…
Browse files Browse the repository at this point in the history
…iles
  • Loading branch information
keyskull committed Jun 26, 2024
1 parent add9487 commit 27ba439
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 719 deletions.
5 changes: 1 addition & 4 deletions app/dashboard/page.tsx → app/(root)/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from "react";
import DashBoard from "@/components/ui/dashboard/index";
import DashboardChart from "@/components/ui/dashboard/charts";

const Page: React.FC<any> = () => {
export default function Page() {
return (
<React.Fragment>
<DashBoard>
Expand All @@ -14,6 +14,3 @@ const Page: React.FC<any> = () => {
);
};



export default Page
41 changes: 0 additions & 41 deletions app/(root)/layout.tsx

This file was deleted.

124 changes: 15 additions & 109 deletions app/(root)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,110 +1,16 @@
"use client"
import Pagination from '@/components/ui/pagination';
import Search from '@mitech/shared-components/ui/search';
import AdsTable from '@/components/ui/ads-table';
import { CreateAd } from '@/components/ui/button';
import { Suspense, useEffect, useState } from 'react';
import { Metadata } from 'next';
import { GetFilteredAdsPages } from '@/lib/data';
import GanttChart from '@/components/ui/gantt-chart/gantt-chart';
import { fetchAds } from '@/lib/api';
import { Advertisement } from '@/lib/definitions';
import 'react-toastify/dist/ReactToastify.css';
import Cookies from 'js-cookie';
import { toast } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
"use client";

import React from "react";
import DashBoard from "@/components/ui/dashboard/index";
import DashboardChart from "@/components/ui/dashboard/charts";

export default function Page() {
return (
<React.Fragment>
<DashBoard>
<DashboardChart />
</DashBoard>
</React.Fragment>
);
};

export default function Page({
searchParams,
}: {
searchParams?: {
query?: string;
page?: string;
};
}) {
const query = searchParams?.query || '';
const currentPage = Number(searchParams?.page) || 1;
const [adsAll, setAds] = useState<Advertisement[]>([]);
useEffect(() => {
fetchAds().then(data => setAds(data.result.filter((ad:any) => ad.status !== 'deleted')));
}, []);
useEffect(() => {
const message = Cookies.get('notification_stop_ad');
function showToast() {
toast.success(message);
}
if (message) {
setTimeout(showToast, 1000);
Cookies.remove('notification_stop_ad');
}
}, []);
useEffect(() => {
const message = Cookies.get('notification_post_ad');
function showToast() {
toast.success(message);
}
if (message) {
setTimeout(showToast, 1000);
Cookies.remove('notification_post_ad');
}
}, []);
useEffect(() => {
const message = Cookies.get('notification_delete_ad');
function showToast() {
toast.success(message);
}
if (message) {
setTimeout(showToast, 1000);
Cookies.remove('notification_delete_ad');
}
}, []);
useEffect(() => {
const message = Cookies.get('notification_create_ad');
function showToast() {
toast.success(message);
}
if (message) {
setTimeout(showToast, 1000);
Cookies.remove('notification_create_ad');
}
}, []);
useEffect(() => {
const message = Cookies.get('notification_update_ad');
function showToast() {
toast.success(message);
}
if (message) {
setTimeout(showToast, 1000);
Cookies.remove('notification_update_ad');
}
}, []);
const totalPages = GetFilteredAdsPages(adsAll,query);
return (
<div className="w-full">
<header className="flex items-center justify-between px-6 py-8 bg-gray-900 text-white">
<div className="flex items-center space-x-4">
<h2 className="text-lg font-medium">Manage Ads</h2>
</div>
</header>
<div className='w-full max-w-[80%] justify-center items-center m-auto'>
<div className="mt-4 flex items-center justify-center gap-2 md:mt-8">
<Search placeholder="Search ad..." />
<CreateAd />
</div>
<AdsTable query={query} currentPage={currentPage} />
<div className="mt-5 flex w-full justify-center">
<Pagination totalPages={totalPages} />
</div>
</div>
<br /><hr />
<div className='w-full max-w-[80%] justify-center items-center m-auto pb-40'>
<div className="mt-4 items-center justify-center gap-2 md:mt-8">
<div className='row'><p className='ml-3 font-bold'>AD Campaign Gantt Chart</p></div>
<div className="row">
<GanttChart adsAll={adsAll}/>
</div>
</div>
</div>
</div>
);
}
17 changes: 0 additions & 17 deletions app/dashboard/layout.tsx

This file was deleted.

File renamed without changes.
49 changes: 49 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import './globals.css';
import { Analytics } from '@vercel/analytics/react';
import { SessionProvider } from 'next-auth/react';
import { SpeedInsights } from "@vercel/speed-insights/next"
import { NextUIProvider } from '@nextui-org/react';
import { ThemeProvider as NextThemesProvider } from "next-themes";
import { NotificationProvider } from '@/components/ui/NotificationContext';
import Navbar from '@mitech/shared-components/ui/navbars/navbar-2';
import Sidebar from '@mitech/shared-components/ui/sidebars/sidebar-2';

export const metadata = {
title: 'Next.js',
description: 'Generated by Next.js',
}


export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body>
<SessionProvider>
<NextUIProvider>
<NextThemesProvider attribute="class" defaultTheme='light'>
<NotificationProvider>
<div className="flex">
<aside className="w-1/5 bg-[#ff7f00] text-white p-4">
<Sidebar />
</aside>
<main className="w-full">
<div className="container mx-auto px-4 mb-8">
<Navbar />
{children}
</div>
</main>
</div>
<Analytics />
<SpeedInsights />{/* Vercel Speed Insights */}
</NotificationProvider>
</NextThemesProvider>
</NextUIProvider>
</SessionProvider>
</body>
</html>
)
}
24 changes: 1 addition & 23 deletions components/ui/dashboard/charts.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
"use client"
import Link from "next/link";
import { useState } from "react";
import { CircleAlertIcon, SearchIcon, BellIcon, Question } from "./icons";
import { Avatar } from '@nextui-org/react';
import BarListChart from "./barList";
import BarChartComponent from "./barChart";
import LineCharts from "./lineChart";
Expand Down Expand Up @@ -40,26 +37,7 @@ const DashboardChart = () => {
};

return (
<div className="container mx-auto px-4 mb-8">
<header className="flex items-center justify-between border-b border-gray-300 pb-4 mt-4">
<div className="flex items-center space-x-4">
<CircleAlertIcon className="w-6 h-6 text-yellow-500" />
<div className="bg-orange-100 p-4 rounded-md flex items-center justify-between">
<span>There are 30 days left in your trial. </span>
<Link href="#" className="text-blue-500 ml-2" prefetch={false}>
Upgrade Account
</Link>
</div>
</div>
<div className="flex items-center space-x-4">
<SearchIcon className="w-6 h-6" />
<BellIcon className="w-6 h-6" />
<Question className="w-6 h-6" />
<Avatar className="w-8 h-8">
XD
</Avatar>
</div>
</header>
<div>
<div>
<div className="h-px bg-gray-300" />
<h1 className="text-3xl font-bold mb-4 mt-4">Dashboard</h1>
Expand Down
Loading

0 comments on commit 27ba439

Please sign in to comment.