Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtoszBart committed Jun 10, 2024
1 parent 3375f7b commit 5b12514
Show file tree
Hide file tree
Showing 20 changed files with 641 additions and 117 deletions.
677 changes: 593 additions & 84 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
"chart.js": "^4.4.0",
"cheerio": "^1.0.0-rc.12",
"formik": "^2.4.6",
"next": "14.0.3",
"next": "^14.2.3",
"next-auth": "^4.24.6",
"react": "^18",
"react-chartjs-2": "^5.2.0",
"react-dom": "^18",
"react-spinners": "^0.13.8",
"sass": "^1.69.5",
"sharp": "^0.33.4",
"yup": "^1.4.0"
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion src/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { authConfig } from '@/auth/auth';
import NextAuth from 'next-auth/next';

import { authConfig } from '@/auth/auth';

const handler = NextAuth(authConfig);

export { handler as GET, handler as POST };
3 changes: 2 additions & 1 deletion src/app/api/data/items/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NextResponse, NextRequest } from 'next/server';

import Item, { ItemMin } from '@/models/Item';
import { getItemsMin, createItem } from '@/repository/postgres/itemRepository';
import { NextResponse, NextRequest } from 'next/server';

export async function GET(): Promise<NextResponse> {
const items: ItemMin[] = await getItemsMin();
Expand Down
3 changes: 2 additions & 1 deletion src/app/api/data/notifications/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NextResponse, NextRequest } from 'next/server';

import { Notification } from '@/models/Notification';
import { createNotification } from '@/repository/postgres/notificationRepository';
import { NextResponse, NextRequest } from 'next/server';

export async function POST(req: NextRequest): Promise<NextResponse> {
const notification: Notification = await req.json();
Expand Down
3 changes: 2 additions & 1 deletion src/app/api/data/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NextResponse } from 'next/server';

import Data from '@/models/Data';
import { getItemData } from '@/repository/postgres/dataRepository';
import { NextResponse } from 'next/server';

export async function GET(req: any) {
const { searchParams } = new URL(req.url);
Expand Down
3 changes: 2 additions & 1 deletion src/app/api/data/vendors/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NextResponse } from 'next/server';

import Vendor from '@/models/Vendor';
import { getVendors } from '@/repository/postgres/vendorRepository';
import { NextResponse } from 'next/server';

