Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Antti/json server #4

Merged
merged 49 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
dad603e
Created a json-server folder. Created a few API tests inside pages fo…
Sep 29, 2023
5af593c
More tests in pages/api and with the json-server
Sep 30, 2023
574b0fa
Merged from Antin-dev
Oct 11, 2023
bad94e3
CSS and json-server tests
Oct 11, 2023
ba91e39
Merged from antti/modal
Nov 1, 2023
d19d5a3
Refactoring index.tsx. Renamed fetchFunctions.tsx to jsonServerFuncti…
Nov 1, 2023
727d27d
Refactoring index.tsx. Cleared the json-server's 'database'. Added a …
Nov 1, 2023
adf6e8e
Refactoring index.tsx and DeleteModal.tsx. Site now loads gifts from …
Nov 9, 2023
ed20f50
Refactoring jsonServerFunctions.ts. Changed the way how getOne functi…
Nov 9, 2023
8b35517
Added remove function to jsonServerFunctions.ts
Nov 9, 2023
f65ba75
Refactoring DeleteModal.tsx
Nov 9, 2023
390648a
Refactoring index.tsx, added more Tailwind animation tests
Nov 9, 2023
b59bc32
Did an ESLint check and fix. Deleted the api folder inside the pages …
Nov 9, 2023
2602e90
Fixed errors ESLint gave. Changed giftListRefrechFunction's return to…
Nov 10, 2023
742f7bb
Created an useState for info modal to tell if the gift was deleted al…
Nov 10, 2023
e722466
Added opacity for Modal to look like it is focused
Nov 28, 2023
53258f0
Added a check if the gift wanted to be deleted exist still in json-se…
Nov 28, 2023
7640b76
Merged from antti/modal to antti/json-server
Dec 18, 2023
b830873
ESLint fixes. Deleted a few type checks that were not needed
Dec 18, 2023
7c4c5ed
Fixed couple promise-returning errors ESLint gave. Changed couple con…
Dec 18, 2023
0ee36ba
Changed db.json to have a real name instead of tests
Dec 19, 2023
4777315
Fixed typos in jsonServerFunctions.ts
Dec 19, 2023
808334a
Moved db.json file to root folder for Vercel's json-server host. Dele…
Dec 21, 2023
417109e
Changed FullLocalStorage type to Gifts_Type to be more clarifying
Jan 8, 2024
5298332
Revert "Changed FullLocalStorage type to Gifts_Type to be more clarif…
Jan 8, 2024
ddeccfc
Changed FullLocalStorage type to Gifts to be more clarifying
Jan 8, 2024
2dfcc78
Changed the way how getAll returns its data. Changed variables types …
Jan 8, 2024
0c6fb70
Changed getOne function to take only ID as a parameter. Changed JSDoc…
Jan 8, 2024
4abe5fa
Changed JSDoc and the way how Update function works in jsonServerFunc…
Jan 8, 2024
54c6bf0
Removed export default when exporting functions in jsonServerFunction…
Jan 8, 2024
5772267
Changed jsonServerFunctions to have gift in their name to make more c…
Jan 9, 2024
33a8c68
Modified JSDoc documentations and added types for return statements i…
Jan 9, 2024
ad30587
Changed module name from create to createGift in index.tsx to make it…
Jan 9, 2024
aabb832
Changed Container component to div element due to no difference
Jan 9, 2024
c498eaa
Deleted Container component due to no usage
Jan 9, 2024
fa7b9ff
Changed fetchData -> fetchGifts. Changed catch function to console.er…
Jan 9, 2024
8bdda47
Changed removeGift's argument to not have template literals in Delete…
Jan 9, 2024
355c0d0
ESLint fixes
Jan 9, 2024
6b4537b
Added "prepush" script to package.json
anttiasmala Jan 9, 2024
d085fc0
Added URLs for localhost and for externals. Localhost url is commente…
anttiasmala Jan 9, 2024
49ad5e8
Changed surname Virtanen to Meikäläinen to be correct placeholder name
anttiasmala Jan 9, 2024
57cdd77
Fixed JSDoc faulty documentation in jsonServerFunctions.ts. Fixed upd…
anttiasmala Jan 12, 2024
01b7d23
Changed Gifts type to Gift
anttiasmala Jan 20, 2024
43138e8
Deleted isGiftDeletedAlreadyType due to no usage
anttiasmala Jan 20, 2024
9f4f6b1
Changed inquality check to strict inequality and getGift function now…
anttiasmala Jan 20, 2024
1247c5f
Merged main branch to antti/json-server branch
anttiasmala Jan 21, 2024
8f179a7
Renamed accept_button_icon.tsx to CheckMarkIcon.tsx
anttiasmala Jan 22, 2024
cca673d
Deleted icons/index.ts due to no usage currently. Changed the way how…
anttiasmala Jan 22, 2024
83311cf
ESLint fixes
anttiasmala Jan 23, 2024
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
8 changes: 0 additions & 8 deletions components/Container.tsx

