-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: host database * fix: email link to activate account * feat: account activation page * chore: change error function name
- Loading branch information
1 parent
b45679e
commit 825d14e
Showing
28 changed files
with
231 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './remote-authentication' | ||
export * from './remote-create-account' | ||
export * from './remote-activation' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { HttpClient, HttpStatusCode } from '../protocols/http' | ||
import { Activation } from '../../domain/usecases' | ||
import { Err } from '../../domain/errors' | ||
|
||
export class RemoteActivation implements Activation { | ||
constructor ( | ||
private readonly url: string, | ||
private readonly httpClient: HttpClient<Activation.Model> | ||
) {} | ||
|
||
async activate (params: Activation.Params): Promise<Activation.Model> { | ||
const httpResponse = await this.httpClient.request({ url: this.url, method: 'post', body: params }) | ||
switch (httpResponse.statusCode) { | ||
case HttpStatusCode.ok: return httpResponse.body | ||
default: throw new Err(httpResponse.body.message) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export class Oops extends Error { | ||
export class Err extends Error { | ||
constructor (message: string) { | ||
super(message) | ||
this.name = 'OopsError' | ||
this.name = 'ErrError' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Err } from "@/domain/models" | ||
|
||
export interface Activation { | ||
activate: (params: Activation.Params) => Promise<Activation.Model> | ||
} | ||
|
||
export namespace Activation { | ||
export type Params = { | ||
id: string | ||
} | ||
|
||
export type Model = Err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './authentication' | ||
export * from './create-account' | ||
export * from './activation' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react' | ||
import { useParams } from 'react-router-dom' | ||
|
||
import { ActivationPage } from '../../../presentation/pages' | ||
import { makeRemoteActivation } from '../usecases' | ||
|
||
export const makeActivationPage: React.FC = () => { | ||
const { token } = useParams<{ token: string }>() | ||
return <ActivationPage usecase={makeRemoteActivation(token)}/> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './login-factory' | ||
export * from './home-factory' | ||
export * from './create-account-factory' | ||
export * from './activation-factory' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { makeApiUrl, makeAxiosHttpClient } from '../http' | ||
import { RemoteActivation } from '../../../data/usecases' | ||
import { Activation } from '../../../domain/usecases' | ||
|
||
export const makeRemoteActivation = (token: string): Activation => | ||
new RemoteActivation(makeApiUrl(`auth/activation/${token}`), makeAxiosHttpClient()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './remote-authentication-factory' | ||
export * from './remote-register-factory' | ||
export * from './activation-factory' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { atom } from 'recoil' | ||
|
||
export const activationState = atom({ | ||
key: 'activationState', | ||
default: { | ||
isLoading: false, | ||
errorMessage: '' | ||
} | ||
}) |
12 changes: 12 additions & 0 deletions
12
ui/src/presentation/pages/activation/components/form-status.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react' | ||
import { useRecoilValue } from 'recoil' | ||
|
||
import { activationState } from './atoms' | ||
import { FormStatusBase } from '../../../../presentation/components' | ||
|
||
const FormStatus: React.FC = () => { | ||
const state = useRecoilValue(activationState) | ||
return <FormStatusBase errorMessage={state.errorMessage} /> | ||
} | ||
|
||
export default FormStatus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React, { useEffect } from 'react' | ||
import { Activation } from '@/domain/usecases/activation' | ||
import { useRecoilState, useResetRecoilState } from 'recoil' | ||
import { activationState } from './components/atoms' | ||
import FormStatus from './components/form-status' | ||
import { Link } from 'react-router-dom' | ||
|
||
type Props = { | ||
usecase: Activation | ||
} | ||
|
||
const ActivationPage: React.FC<Props> = ({ usecase }: Props) => { | ||
const resetActivationState = useResetRecoilState(activationState) | ||
const [state, setState] = useRecoilState(activationState) | ||
|
||
useEffect(() => { | ||
resetActivationState() | ||
handleSubmit() | ||
}, []) | ||
|
||
const handleSubmit = async (): Promise<void> => { | ||
try { | ||
if (state.isLoading) return | ||
setState((old) => ({ ...old, isLoading: true })) | ||
await usecase.activate({ id: 'asdasdasd' }) | ||
} catch (error: any) { | ||
setState((old) => ({ ...old, isLoading: false, errorMessage: error.message })) | ||
} | ||
} | ||
|
||
return ( | ||
<section className='h-screen flex justify-center items-center bg-pink-50'> | ||
{state.errorMessage === '' && ( | ||
<div className='space-y-6 bg-white p-12 rounded-sm shadow-sm'> | ||
<p className='mb-4 text-base'>Activation successful! now you can login.</p> | ||
<Link to='/auth/login'><p className='text-blue-500'>Login</p></Link> | ||
</div> | ||
)} | ||
<FormStatus /> | ||
</section> | ||
) | ||
} | ||
|
||
export default ActivationPage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { default as LoginPage } from './login/login' | ||
export { default as LoginPage } from './login' | ||
export { default as CreateAccountPage } from './create-account' | ||
export { default as ActivationPage } from './activation' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
825d14e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
power-sso – ./
power-sso.vercel.app
power-sso-isaqueveras.vercel.app
power-sso-git-main-isaqueveras.vercel.app