Skip to content

Commit

Permalink
Merge pull request #663 from vselvarajijay/hexagonal
Browse files Browse the repository at this point in the history
wip: setting up local env
  • Loading branch information
vselvarajijay committed Jun 3, 2024
2 parents 0daa018 + 1629420 commit 0c1709d
Show file tree
Hide file tree
Showing 126 changed files with 174 additions and 5,019 deletions.
2 changes: 0 additions & 2 deletions apps/registry/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ COPY ./packages ./packages
WORKDIR /apps/registry

RUN rm -rf node_modules

RUN pnpm i


EXPOSE 5173

CMD ["pnpm", "dev"]
Expand Down
4,704 changes: 0 additions & 4,704 deletions apps/registry/pnpm-lock.yaml

This file was deleted.

42 changes: 0 additions & 42 deletions apps/registry/src/App.css

This file was deleted.

160 changes: 2 additions & 158 deletions apps/registry/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,155 +1,18 @@
import {
ReportsPage,
RegistrySecurityPage,
ReferPatientStepper,
PatientReferralPage,
RegistryShell,
UserAccountShell,
RegistryCollectionShell,
NothingFoundBackground,
ChangePasswordPage,
PaymentCompleted,
MeasurementsPage,
} from '@akello/react';
import { Registry } from '@akello/core';
import { AccountService } from '@akello/account';

import { useLocation } from 'react-router-dom';
import { useNavigate } from 'react-router';
import { Outlet } from 'react-router-dom'
import React from 'react';
import { Routes, Route } from "react-router-dom";
import { useEffect, useState } from 'react';
import { Amplify } from 'aws-amplify';
import { ThemeProvider } from '@aws-amplify/ui-react';
import { theme } from './theme';
import '@aws-amplify/ui-react/styles.css';
import { RegistryPage } from '@akello/react';
import { AkelloClient } from '@akello/client';
import './App.css';

import {
withAuthenticator,
useAuthenticator,
} from '@aws-amplify/ui-react';
import { useAkello } from '@akello/react-hook';



Amplify.configure({
Auth: {
Cognito: {
userPoolClientId: import.meta.env.VITE_AWS_COGNITO_APP_CLIENT_ID,
userPoolId: import.meta.env.VITE_AWS_COGNITO_USERPOOL_ID,
loginWith: {
oauth: {
domain: import.meta.env.VITE_AWS_COGNITO_OAUTH_DOMAIN,
providers: ['Google'],
scopes: ["phone", "email", "profile", "openid"],
responseType: 'code',
redirectSignIn: [
import.meta.env.VITE_AWS_COGNITO_SIGNIN_URL,
],
redirectSignOut: [
import.meta.env.VITE_AWS_COGNITO_SIGNOUT_URL,
],
},
email: true,
}
}
}
});


const theme = {
name: 'custom-theme',
overrides: [
{
colorMode: 'dark',
tokens: {
components: {
authenticator: {
modal: {
background: {
color: 'rgba(28,25,23,1)',
}
}
},
tabs: {
item: {
active: {
color: '{colors.black}',
border: {
color: '{colors.black}',
}
}
}
},
button: {
primary: {
background: {
color: '{colors.black}',
}
}
}
},
},
},
],
};

async function currentSession(akello: AkelloClient) {
try {
const { accessToken, idToken } = (await fetchAuthSession()).tokens ?? {};

akello.setAccessToken(accessToken?.toString())

akello.setProfileInfo(
idToken!.payload.given_name,
idToken!.payload.family_name,
idToken!.payload.picture,
idToken!.payload.email
)

} catch (err) {
console.log(err);
}
}