This file was deleted.

41 changes: 20 additions & 21 deletions components/DeleteModal.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { TitleText } from './TitleText';
import React, { Dispatch, SetStateAction } from 'react';
import { FullLocalStorage } from '~/pages';
import {
getLocalStorage,
setLocalStorage,
} from '~/utils/localStorageFunctions';
import { Gift } from '~/pages';
import { Modal } from './Modal';
import SvgAcceptButtonIcon from '~/icons/accept_button_icon';
import SvgDeclineButtonIcon from '~/icons/decline_button_icon';
import { Button } from './Button';
import { getGift, removeGift } from '~/utils/jsonServerFunctions';
import { SvgCheckMarkIcon } from '~/icons/CheckMarkIcon';
import { SvgDeclineIcon } from '~/icons/DeclineIcon';

type ModalType = {
gift: FullLocalStorage;
gift: Gift;
giftListRefreshFunction: () => void;
setIsModalOpen: Dispatch<SetStateAction<boolean>>;
};
Expand All @@ -21,14 +18,11 @@ export function DeleteModal({
giftListRefreshFunction,
setIsModalOpen,
}: ModalType) {
function handleDeletion() {
let localStorageGifts: FullLocalStorage[] = JSON.parse(
getLocalStorage('giftData'),
);
localStorageGifts = localStorageGifts.filter(
(localStorageGift) => localStorageGift.id !== gift.id,
);
setLocalStorage('giftData', JSON.stringify(localStorageGifts));
async function handleDeletion() {
const giftToBeDeleted = await getGift(gift.id);
if (giftToBeDeleted !== null) {
await removeGift(gift.id);
}
giftListRefreshFunction();
setIsModalOpen(false);
}
Expand All @@ -41,15 +35,20 @@ export function DeleteModal({
<p className="row-start-2 row-end-2 ps-5 pt-5 text-lg w-full h-full font-bold">
{gift.name} - {gift.gift}
</p>
<Button className="border border-yellow-500 mt-3 p-0 row-start-3 row-end-3 col-start-1 col-end-1 w-[64px] h-[64px] bg-gray-300 text-black hover:bg-gray-600 hover:text-yellow-400">
<SvgAcceptButtonIcon
<Button className="border border-yellow-500 mt-3 p-0 row-start-3 row-end-3 col-start-1 col-end-1 w-[66px] h-[66px]">
<SvgCheckMarkIcon
className="bg-gray-300 hover:bg-gray-600 group/checkMarkIcon"
backgroundClassName="fill-black group-hover/checkMarkIcon:fill-yellow-400"
checkMarkClassName="fill-gray-300 group-hover/checkMarkIcon:fill-gray-600"
width={64}
height={64}
onClick={() => handleDeletion()}
onClick={() => void handleDeletion()}
/>
</Button>
<Button className="border border-yellow-500 relative mt-3 p-0 left-32 sm:left-28 row-start-3 row-end-3 col-start-1 col-end-1 w-[64px] h-[64px] bg-gray-300 text-black hover:bg-gray-600 hover:text-yellow-400">
<SvgDeclineButtonIcon
<Button className="border border-yellow-500 relative mt-3 p-0 left-32 sm:left-28 row-start-3 row-end-3 col-start-1 col-end-1 w-[66px] h-[66px] ">
<SvgDeclineIcon
className="group/declineIcon bg-gray-300 hover:bg-gray-600"
backgroundClassName="fill-black group-hover/declineIcon:fill-yellow-400"
width={64}
height={64}
onClick={() => setIsModalOpen(false)}
Expand Down
22 changes: 22 additions & 0 deletions components/InfoModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Modal } from './Modal';
import { TitleText } from './TitleText';

type InfoModalType = {
title: string;
info: string;
};

export function InfoModal({ title, info }: InfoModalType) {
return (
<div>
<Modal>
<TitleText className="row-start-1 row-end-1 ps-5 font-bold">
{title}
</TitleText>
<p className="row-start-2 row-end-2 ps-5 pt-5 text-lg w-full h-full font-bold">
{info}
</p>
</Modal>
</div>
);
}
19 changes: 9 additions & 10 deletions icons/accept_button_icon.tsx → icons/CheckMarkIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import type { SVGProps } from 'react';

type AcceptButtonType = SVGProps<SVGSVGElement> & {
backgroundFill?: string;
checkmarkFill?: string;
type CheckMarkIcon = SVGProps<SVGSVGElement> & {
backgroundClassName?: string;
checkMarkClassName?: string;
};

const SvgAcceptButtonIcon = ({
backgroundFill,
checkmarkFill,
export const SvgCheckMarkIcon = ({
backgroundClassName,
checkMarkClassName,
...rest
}: AcceptButtonType) => (
}: CheckMarkIcon) => (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" {...rest}>
<path
fill={backgroundFill || 'currentColor'}
className={backgroundClassName}
d="M16 2a14 14 0 1 0 14 14A14 14 0 0 0 16 2Zm-2 19.59-5-5L10.59 15 14 18.41 21.41 11l1.596 1.586Z"
/>
<path
fill={checkmarkFill || 'none'}
className={checkMarkClassName}
d="m14 21.591-5-5L10.591 15 14 18.409 21.41 11l1.595 1.585L14 21.591z"
/>
</svg>
);
export default SvgAcceptButtonIcon;
13 changes: 6 additions & 7 deletions icons/decline_button_icon.tsx → icons/DeclineIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import type { SVGProps } from 'react';

type DeclineButtonType = SVGProps<SVGSVGElement> & {
backgroundFill?: string;
type DeclineIcon = SVGProps<SVGSVGElement> & {
backgroundClassName?: string;
};

const SvgDeclineButtonIcon = ({
backgroundFill,
export const SvgDeclineIcon = ({
backgroundClassName,
...rest
}: DeclineButtonType) => (
}: DeclineIcon) => (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" {...rest}>
<path
fill={backgroundFill || 'currentColor'}
className={backgroundClassName}
d="m8.4 17 3.6-3.6 3.6 3.6 1.4-1.4-3.6-3.6L17 8.4 15.6 7 12 10.6 8.4 7 7 8.4l3.6 3.6L7 15.6 8.4 17Zm3.6 5q-2.075 0-3.9-.788t-3.175-2.137q-1.35-1.35-2.137-3.175T2 12q0-2.075.788-3.9t2.137-3.175q1.35-1.35 3.175-2.137T12 2q2.075 0 3.9.788t3.175 2.137q1.35 1.35 2.138 3.175T22 12q0 2.075-.788 3.9t-2.137 3.175q-1.35 1.35-3.175 2.138T12 22Z"
/>
</svg>
);
export default SvgDeclineButtonIcon;
72 changes: 72 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"check-types": "tsc --noemit",
"lint": "(next lint || true) && npm run check-types",
"lint:fix": "next lint --fix",
"start-json-server": "json-server -p3001 --watch db.json",
"prepush": "next lint --max-warnings=0 && npm run check-types",
"svgr": "svgr --out-dir icons --typescript --jsx-runtime automatic --no-dimensions --silent --filename-case snake -- public/images/icons"
},
Expand All @@ -22,6 +23,7 @@
"@types/react": "18.2.21",
"@types/react-dom": "18.2.7",
"autoprefixer": "10.4.15",
"axios": "1.5.1",
"eslint": "8.49.0",
"eslint-config-next": "13.4.19",
"json-server": "0.17.3",
Expand Down
Loading