export async function GET(): Promise<NextResponse> {
const vendors: Vendor[] = await getVendors();
Expand Down
3 changes: 2 additions & 1 deletion src/app/api/scrape/route.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { NextResponse } from 'next/server';

import Data from '@/models/Data';
import Item from '@/models/Item';
import { getItems } from '@/repository/postgres/itemRepository';
import { insertData } from '@/repository/postgres/dataRepository';
import { scrape } from '@/utils/scraping';
import { NextResponse } from 'next/server';

export async function GET(req: any) {
const { searchParams } = new URL(req.url);
Expand Down
6 changes: 3 additions & 3 deletions src/app/dashboard/new-item/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use client';

import { useRouter } from 'next/navigation';
import axios from 'axios';
import { useSession } from 'next-auth/react';
import { useEffect, useRef, useState } from 'react';
import { useRouter } from 'next/navigation';
import Image, { StaticImageData } from 'next/image';
import { useSession } from 'next-auth/react';
import axios from 'axios';
import { FormikProps, FormikValues } from 'formik';

import '@/styles/pages/newItem.scss';
Expand Down
9 changes: 5 additions & 4 deletions src/app/dashboard/new-notification/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
'use client';

import { useEffect, useState } from 'react';
import { useRouter } from 'next/navigation';
import { useSession } from 'next-auth/react';
import axios from 'axios';

import { ISession } from '@/auth/auth';
import Loader from '@/components/Loader';
import ComboBox, { IComboBoxOptions } from '@/components/forms/ComboBox';
Expand All @@ -9,10 +14,6 @@ import SubmitButton from '@/components/forms/SubmitButton';
import { ItemMin } from '@/models/Item';
import { Notification, NotificationSchema } from '@/models/Notification';
import { getBoolValue } from '@/utils/formatters';
import axios from 'axios';
import { useSession } from 'next-auth/react';
import { useRouter } from 'next/navigation';
import { useEffect, useState } from 'react';

interface INotification {
item: number | undefined;
Expand Down
5 changes: 3 additions & 2 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Metadata } from 'next';
import { Inter } from 'next/font/google';
import '../styles/main.scss';

import '@/styles/main.scss';
import AuthComponent from '@/components/auth/AuthComponent';
import NextAuthProvider from '@/auth/SessionProvider';

Expand All @@ -17,7 +18,7 @@ export default async function RootLayout({
children: React.ReactNode;
}) {
return (
<html lang='en'>
<html lang='en' suppressHydrationWarning>
<body className={inter.className}>
<NextAuthProvider>
<header>
Expand Down
5 changes: 3 additions & 2 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import '../styles/pages/mainPage.scss';
import Image from 'next/image';

import '@/styles/pages/mainPage.scss';
import Item from '@/models/Item';
import { getItems } from '@/repository/postgres/itemRepository';
import Image from 'next/image';

export default async function Home() {
const items: Item[] = await getItems();
Expand Down
1 change: 1 addition & 0 deletions src/auth/SessionProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client';

import { SessionProvider } from 'next-auth/react';

export default SessionProvider;
11 changes: 5 additions & 6 deletions src/auth/auth.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { redirect } from 'next/navigation';
import { NextAuthOptions, Session, getServerSession } from 'next-auth';
import { JWT } from 'next-auth/jwt';
import GoogleProvider from 'next-auth/providers/google';

import User from '@/models/User';
import {
getUser,
insertUser,
updateUser,
} from '@/repository/postgres/userRepository';
import { NextAuthOptions, Session, getServerSession } from 'next-auth';
import { JWT } from 'next-auth/jwt';
import CredentialsProvider from 'next-auth/providers/credentials';
import GoogleProvider, { GoogleProfile } from 'next-auth/providers/google';
import { useSession } from 'next-auth/react';
import { redirect, useRouter } from 'next/navigation';

export interface ISession {
id: number;
Expand Down
3 changes: 2 additions & 1 deletion src/components/NotificationCard.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import Image from 'next/image';

import '@/styles/components/notificationCard.scss';
import Item, { ItemLastData } from '@/models/Item';
import { Notification } from '@/models/Notification';
import Image from 'next/image';

export default function NotificationCard({
notification,
Expand Down
3 changes: 2 additions & 1 deletion src/components/auth/AuthComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import '@/styles/components/linkButton.scss';
import React from 'react';
import { getServerSession } from 'next-auth';

import '@/styles/components/linkButton.scss';
import { authConfig, ISession } from '@/auth/auth';
import LoggedInComponent from '@/components/auth/LoggedInComponent';

Expand Down
2 changes: 1 addition & 1 deletion src/components/auth/LoggedInComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use client';

import { useState } from 'react';
import { signOut } from 'next-auth/react';
import Image from 'next/image';
import { useState } from 'react';

export default function LoggedInComponent({
image,
Expand Down
4 changes: 2 additions & 2 deletions src/components/chart/Chart.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use client';

import 'chart.js/auto';
import { useState } from 'react';
import { Line } from 'react-chartjs-2';
import { ChartData } from 'chart.js/auto';

import '@/styles/components/charts.scss';
import Data from '@/models/Data';
import { options } from '@/utils/charts';
import { useState } from 'react';
import { ChartData } from 'chart.js/auto';
import ChartFilterOption from '@/models/ChartFilterOption';

export default function LineChart({ itemData }: { itemData: Data[] }) {
Expand Down
3 changes: 2 additions & 1 deletion src/components/forms/Form.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use client';

import { Ref } from 'react';
import { Form, Formik, FormikProps } from 'formik';

import '@/styles/components/forms.scss';
import { Ref } from 'react';

interface IForm {
initialValues: Object;
Expand Down
8 changes: 5 additions & 3 deletions src/utils/scraping.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import Data from '@/models/Data';
import Item from '@/models/Item';
import axios from 'axios';
import * as cheerio from 'cheerio';

import Data from '@/models/Data';
import Item from '@/models/Item';
import Vendor from '@/models/Vendor';

export function scrape(item: Item): Promise<Data> {
switch (item.vendor.id) {
switch ((item.vendor as Vendor).id) {
case 1:
return scrapeMorele(item);
case 2:
Expand Down

0 comments on commit 5b12514

Please sign in to comment.