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

Revamp: Journal Page #1939

Merged
merged 27 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f0247bf
fix: getJustDate arg in feeling hook
Tushar-4781 Jun 23, 2024
0d56f13
pruned: feelings collectio api(s)
Tushar-4781 Jun 24, 2024
50ac0d1
created: loading container
Tushar-4781 Jun 24, 2024
646cad3
patch: infinte animation of zz logo
Tushar-4781 Jun 24, 2024
1d1fada
added: react 18, react query in deps
Tushar-4781 Jun 24, 2024
f73e375
migration: react 17 -> 18 and react query setup
Tushar-4781 Jun 24, 2024
323cdc5
defined: type of feeling emojis map
Tushar-4781 Jun 24, 2024
fd6bbce
made: onCancel optional for Zmodal
Tushar-4781 Jun 24, 2024
f877e04
added: feelings object types
Tushar-4781 Jun 24, 2024
2f5b15d
added: bottom padding in app layout
Tushar-4781 Jun 24, 2024
6b4aa1c
pruned global.scss
Tushar-4781 Jun 24, 2024
8026abc
custom handy classes
Tushar-4781 Jun 24, 2024
7bdffda
added: journal page helper fns
Tushar-4781 Jun 24, 2024
380652e
removed: dead code
Tushar-4781 Jun 24, 2024
1c58ece
revamp: add feeling component
Tushar-4781 Jun 24, 2024
4081de5
developed: feeling component
Tushar-4781 Jun 24, 2024
ed963d6
revamped: note modal
Tushar-4781 Jun 24, 2024
799e3df
revamped: feelings page
Tushar-4781 Jun 24, 2024
f8f7e55
patch: made nav props in subheader optional
Tushar-4781 Jun 24, 2024
c228ea4
fix: subheader alignment
Tushar-4781 Jun 24, 2024
b1c2abe
pruned: css
Tushar-4781 Jun 24, 2024
947a2e9
pruned: css
Tushar-4781 Jun 24, 2024
fe1f2b0
changed: journal page component name
Tushar-4781 Jun 24, 2024
0501c42
removed: dead code
Tushar-4781 Jun 24, 2024
31534bc
fix: Eslint warning
Tushar-4781 Jun 24, 2024
449e26e
fix: date bug
Tushar-4781 Jun 24, 2024
8d8b749
fix: alignment issue
Tushar-4781 Jun 24, 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
408 changes: 280 additions & 128 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
"i18next": "^21.6.11",
"i18next-browser-languagedetector": "^6.1.3",
"moment": "^2.30.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-i18next": "^11.15.4",
"react-router-dom": "^6.2.1",
"react-query": "^3.39.3",
"react-router-dom": "^6.23.1",
"recoil": "^0.7.1",
"regenerator-runtime": "^0.13.9",
"sass": "^1.50.0",
Expand Down
27 changes: 19 additions & 8 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
import { notification } from "antd";
import React, { useEffect } from "react";
import { notification } from "antd";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import { useRecoilState, useRecoilValue } from "recoil";
import { darkModeState, displayToast, backupRestoreModal, languageChangeModal } from "@store";

import lightAvatar from "@assets/images/mainAvatarLight.svg";
import darkAvatar from "@assets/images/mainAvatarDark.svg";

import { FAQPage } from "@pages/FAQPage/FAQPage";
import { MyTimePage } from "@pages/MyTimePage/MyTimePage";
import { LandingPage } from "@pages/LandingPage/LandingPage";
import { FeedbackPage } from "@pages/FeedbackPage/FeedbackPage";
import { ShowFeelingsPage } from "@pages/ShowFeelingsPage/ShowFeelingsPage";
import GoalsPage from "@pages/GoalsPage/GoalsPage";
import InvitePage from "@pages/InvitePage/InvitePage";
import InvestPage from "@pages/InvestPage/InvestPage";
import BackupRestoreModal from "@components/BackupRestoreModal";

