Skip to content

Commit e3067aa

Browse files
authored
Merge pull request #1855 from mertbagt/login-page
Login page
2 parents 4a94aae + e8846ec commit e3067aa

File tree

7 files changed

+59
-17
lines changed

7 files changed

+59
-17
lines changed

components/EditProfilePage/EditProfilePage.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
} from "./StyledEditProfileComponents"
2626
import { TestimoniesTab } from "./TestimoniesTab"
2727
import { useFlags } from "components/featureFlags"
28+
import LoginPage from "components/Login/login"
2829
import { PendingUpgradeBanner } from "components/PendingUpgradeBanner"
2930

3031
const tabTitle = ["about-you", "testimonies", "following"] as const
@@ -39,14 +40,18 @@ export default function EditProfile({
3940
const uid = user?.uid
4041
const result = useProfile()
4142

42-
if (result.loading) {
43+
if (result.loading && uid) {
4344
return (
4445
<Row>
4546
<Spinner animation="border" className="mx-auto" />
4647
</Row>
4748
)
4849
}
4950

51+
if (result.loading) {
52+
return <LoginPage />
53+
}
54+
5055
if (result?.profile && uid) {
5156
return (
5257
<EditProfileForm
@@ -57,8 +62,6 @@ export default function EditProfile({
5762
/>
5863
)
5964
}
60-
61-
// Todo add error handling/404 page?
6265
}
6366

6467
export function EditProfileForm({

components/Login/login.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { useTranslation } from "next-i18next"
2+
import styled from "styled-components"
3+
import { Container } from "../bootstrap"
4+
import { SignInWithButton } from "components/auth"
5+
6+
export default function LoginPage() {
7+
const { t } = useTranslation("auth")
8+
9+
const StyledContainer = styled(Container)`
10+
@media (min-width: 768px) {
11+
}
12+
`
13+
14+
return (
15+
<StyledContainer>
16+
<div className={`bg-white my-3 overflow-hidden rounded-3`}>
17+
<div className={`align-items-center d-flex px-2 pt-2 pb-0`}>
18+
<div className={`px-3 py-0`}>
19+
<div className={`align-items-start fs-5 lh-sm mb-1 text-secondary`}>
20+
{t("probablySignedOut")}
21+
</div>
22+
<br />
23+
<div className={`align-items-start fs-5 lh-sm mb-1 text-secondary`}>
24+
{t("pleaseConsider")}
25+
</div>
26+
<br />
27+
<div className={`justify-content-center d-flex w-100`}>
28+
<SignInWithButton />
29+
</div>
30+
<br />
31+
</div>
32+
</div>
33+
</div>
34+
</StyledContainer>
35+
)
36+
}

components/Newsfeed/Newsfeed.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import ErrorPage from "next/error"
22
import { Timestamp } from "firebase/firestore"
33
import { useTranslation } from "next-i18next"
4-
import { useContext, useEffect, useState } from "react"
4+
import { useEffect, useState } from "react"
55
import { useAuth } from "../auth"
66
import { Col, Row, Spinner } from "../bootstrap"
77
import { Profile, useProfile, usePublicProfile } from "../db"
@@ -14,6 +14,7 @@ import {
1414
StyledContainer
1515
} from "./StyledNewsfeedComponents"
1616
import ProfileSettingsModal from "components/EditProfilePage/ProfileSettingsModal"
17+
import LoginPage from "components/Login/login"
1718
import { NewsfeedCard } from "components/NewsfeedCard/NewsfeedCard"
1819
import { ProfileButtons } from "components/ProfilePage/ProfileButtons"
1920

@@ -22,7 +23,7 @@ export default function Newsfeed() {
2223

2324
const { user } = useAuth()
2425
const uid = user?.uid
25-
const { result: profile, loading } = usePublicProfile(uid)
26+
const result = useProfile()
2627
const isUser = user?.uid !== undefined
2728

2829
const [isShowingOrgs, setIsShowingOrgs] = useState<boolean>(true)
@@ -191,20 +192,20 @@ export default function Newsfeed() {
191192

192193
return (
193194
<>
194-
{loading ? (
195+
{result.loading && uid ? (
195196
<Row>
196197
<Spinner animation="border" className="mx-auto" />
197198
</Row>
198199
) : (
199200
<>
200-
{profile ? (
201+
{result.profile ? (
201202
<div className={`d-flex align-self-center`}>
202203
<StyledContainer>
203204
<Header>
204205
<HeaderTitle className={`mb-4`}>
205206
{t("navigation.newsfeed")}
206207
</HeaderTitle>
207-
<Filters profile={profile} />
208+
<Filters profile={result.profile} />
208209
</Header>
209210
{filteredResults.length > 0 ? (
210211
<>
@@ -237,9 +238,9 @@ export default function Newsfeed() {
237238
<>
238239
<div className="pb-4">
239240
<NewsfeedCard
240-
header={`No Results`}
241+
header={t("noResults")}
241242
timestamp={Timestamp.now()}
242-
bodyText={`There are no news updates for your current followed topics`}
243+
bodyText={t("noNewsUpdates")}
243244
type={``}
244245
/>
245246
</div>
@@ -251,7 +252,8 @@ export default function Newsfeed() {
251252
</StyledContainer>
252253
</div>
253254
) : (
254-
<ErrorPage statusCode={404} withDarkMode={false} />
255+
// <ErrorPage statusCode={404} withDarkMode={false} />
256+
<LoginPage />
255257
)}
256258
</>
257259
)}

components/auth/SignInModal.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useEffect } from "react"
2-
import type { ModalProps } from "react-bootstrap"
32
import { useForm } from "react-hook-form"
43
import { Alert, Button, Col, Form, Modal, Stack } from "../bootstrap"
54
import { LoadingButton } from "../buttons"

pages/edit-profile/[[...docName]].tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ const Query = z.object({
1414

1515
export default createPage({
1616
title: "Edit Profile",
17-
Page: requireAuth(({ user }) => {
17+
Page: () => {
18+
// Page: requireAuth(({ user }) => {
1819
const tabTitle = Query.parse(useRouter().query).docName?.[0] || "about-you"
1920
return <EditProfile tabTitle={tabTitle as TabTitles} />
20-
})
21+
}
2122
})
2223

2324
export const getStaticPaths: GetStaticPaths = async ctx => {

public/locales/en/auth.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"subscribeNewsletter": "Click here to subscribe to our newsletter",
5555
"verifyEmail": "Verify your email address",
5656
"verifyLinkSent": "Please verify your email for your account by clicking the verification link we sent to your email. You will be required to verify your email before submitting testimony.",
57-
"setUpProfile": "Set Up Your Profile"
58-
59-
57+
"setUpProfile": "Set Up Your Profile",
58+
"probablySignedOut": "You were possibly signed out while trying to go to a page that needs to be signed in to function",
59+
"pleaseConsider": "Please consider logging in first:"
6060
}

public/locales/en/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
},
9898
"notInCommittee": "Bill not currently in committee",
9999
"noResults": "No Results",
100+
"noNewsUpdates": "There are no news updates for your current followed topics",
100101
"orgs": "Organizations",
101102
"partners": {
102103
"header": "Our Partners",

0 commit comments

Comments
 (0)