const App = () => {
const [tokenLoaded, setTokenLoaded] = React.useState(false);
const [themeMode, setThemeMode] = useState('');
const { authStatus } = useAuthenticator(context => [context.authStatus]);
const { pathname } = useLocation();
const akello = useAkello();
const navigate = useNavigate();
const patient_id = akello.getSelectedPatientRegistry()?.id;


useEffect(() => {
currentSession(akello).then(() => {
setTokenLoaded(true)
})
})

useEffect(() => {
if(!tokenLoaded) {
return;
}
akello.userService.getUser((data: any) => {

akello.registryService.getRegistry(data.selected_registry.registry_id, (registry_data: any) => {
const registry = new Registry(registry_data.id, registry_data.organization_id, registry_data.name, registry_data.logo)
akello.selectRegistry(registry);
akello.dispatchEvent({ type: 'change' });


}, (error: any) => {
console.log(error)
})
})
}, [tokenLoaded])



useEffect(() => {
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
Expand All @@ -168,12 +31,6 @@ const App = () => {
};
}, []);


if(!tokenLoaded) {
return <></>
}


if(authStatus === 'configuring') {
return <></>
}
Expand All @@ -182,23 +39,10 @@ const App = () => {
return <>not authenticated</>
}


return (
<ThemeProvider theme={theme} colorMode={themeMode}>
<Routes>
<Route path="/" element={
<>
<UserAccountShell
navigate={navigate}
pathname={pathname}
Outlet={Outlet}
signOut={() => {}}
stripe_checkout_url={import.meta.env.VITE_STRIPE_CHECKOUT_URL}
stripe_portal_url={import.meta.env.VITE_STRIPE_CUSTOMER_PORTAL}
/>
</>}>
<Route index element={<RegistryPage drawerHandlers={() => {}} onNavigate={(path: string) => navigate(path)} patient_id={patient_id} />} />
</Route>
<Route path="/" element={<>root</>} />
</Routes>
</ThemeProvider>
);
Expand Down
26 changes: 26 additions & 0 deletions apps/registry/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,32 @@ import { Authenticator } from '@aws-amplify/ui-react';
import { AkelloProvider } from '@akello/react-hook'
import { akello } from './client.ts'
import { BrowserRouter } from 'react-router-dom';
import { Amplify } from 'aws-amplify';


Amplify.configure({
Auth: {
Cognito: {
userPoolClientId: import.meta.env.VITE_AWS_COGNITO_APP_CLIENT_ID,
userPoolId: import.meta.env.VITE_AWS_COGNITO_USERPOOL_ID,
loginWith: {
oauth: {
domain: import.meta.env.VITE_AWS_COGNITO_OAUTH_DOMAIN,
providers: ['Google'],
scopes: ["phone", "email", "profile", "openid"],
responseType: 'code',
redirectSignIn: [
import.meta.env.VITE_AWS_COGNITO_SIGNIN_URL,
],
redirectSignOut: [
import.meta.env.VITE_AWS_COGNITO_SIGNOUT_URL,
],
},
email: true,
}
}
}
});


ReactDOM.createRoot(document.getElementById('root')!).render(
Expand Down
36 changes: 36 additions & 0 deletions apps/registry/src/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export const theme = {
name: 'custom-theme',
overrides: [
{
colorMode: 'dark',
tokens: {
components: {
authenticator: {
modal: {
background: {
color: 'rgba(28,25,23,1)',
}
}
},
tabs: {
item: {
active: {
color: '{colors.black}',
border: {
color: '{colors.black}',
}
}
}
},
button: {
primary: {
background: {
color: '{colors.black}',
}
}
}
},
},
},
],
};
5 changes: 1 addition & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ services:
network_mode: bridge
extra_hosts:
- "host.docker.internal:host-gateway"

accounts-service:
environment:
DYNAMODB_URL: ${DYNAMODB_URL}
AWS_REGION: ${AWS_REGION}
AWS_PROFILE: ${AWS_PROFILE}
build:
context: ./microservices/akello-account
context: ./microservices/account
dockerfile: ./Dockerfile
ports:
- "8009:8000"
Expand Down Expand Up @@ -67,8 +66,6 @@ services:
extra_hosts:
- "host.docker.internal:host-gateway"



volumes:
cache:
driver: local
File renamed without changes.
2 changes: 1 addition & 1 deletion microservices/registry/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ RUN poetry install



CMD ["poetry", "run", "uvicorn", "mbc.entrypoints.api.main:app", "--host", "0.0.0.0", "--port", "8000"]
CMD ["poetry", "run", "uvicorn", "registry.entrypoints.api.main:app", "--host", "0.0.0.0", "--port", "8000"]

EXPOSE 8000
8 changes: 0 additions & 8 deletions microservices/registry/mbc/adapters/__init__.py

This file was deleted.

File renamed without changes.
8 changes: 8 additions & 0 deletions microservices/registry/registry/adapters/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import os

from registry.adapters.dynamodb_query_service import DynamoDBRegistryQueryService


query_service = DynamoDBRegistryQueryService()
patch_registry_query_service = 'registry.adapters.dynamodb_query_service.DynamoDBRegistryQueryService'
patch_unit_of_work = 'registry.adapters.dynamodb_unit_of_work.DynamoDBUnitOfWork'
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from typing import Optional, List

from infra.dynamodb import *
from mbc.domain.model.measurement import Measurement
from mbc.domain.model.registry import RegistryUser, Registry
from mbc.domain.ports.measurement_query_service import MeasurementQueryService
from mbc.domain.ports.registry_query_service import RegistryQueryService
from registry.domain.model.measurement import Measurement
from registry.domain.model.registry import RegistryUser, Registry
from registry.domain.ports.measurement_query_service import MeasurementQueryService
from registry.domain.ports.registry_query_service import RegistryQueryService

AKELLO_DYNAMODB_LOCAL_URL = os.getenv('DYNAMODB_URL')
AKELLO_UNIT_TEST = os.getenv('AKELLO_UNIT_TEST')
Expand Down
Loading

0 comments on commit 0c1709d

Please sign in to comment.