import { FAQPage } from "@pages/FAQPage/FAQPage";
import { MyTimePage } from "@pages/MyTimePage/MyTimePage";
import { LandingPage } from "@pages/LandingPage/LandingPage";
import { FeedbackPage } from "@pages/FeedbackPage/FeedbackPage";
import { FeelingsPage } from "@pages/FeelingsPage/FeelingsPage";
import { LanguageChangeModal } from "@components/LanguageChangeModal/LanguageChangeModal";

import useApp from "./hooks/useApp";
import AppLayout from "./layouts/AppLayout";
import { themeState } from "./store/ThemeState";

import "./global.scss";
import "./customize.scss";
import "./override.scss";
import useApp from "./hooks/useApp";
import "./short.scss";

const Context = React.createContext({ name: "Default" });

Expand Down Expand Up @@ -77,7 +81,14 @@ const App = () => {
)}
<Route path="/Feedback" element={<FeedbackPage />} />
<Route path="/MyGoals" element={<GoalsPage />} />
<Route path="/MyJournal" element={<ShowFeelingsPage />} />
<Route
path="/MyJournal"
element={
<AppLayout title="myJournal">
<FeelingsPage />
</AppLayout>
}
/>
<Route path="*" element={<GoalsPage />} />
<Route path="/ZinZenFAQ" element={<FAQPage />} />
<Route path="/invite/:id" element={<InvitePage />} />
Expand Down
10 changes: 5 additions & 5 deletions src/Interfaces/ICommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface ZModalProps {
children: React.ReactNode;
type?: string;
open: boolean;
onCancel: () => void;
onCancel?: () => void;
width?: number;
style?: React.CSSProperties;
}
Expand All @@ -35,10 +35,10 @@ export interface ColorPaletteProps {

export interface ISubHeaderProps {
title: string;
leftNav: () => void;
rightNav: () => void;
showLeftNav: boolean;
showRightNav: boolean;
leftNav?: () => void;
rightNav?: () => void;
showLeftNav?: boolean;
showRightNav?: boolean;
}

export interface IconProps {
Expand Down
14 changes: 14 additions & 0 deletions src/Providers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React, { ReactNode } from "react";
import { QueryClient, QueryClientProvider } from "react-query";
import { RecoilRoot } from "recoil";

const Providers = ({ children }: { children: ReactNode }) => {
const queryClient = new QueryClient();
return (
<RecoilRoot>
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
</RecoilRoot>
);
};

export default Providers;
108 changes: 15 additions & 93 deletions src/api/FeelingsAPI/index.ts
Original file line number Diff line number Diff line change
@@ -1,106 +1,28 @@
import { db, IFeelingItem } from "@models";
import { getJustDate } from "@src/utils";

export const getFeeling = async (feelingId: number) => {
db.transaction("rw", db.feelingsCollection, async () => {
const feeling = await db.feelingsCollection.get(feelingId);
return feeling;
}).catch((e) => {
console.log(e.stack || e);
});
export const fetchFeelings = async ({ pageParam = 1 }) => {
const limit = 6;
const offset = (pageParam - 1) * limit;
const feelings = await db.feelingsCollection.orderBy("date").reverse().offset(offset).limit(limit).toArray();
return { feelings, nextPage: pageParam + 1 };
};

export const removeFeeling = (feelingId: number) => {
db.transaction("rw", db.feelingsCollection, async () => {
await db.feelingsCollection.delete(feelingId);
}).catch((e) => {
console.log(e.stack || e);
});
export const addFeeling = async (feeling: Omit<IFeelingItem, "id">) => {
return db.feelingsCollection.add(feeling);
};

export const getAllFeelings = async () => {
const allFeelings = await db.feelingsCollection.toArray();
return allFeelings;
export const getFeelings = async () => {
return db.feelingsCollection.toArray();
};

export const getFeelingsOnDate = async (date: Date) => {
let feelingsList: IFeelingItem[] = [];
await db
.transaction("rw", db.feelingsCollection, async () => {
feelingsList = await db.feelingsCollection.where("date").equals(date).toArray();
})
.catch((e) => {
console.log(e.stack || e);
});
return feelingsList;
export const getFeelingById = async (id: number) => {
return db.feelingsCollection.get(id);
};

export const addFeelingWithNote = async (
feelingName: string,
feelingCategory: string,
feelingDate: Date,
feelingNote: string,
) => {
// const currentDate = getJustDate(new Date());
const feelingDateFormatted = getJustDate(feelingDate);
const currentDateFeelings = await getFeelingsOnDate(feelingDate);
const checkFeelings = (feeling: IFeelingItem) => feeling.content === feelingName;
if (currentDateFeelings.some(checkFeelings)) {
return;
}
db.transaction("rw", db.feelingsCollection, async () => {
await db.feelingsCollection.add({
content: feelingName,
date: feelingDateFormatted,
category: feelingCategory,
note: feelingNote,
});
}).catch((e) => {
console.log(e.stack || e);
});
export const updateFeeling = async (id: number, updatedFeeling: Partial<IFeelingItem>) => {
return db.feelingsCollection.update(id, updatedFeeling);
};

export const addFeeling = async (feelingName: string, feelingCategory: string, feelingDate: Date) => {
// const currentDate = getJustDate(new Date());
const feelingDateFormatted = getJustDate(feelingDate);
const currentDateFeelings = await getFeelingsOnDate(feelingDate);
const checkFeelings = (feeling: IFeelingItem) => feeling.content === feelingName;
if (currentDateFeelings.some(checkFeelings)) {
return;
}
db.transaction("rw", db.feelingsCollection, async () => {
await db.feelingsCollection.add({ content: feelingName, date: feelingDateFormatted, category: feelingCategory });
}).catch((e) => {
console.log(e.stack || e);
});
};

export const addFeelingNote = async (feelingId: number, InputNote: string) => {
const feeling = await db.feelingsCollection.get(feelingId);
const updatedFeeling = { ...feeling, note: InputNote };
let updatedFeelingsList;
await db
.transaction("rw", db.feelingsCollection, async () => {
await db.feelingsCollection.put(updatedFeeling as IFeelingItem);
updatedFeelingsList = await getAllFeelings();
})
.catch((e) => {
console.log(e.stack || e);
});
return updatedFeelingsList;
};

export const removeFeelingNote = async (feelingId: number) => {
const feeling = await db.feelingsCollection.get(feelingId);
delete feeling?.note;
let updatedFeelingsList;
await db
.transaction("rw", db.feelingsCollection, async () => {
await db.feelingsCollection.put(feeling!);
updatedFeelingsList = await getAllFeelings();
})
.catch((e) => {
console.log(e.stack || e);
});
return updatedFeelingsList;
export const deleteFeeling = async (id: number) => {
return db.feelingsCollection.delete(id);
};
19 changes: 19 additions & 0 deletions src/common/LoadingContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from "react";
import zinzenLightLogo from "@assets/images/zinzenLightLogo.svg";

const LoadingContainer = () => {
return (
<div
className="place-middle f-col gap-8"
style={{
gap: 8,
height: "100%",
}}
>
<img className="logo-flip" src={zinzenLightLogo} alt="ZinZen" />
<p>loading...</p>
</div>
);
};

export default LoadingContainer;
2 changes: 1 addition & 1 deletion src/common/SubHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import chevronLeftIcon from "@assets/images/chevronLeft.svg";

import { ISubHeaderProps } from "@src/Interfaces/ICommon";

const NavBtn = ({ show, className, handleClick }: { show: boolean; className: string; handleClick: () => void }) => (
const NavBtn = ({ show, className, handleClick }: { show?: boolean; className: string; handleClick?: () => void }) => (
<Col span={6} style={{ textAlign: "center", alignSelf: "center" }}>
{show && (
<button type="button" className="ordinary-element" onClick={handleClick}>
Expand Down
59 changes: 0 additions & 59 deletions src/components/FeelingsComponents/AddFeeling.scss

This file was deleted.

Loading
Loading