Skip to content

Commit a36df98

Browse files
readme updated, userInfo props added, bug fixed
1 parent 4b9e789 commit a36df98

File tree

14 files changed

+247
-195
lines changed

14 files changed

+247
-195
lines changed

README.md

+27
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class Example extends Component {
5959
render() {
6060
return (
6161
<BlinkApp
62+
userInfo={{ Header: 'startup_name', accessor: 'startup_id' }}
6263
screen={'startupScreen'}
6364
view={'homeView'}
6465
page={'metrics'}
@@ -74,6 +75,32 @@ class Example extends Component {
7475

7576
1. All the props passed here are stored in a global Object with the help of context API and can be accessed anywhere in the app.
7677
2. **screen**,**view**,**page** props are used for in app navigation. Pass the correct values to load the required page.
78+
3. Pass name and id of startup/investor in the format shown above in **userInfo** props.
79+
80+
## Overall Structure of BlinkApp
81+
82+
Pass following values to **screen**,**view**,**page** props to load required pages accordingly
83+
84+
### Screen => startupScreen:
85+
86+
- #### View => home
87+
- page => metrics
88+
- page => notes
89+
- #### View => tables
90+
- page => revenue
91+
- page => expenses
92+
- page => employee
93+
- page => notes
94+
- #### View => settings
95+
- page => profile
96+
97+
### Screen => investorScreen
98+
99+
- #### View => dashboard
100+
- page => metrics
101+
- page => notes
102+
- #### View => settings
103+
- page => profile
77104

78105
## License
79106

example/src/App.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ import React from 'react'
22

33
import { BlinkApp } from 'blink-npm'
44
import 'blink-npm/dist/index.css'
5+
const token = `Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3N1ZXIiOiJoYWNrc3RyYXAiLCJhdWRpZW5jZSI6Imh0dHBzOi8vaGFja3N0cmFwLmNvbSIsImFsZ29yaXRobXMiOlsiSFMyNTYiXSwiY2xhaW1zIjp7Im9yZyI6ImhhY2tzdHJhcCJ9LCJpYXQiOjE2MjQ3ODkwNTd9.Dmo2eZKUtAOD7o7UPopoKRgma2jbESyYos8HKdU_tXk`
6+
const mainRoute = 'https://blink.hackstrap.com/'
57

68
const App = () => {
79
return (
810
<BlinkApp
11+
userInfo={{ Header: 'Startup 1', accessor: 'startup-1slug' }}
912
screen={'startupScreen'}
1013
view={'homeView'}
1114
page={'metrics'}
12-
apiRoute={''}
13-
token={''}
15+
apiRoute={mainRoute}
16+
token={token}
1417
/>
1518
)
1619
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hackstrap/blink-npm",
3-
"version": "1.0.10",
3+
"version": "1.0.11",
44
"description": "This repo contains the code for blink npm pakage",
55
"author": "AbhijeetNandvikar",
66
"license": "MIT",

src/AppContext.tsx

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React, { createContext, useState } from 'react'
2+
import { OptionInterface } from './Components/interfaces'
23
interface IProps {
34
children: React.ReactNode
4-
userInfo?: object
5+
userInfo: OptionInterface
56
screen?: string
67
view?: string
78
page?: string
@@ -12,6 +13,7 @@ interface IProps {
1213
interface ValueInterface {
1314
// auth: object | undefined;
1415
// setAuth: Function;
16+
userInfo: OptionInterface | undefined
1517
setCurrentScreen: Function
1618
setCurrentView: Function
1719
setCurrentPage: Function
@@ -24,10 +26,10 @@ interface ValueInterface {
2426
export const globalContext = React.createContext<ValueInterface | null>(null)
2527

2628
const AppContext = (props: IProps) => {
27-
const [auth, setAuth] = useState<object | undefined>(props.userInfo)
28-
// const [currentScreen, setCurrentScreen] = useState(
29-
// props?.view ? props.view : 'startupScreen'
30-
// )
29+
const [userInfo, setUserInfo] = useState<OptionInterface | undefined>(
30+
props.userInfo
31+
)
32+
3133
const [currentScreen, setCurrentScreen] = React.useState<string | undefined>(
3234
props.screen
3335
)
@@ -52,8 +54,7 @@ const AppContext = (props: IProps) => {
5254
return (
5355
<globalContext.Provider
5456
value={{
55-
// auth,
56-
// setAuth,
57+
userInfo,
5758
currentScreen,
5859
setCurrentScreen,
5960
currentView,

src/Components/InvestorScreen/Dashboard/MetricsPage/MetricsPage.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ const MetricsPage = (props: PropsInterface) => {
9393
setChartInfo(chartData);
9494
})
9595
.catch((err) => console.log(err));
96-
}, []);
96+
}, [props.selectedStartup]);
9797

9898
return (
9999
<div>

src/Components/InvestorScreen/Dashboard/NotesPage/NotesPage.tsx

+6-5
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ const NotesPage = (props: PropsInterface) => {
102102
} else {
103103
console.log("note not avaliable, init empty note");
104104
setnoteData({
105-
note_name: "Investor Update",
105+
note_name: "No Data Avaliable",
106106
month: new Date().getMonth() + 1,
107-
note_data: "<p>Hello</p>",
107+
note_data: "<p>No Data Avaliable</p>",
108108
email_status: false,
109109
investor_view: false,
110110
last_emailed: "",
111111
last_updated: "",
112112
year: 2021,
113-
startup_id: "startup-1slug",
113+
startup_id: "",
114114
});
115115
}
116116
})
@@ -154,8 +154,9 @@ const NotesPage = (props: PropsInterface) => {
154154
currentMonth={currentMonth}
155155
setCurrentMonth={(month: string) => setCurrentMonth(month)}
156156
setNoteData={(val: NoteDataInterface) => setnoteData(val)}
157-
noteData={noteData}
158-
saveChangeHandler={(val: NoteDataInterface) => updateData(val)}
157+
noteData={null}
158+
saveChangeHandler={(val: NoteDataInterface) => {}}
159+
preview={noteData}
159160
/>
160161
) : (
161162
<CircularProgress />

src/Components/InvestorScreen/InvestorScreen.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ const InvestorScreen = () => {
106106
const renderCurrentView = (view: string | undefined) => {
107107
switch (view) {
108108
case "settings":
109-
return (
110-
<SettingsView
111-
investorInfo={{ Header: "investor 1", accessor: "investor-1slug" }}
112-
/>
109+
return appContext?.userInfo ? (
110+
<SettingsView investorInfo={appContext?.userInfo} />
111+
) : (
112+
<div></div>
113113
);
114114
// case "portfolio":
115115
// return <Portfolio />;
@@ -133,7 +133,7 @@ const InvestorScreen = () => {
133133
appContext?.token,
134134
"investment",
135135
"",
136-
"investor-1slug"
136+
appContext?.userInfo?.accessor
137137
)
138138
.then((res) => {
139139
let options = extractStartupsInvested(res.data);

src/Components/StartupScreen/HomeView/HomeView.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ const HomeView = () => {
7373
const renderCurrentPage = (page: string | undefined) => {
7474
switch (page) {
7575
case "notes":
76-
return (
77-
<NotesPage
78-
selectedStartup={{ Header: "Startup 1", accessor: "startup-1slug" }}
79-
/>
76+
return appContext?.userInfo ? (
77+
<NotesPage selectedStartup={appContext.userInfo} />
78+
) : (
79+
<div></div>
8080
);
8181
default:
82-
return (
83-
<MetricsPage
84-
selectedStartup={{ Header: "Startup 1", accessor: "startup-1slug" }}
85-
/>
82+
return appContext?.userInfo ? (
83+
<MetricsPage selectedStartup={appContext.userInfo} />
84+
) : (
85+
<div></div>
8686
);
8787
}
8888
};

src/Components/StartupScreen/SettingsView/SettingsView.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ const SettingsView = () => {
7575
const renderCurrentPage = (page: string | undefined) => {
7676
switch (page) {
7777
case "profile":
78-
return (
79-
<ProfileSettings
80-
selectedStartup={{ Header: "Startup 1", accessor: "startup-1slug" }}
81-
/>
78+
return appContext?.userInfo ? (
79+
<ProfileSettings selectedStartup={appContext.userInfo} />
80+
) : (
81+
<div></div>
8282
);
8383
default:
8484
return <div></div>;

0 commit comments

Comments
 (0)