Skip to content
Closed
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
4 changes: 2 additions & 2 deletions .github/workflows/blank1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ name: CI
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
branches: ['main']
pull_request:
branches: [ "main" ]
branches: ['main']

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bun run lint
bun run prettier
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"bracketSameLine": false,
"bracketSpacing": true
}
12 changes: 6 additions & 6 deletions Providers.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"use client";
import { Toaster } from "react-hot-toast";
'use client';
import { Toaster } from 'react-hot-toast';

import React from "react";
import React from 'react';

const Providers = ({ children }: { children: React.ReactNode }) => {
return (
<>
<Toaster
toastOptions={{
className: "",
className: '',
style: {
fontSize: "17px",
fontSize: '17px',
},
}}
/>
Expand All @@ -19,4 +19,4 @@ const Providers = ({ children }: { children: React.ReactNode }) => {
);
};

export default Providers;
export default Providers;
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ As the above image shows, we documented each our test example in terms of test I

![errors in testing script](https://github.com/Kuzma02/Electronics-eCommerce-Shop-With-Admin-Dashboard-NextJS-NodeJS/assets/138793624/507fa099-2039-47ce-a38b-209166a8d5c4)


<p>During the software testing process, we documented each error found in the error report form. As shown in the image above, each error has its own unique error ID and a detailed description of the error containing: date of identifying an error, date of troubleshooting an error, error priority, type of error, file name, testing phase.</p>

<h3>6.1. Ad hoc testing</h3>
Expand Down Expand Up @@ -108,7 +107,6 @@ We have applied this method by examining the code after each new added functiona
<h3>Is Next.js good for eCommerce?</h3>
<p>Next.js is currently one of the best ways for developing custom eCommerce solutions. It’s benefits include improved performance, SEO-friendliness, easy development and deployment, excellent developer experience, and the ability to handle versatile and scalable projects. By leveraging Next.js, developers can create compelling web applications that deliver an exceptional user experience while maintaining optimal performance.</p>


<h2>Step-by-step video instructions for running the app</h2>

[https://www.youtube.com/watch?v=Ry0aOMws0gE](https://www.youtube.com/watch?v=Ry0aOMws0gE)
Expand Down Expand Up @@ -137,7 +135,6 @@ DATABASE_URL="mysql://username:password@localhost:3306/singitronic_nextjs"

<p>8. Now you need to open your terminal of choice in the root folder of the project and write:</p>


```
npm install
```
Expand Down Expand Up @@ -177,7 +174,6 @@ npm run dev

<p>14. Open <a href="http://localhost:3000" target="_blank">http://localhost:3000</a> and see it live!</p>


<h2>Project screenshots</h2>

<h3>Home page</h3>
Expand Down
38 changes: 19 additions & 19 deletions app/(dashboard)/admin/categories/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"use client";
import { DashboardSidebar } from "@/components";
import { useRouter } from "next/navigation";
import React, { useEffect, useState } from "react";
import toast from "react-hot-toast";
import { formatCategoryName } from "../../../../../utils/categoryFormating";
import { convertCategoryNameToURLFriendly } from "../../../../../utils/categoryFormating";
'use client';
import { DashboardSidebar } from '@/components';
import { useRouter } from 'next/navigation';
import React, { useEffect, useState } from 'react';
import toast from 'react-hot-toast';
import { formatCategoryName } from '../../../../../utils/categoryFormating';
import { convertCategoryNameToURLFriendly } from '../../../../../utils/categoryFormating';

interface DashboardSingleCategoryProps {
params: { id: number };
Expand All @@ -14,34 +14,34 @@ const DashboardSingleCategory = ({
params: { id },
}: DashboardSingleCategoryProps) => {
const [categoryInput, setCategoryInput] = useState<{ name: string }>({
name: "",
name: '',
});
const router = useRouter();

const deleteCategory = async () => {
const requestOptions = {
method: "DELETE",
method: 'DELETE',
};
// sending API request for deleting a category
fetch(`http://localhost:3001/api/categories/${id}`, requestOptions)
.then((response) => {
if (response.status === 204) {
toast.success("Category deleted successfully");
router.push("/admin/categories");
toast.success('Category deleted successfully');
router.push('/admin/categories');
} else {
throw Error("There was an error deleting a category");
throw Error('There was an error deleting a category');
}
})
.catch((error) => {
toast.error("There was an error deleting category");
toast.error('There was an error deleting category');
});
};

const updateCategory = async () => {
if (categoryInput.name.length > 0) {
const requestOptions = {
method: "PUT",
headers: { "Content-Type": "application/json" },
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: convertCategoryNameToURLFriendly(categoryInput.name),
}),
Expand All @@ -52,15 +52,15 @@ const DashboardSingleCategory = ({
if (response.status === 200) {
return response.json();
} else {
throw Error("Error updating a category");
throw Error('Error updating a category');
}
})
.then((data) => toast.success("Category successfully updated"))
.then((data) => toast.success('Category successfully updated'))
.catch((error) => {
toast.error("There was an error while updating a category");
toast.error('There was an error while updating a category');
});
} else {
toast.error("For updating a category you must enter all values");
toast.error('For updating a category you must enter all values');
return;
}
};
Expand Down
26 changes: 13 additions & 13 deletions app/(dashboard)/admin/categories/new/page.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
"use client";
import { DashboardSidebar } from "@/components";
import React, { useState } from "react";
import toast from "react-hot-toast";
import { convertCategoryNameToURLFriendly } from "../../../../../utils/categoryFormating";
'use client';
import { DashboardSidebar } from '@/components';
import React, { useState } from 'react';
import toast from 'react-hot-toast';
import { convertCategoryNameToURLFriendly } from '../../../../../utils/categoryFormating';

const DashboardNewCategoryPage = () => {
const [categoryInput, setCategoryInput] = useState({
name: "",
name: '',
});

const addNewCategory = () => {
if (categoryInput.name.length > 0) {
const requestOptions = {
method: "post",
headers: { "Content-Type": "application/json" },
method: 'post',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: convertCategoryNameToURLFriendly(categoryInput.name),
}),
Expand All @@ -24,20 +24,20 @@ const DashboardNewCategoryPage = () => {
if (response.status === 201) {
return response.json();
} else {
throw Error("There was an error while creating category");
throw Error('There was an error while creating category');
}
})
.then((data) => {
toast.success("Category added successfully");
toast.success('Category added successfully');
setCategoryInput({
name: "",
name: '',
});
})
.catch((error) => {
toast.error("There was an error while creating category");
toast.error('There was an error while creating category');
});
} else {
toast.error("You need to enter values to add a category");
toast.error('You need to enter values to add a category');
}
};
return (
Expand Down
14 changes: 7 additions & 7 deletions app/(dashboard)/admin/categories/page.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"use client";
import { CustomButton, DashboardSidebar } from "@/components";
import { nanoid } from "nanoid";
import Link from "next/link";
import React, { useEffect, useState } from "react";
import { formatCategoryName } from "../../../../utils/categoryFormating";
'use client';
import { CustomButton, DashboardSidebar } from '@/components';
import { nanoid } from 'nanoid';
import Link from 'next/link';
import React, { useEffect, useState } from 'react';
import { formatCategoryName } from '../../../../utils/categoryFormating';

const DashboardCategory = () => {
const [categories, setCategories] = useState<Category[]>([]);

// getting all categories to be displayed on the all categories page
useEffect(() => {
fetch("http://localhost:3001/api/categories")
fetch('http://localhost:3001/api/categories')
.then((res) => {
return res.json();
})
Expand Down
Loading