Skip to content

Commit

Permalink
working with multiple forms
Browse files Browse the repository at this point in the history
  • Loading branch information
ELiuHub committed Sep 2, 2022
1 parent 83b28f0 commit 24ae47b
Show file tree
Hide file tree
Showing 19 changed files with 3,028 additions and 126 deletions.
15 changes: 15 additions & 0 deletions .graphqlconfig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
projects:
b4hGraphQL:
schemaPath: src/graphql/schema.json
includes:
- src/graphql/**/*.js
excludes:
- ./amplify/**
extensions:
amplify:
codeGenTarget: javascript
generatedFileName: ''
docsFilePath: src/graphql
extensions:
amplify:
version: 3
12 changes: 12 additions & 0 deletions amplify/backend/api/b4hGraphQL/cli-inputs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"serviceConfiguration": {
"apiName": "b4hGraphQL",
"serviceName": "AppSync",
"gqlSchemaPath": "C:\\Users\\eliu10\\basics4health\\amplify\\backend\\api\\b4hGraphQL\\schema.graphql",
"defaultAuthType": {
"mode": "AMAZON_COGNITO_USER_POOLS",
"cognitoUserPoolId": "authbasics4health41656259"
}
}
}
11 changes: 11 additions & 0 deletions amplify/backend/api/b4hGraphQL/parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"AppSyncApiName": "b4hGraphQL",
"DynamoDBBillingMode": "PAY_PER_REQUEST",
"DynamoDBEnableServerSideEncryption": false,
"AuthCognitoUserPoolId": {
"Fn::GetAtt": [
"authbasics4health41656259",
"Outputs.UserPoolId"
]
}
}
2 changes: 2 additions & 0 deletions amplify/backend/api/b4hGraphQL/resolvers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Any resolvers that you add in this directory will override the ones automatically generated by Amplify CLI and will be directly copied to the cloud.
For more information, visit [https://docs.amplify.aws/cli/graphql-transformer/resolvers](https://docs.amplify.aws/cli/graphql-transformer/resolvers)
15 changes: 15 additions & 0 deletions amplify/backend/api/b4hGraphQL/schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

type Form @model @auth(rules: [{ allow: owner }, { allow: private, operations: [read] }]) {
id: ID!
name: String @index(name: "byFormName", queryField: "getFormByName")
otherUser: String
owner: String
file: S3Object
}

type S3Object {
bucket: String!
region: String!
key: String!
}

58 changes: 58 additions & 0 deletions amplify/backend/api/b4hGraphQL/stacks/CustomResources.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "An auto-generated nested stack.",
"Metadata": {},
"Parameters": {
"AppSyncApiId": {
"Type": "String",
"Description": "The id of the AppSync API associated with this project."
},
"AppSyncApiName": {
"Type": "String",
"Description": "The name of the AppSync API",
"Default": "AppSyncSimpleTransform"
},
"env": {
"Type": "String",
"Description": "The environment name. e.g. Dev, Test, or Production",
"Default": "NONE"
},
"S3DeploymentBucket": {
"Type": "String",
"Description": "The S3 bucket containing all deployment assets for the project."
},
"S3DeploymentRootKey": {
"Type": "String",
"Description": "An S3 key relative to the S3DeploymentBucket that points to the root\nof the deployment directory."
}
},
"Resources": {
"EmptyResource": {
"Type": "Custom::EmptyResource",
"Condition": "AlwaysFalse"
}
},
"Conditions": {
"HasEnvironmentParameter": {
"Fn::Not": [
{
"Fn::Equals": [
{
"Ref": "env"
},
"NONE"
]
}
]
},
"AlwaysFalse": {
"Fn::Equals": ["true", "false"]
}
},
"Outputs": {
"EmptyOutput": {
"Description": "An empty output. You may delete this if you have at least one resource above.",
"Value": ""
}
}
}
4 changes: 4 additions & 0 deletions amplify/backend/api/b4hGraphQL/transform.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Version": 5,
"ElasticsearchWarning": true
}
27 changes: 26 additions & 1 deletion amplify/backend/backend-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,30 @@
]
}
]
},
"b4hGraphQL": {
"service": "AppSync",
"providerPlugin": "awscloudformation",
"dependsOn": [
{
"category": "auth",
"resourceName": "basics4health41656259",
"attributes": [
"UserPoolId"
]
}
],
"output": {
"authConfig": {
"defaultAuthentication": {
"authenticationType": "AMAZON_COGNITO_USER_POOLS",
"userPoolConfig": {
"userPoolId": "authbasics4health41656259"
}
},
"additionalAuthenticationProviders": []
}
}
}
},
"storage": {
Expand All @@ -102,5 +126,6 @@
}
]
}
}
},
"custom": {}
}
5 changes: 3 additions & 2 deletions amplify/backend/storage/b4hstorage/cli-inputs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"bucketName": "basics4health",
"storageAccess": "auth",
"guestAccess": [],
"authAccess": [],
"triggerFunction": "NONE",
"authAccess": [
"READ"
],
"groupAccess": {
"Admins": [
"CREATE_AND_UPDATE",
Expand Down
4 changes: 4 additions & 0 deletions amplify/backend/types/amplify-dependent-resources-ref.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export type AmplifyDependentResourcesAttributes = {
"RootUrl": "string",
"ApiName": "string",
"ApiId": "string"
},
"b4hGraphQL": {
"GraphQLAPIIdOutput": "string",
"GraphQLAPIEndpointOutput": "string"
}
},
"storage": {
Expand Down
17 changes: 14 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,22 @@ Amplify.configure(awsExports);

function App(props) {
const client = props.client;
const [patient, setPatient] = useState();
const [patient, setPatient] = useState('');
const [loading, setLoading] = useState(true);

useEffect(() => {
client.patient.read().then((patient) => setPatient(patient));
}, [client.patient]);
getPatient();
}, []);

async function getPatient() {
let pat = await client.patient.read();
setPatient(pat);
setLoading(false);
}

if (loading) {
return <span>Loading...</span>
}

return (
<>
Expand Down
17 changes: 5 additions & 12 deletions src/Components/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { useState } from "react";
import { AppBar, Toolbar, Button, Typography } from "@mui/material";
import Sidebar from './sidebar';
import { Auth } from 'aws-amplify';
import { useNavigate } from 'react-router-dom';
import { useEffect } from "react";
// import AdminStatus from "../adminStatus";
import AdminStatus from "../Helpers/adminStatus";

export default function Navbar() {
const [admin, setAdmin] = useState(false);
const navigate = useNavigate();

useEffect(() => {
welcomeUser();
Expand All @@ -21,21 +23,12 @@ export default function Navbar() {

async function signOut() {
await Auth.signOut();
navigate("/");
window.location.reload();
}

async function isAdmin() {
let user = await Auth.currentAuthenticatedUser();
let group = user.signInUserSession.accessToken.payload['cognito:groups'];
if (group === undefined) {
setAdmin(false);
} else {
if (group.includes('Admins')) {
setAdmin(true);
}
}
// let adminStatus = await IsAdmin();
// setAdmin(await AdminStatus());
setAdmin(await AdminStatus());
}

return (
Expand Down
27 changes: 0 additions & 27 deletions src/Helpers/notification.js

This file was deleted.

Loading

0 comments on commit 24ae47b

Please sign in to comment.