Skip to content

Commit 9edc76f

Browse files
committed
Added Prettier and Husky
1 parent ebdca21 commit 9edc76f

126 files changed

Lines changed: 2143 additions & 2242 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/blank1.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ name: CI
66
on:
77
# Triggers the workflow on push or pull request events but only for the "main" branch
88
push:
9-
branches: [ "main" ]
9+
branches: ['main']
1010
pull_request:
11-
branches: [ "main" ]
11+
branches: ['main']
1212

1313
# Allows you to run this workflow manually from the Actions tab
1414
workflow_dispatch:

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bun run prettier

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"tabWidth": 2,
5+
"bracketSameLine": false,
6+
"bracketSpacing": true
7+
}

Providers.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
"use client";
2-
import { Toaster } from "react-hot-toast";
1+
'use client';
2+
import { Toaster } from 'react-hot-toast';
33

4-
import React from "react";
4+
import React from 'react';
55

66
const Providers = ({ children }: { children: React.ReactNode }) => {
77
return (
88
<>
99
<Toaster
1010
toastOptions={{
11-
className: "",
11+
className: '',
1212
style: {
13-
fontSize: "17px",
13+
fontSize: '17px',
1414
},
1515
}}
1616
/>
@@ -19,4 +19,4 @@ const Providers = ({ children }: { children: React.ReactNode }) => {
1919
);
2020
};
2121

22-
export default Providers;
22+
export default Providers;

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ As the above image shows, we documented each our test example in terms of test I
5151

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

54-
5554
<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>
5655

5756
<h3>6.1. Ad hoc testing</h3>
@@ -108,7 +107,6 @@ We have applied this method by examining the code after each new added functiona
108107
<h3>Is Next.js good for eCommerce?</h3>
109108
<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>
110109

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

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

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

140-
141138
```
142139
npm install
143140
```
@@ -177,7 +174,6 @@ npm run dev
177174

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

180-
181177
<h2>Project screenshots</h2>
182178

183179
<h3>Home page</h3>

app/(dashboard)/admin/categories/[id]/page.tsx

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
"use client";
2-
import { DashboardSidebar } from "@/components";
3-
import { useRouter } from "next/navigation";
4-
import React, { useEffect, useState } from "react";
5-
import toast from "react-hot-toast";
6-
import { formatCategoryName } from "../../../../../utils/categoryFormating";
7-
import { convertCategoryNameToURLFriendly } from "../../../../../utils/categoryFormating";
1+
'use client';
2+
import { DashboardSidebar } from '@/components';
3+
import { useRouter } from 'next/navigation';
4+
import React, { useEffect, useState } from 'react';
5+
import toast from 'react-hot-toast';
6+
import { formatCategoryName } from '../../../../../utils/categoryFormating';
7+
import { convertCategoryNameToURLFriendly } from '../../../../../utils/categoryFormating';
88

99
interface DashboardSingleCategoryProps {
1010
params: { id: number };
@@ -14,34 +14,34 @@ const DashboardSingleCategory = ({
1414
params: { id },
1515
}: DashboardSingleCategoryProps) => {
1616
const [categoryInput, setCategoryInput] = useState<{ name: string }>({
17-
name: "",
17+
name: '',
1818
});
1919
const router = useRouter();
2020

2121
const deleteCategory = async () => {
2222
const requestOptions = {
23-
method: "DELETE",
23+
method: 'DELETE',
2424
};
2525
// sending API request for deleting a category
2626
fetch(`http://localhost:3001/api/categories/${id}`, requestOptions)
2727
.then((response) => {
2828
if (response.status === 204) {
29-
toast.success("Category deleted successfully");
30-
router.push("/admin/categories");
29+
toast.success('Category deleted successfully');
30+
router.push('/admin/categories');
3131
} else {
32-
throw Error("There was an error deleting a category");
32+
throw Error('There was an error deleting a category');
3333
}
3434
})
3535
.catch((error) => {
36-
toast.error("There was an error deleting category");
36+
toast.error('There was an error deleting category');
3737
});
3838
};
3939

4040
const updateCategory = async () => {
4141
if (categoryInput.name.length > 0) {
4242
const requestOptions = {
43-
method: "PUT",
44-
headers: { "Content-Type": "application/json" },
43+
method: 'PUT',
44+
headers: { 'Content-Type': 'application/json' },
4545
body: JSON.stringify({
4646
name: convertCategoryNameToURLFriendly(categoryInput.name),
4747
}),
@@ -52,15 +52,15 @@ const DashboardSingleCategory = ({
5252
if (response.status === 200) {
5353
return response.json();
5454
} else {
55-
throw Error("Error updating a category");
55+
throw Error('Error updating a category');
5656
}
5757
})
58-
.then((data) => toast.success("Category successfully updated"))
58+
.then((data) => toast.success('Category successfully updated'))
5959
.catch((error) => {
60-
toast.error("There was an error while updating a category");
60+
toast.error('There was an error while updating a category');
6161
});
6262
} else {
63-
toast.error("For updating a category you must enter all values");
63+
toast.error('For updating a category you must enter all values');
6464
return;
6565
}
6666
};

app/(dashboard)/admin/categories/new/page.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
"use client";
2-
import { DashboardSidebar } from "@/components";
3-
import React, { useState } from "react";
4-
import toast from "react-hot-toast";
5-
import { convertCategoryNameToURLFriendly } from "../../../../../utils/categoryFormating";
1+
'use client';
2+
import { DashboardSidebar } from '@/components';
3+
import React, { useState } from 'react';
4+
import toast from 'react-hot-toast';
5+
import { convertCategoryNameToURLFriendly } from '../../../../../utils/categoryFormating';
66

77
const DashboardNewCategoryPage = () => {
88
const [categoryInput, setCategoryInput] = useState({
9-
name: "",
9+
name: '',
1010
});
1111

1212
const addNewCategory = () => {
1313
if (categoryInput.name.length > 0) {
1414
const requestOptions = {
15-
method: "post",
16-
headers: { "Content-Type": "application/json" },
15+
method: 'post',
16+
headers: { 'Content-Type': 'application/json' },
1717
body: JSON.stringify({
1818
name: convertCategoryNameToURLFriendly(categoryInput.name),
1919
}),
@@ -24,20 +24,20 @@ const DashboardNewCategoryPage = () => {
2424
if (response.status === 201) {
2525
return response.json();
2626
} else {
27-
throw Error("There was an error while creating category");
27+
throw Error('There was an error while creating category');
2828
}
2929
})
3030
.then((data) => {
31-
toast.success("Category added successfully");
31+
toast.success('Category added successfully');
3232
setCategoryInput({
33-
name: "",
33+
name: '',
3434
});
3535
})
3636
.catch((error) => {
37-
toast.error("There was an error while creating category");
37+
toast.error('There was an error while creating category');
3838
});
3939
} else {
40-
toast.error("You need to enter values to add a category");
40+
toast.error('You need to enter values to add a category');
4141
}
4242
};
4343
return (

app/(dashboard)/admin/categories/page.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
"use client";
2-
import { CustomButton, DashboardSidebar } from "@/components";
3-
import { nanoid } from "nanoid";
4-
import Link from "next/link";
5-
import React, { useEffect, useState } from "react";
6-
import { formatCategoryName } from "../../../../utils/categoryFormating";
1+
'use client';
2+
import { CustomButton, DashboardSidebar } from '@/components';
3+
import { nanoid } from 'nanoid';
4+
import Link from 'next/link';
5+
import React, { useEffect, useState } from 'react';
6+
import { formatCategoryName } from '../../../../utils/categoryFormating';
77

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

1111
// getting all categories to be displayed on the all categories page
1212
useEffect(() => {
13-
fetch("http://localhost:3001/api/categories")
13+
fetch('http://localhost:3001/api/categories')
1414
.then((res) => {
1515
return res.json();
1616
})

0 commit comments

Comments
 (0)