Skip to content

Commit

Permalink
initial commit for play automation
Browse files Browse the repository at this point in the history
  • Loading branch information
koustov committed Jul 6, 2022
1 parent fecb697 commit 2673b09
Show file tree
Hide file tree
Showing 38 changed files with 774 additions and 311 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ yarn.lock

# nhost
.nhost

# play inde
/src/plays/index.js
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,28 @@
"version": "1.0.0",
"private": true,
"dependencies": {
"@emotion/react": "^11.9.3",
"@emotion/styled": "^11.9.3",
"@giscus/react": "^2.0.3",
"@mui/material": "^5.8.6",
"@nhost/react": "^0.9.0",
"@types/lodash": "^4.14.182",
"@types/react": "^18.0.6",
"@types/react-dom": "^18.0.2",
"@uiw/react-markdown-preview": "^4.0.18",
"date-fns": "^2.28.0",
"firebase": "^9.8.2",
"git-repo-api": "^0.0.17",
"graphql": "^16.5.0",
"json-graphql-parser": "^0.0.8",
"lodash": "^4.17.21",
"node-sass": "^7.0.1",
"plop": "^3.0.5",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-helmet": "^6.1.0",
"react-icons": "^4.3.1",
"react-loader-spinner": "^5.1.5",
"react-markdown": "^8.0.3",
"react-organizational-chart": "^2.1.1",
"react-redux": "^8.0.1",
"react-router-dom": "^6.3.0",
Expand All @@ -35,8 +40,7 @@
"build": "react-scripts build",
"snap": "react-snap",
"test": "react-scripts test",
"eject": "react-scripts eject",
"create-play": "plop"
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
Expand Down
30 changes: 0 additions & 30 deletions plop-templates/component_js.hbs

This file was deleted.

31 changes: 0 additions & 31 deletions plop-templates/component_ts.hbs

This file was deleted.

2 changes: 0 additions & 2 deletions plop-templates/exportPlay.hbs

This file was deleted.

2 changes: 0 additions & 2 deletions plop-templates/importToMeta.hbs

This file was deleted.

27 changes: 0 additions & 27 deletions plop-templates/play-readme.hbs

This file was deleted.

14 changes: 0 additions & 14 deletions plop-templates/play.hbs

This file was deleted.

1 change: 0 additions & 1 deletion plop-templates/style_css.hbs

This file was deleted.

1 change: 0 additions & 1 deletion plop-templates/style_scss.hbs

This file was deleted.

110 changes: 0 additions & 110 deletions plopfile.js

This file was deleted.

93 changes: 93 additions & 0 deletions src/common/components/PlayForms.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import {Chip, Autocomplete, TextField, InputLabel , MenuItem , FormControl , Select} from '@mui/material';
import { useEffect, useState } from 'react';


const PlayForm = ({fields, data, onChange}) => {

const [formData, setFormData] = useState({})
useEffect(() => {
setFormData({...data})
}, [data])

const onDataChanged = (key, value) => {
formData[key] = value;
setFormData({...formData})
if(onChange) {
onChange(key, value)
}
}

const renderField = field => {
switch(field.type){
case 'input': return <TextField id={field.id}
label={field.plaeholder}
value={formData[field.datafields]}
size="small"
className='w-full'
{...field}

onChange={(e) => {
onDataChanged(field.datafield, e.target.value)}
}/>
case 'select': return <FormControl fullWidth>
<Select
id={field.id}
size="small"
label={field.plaeholder}
value={formData[field.datafields]}
onChange={(e) => {
onDataChanged(field.datafield, e.target.value)}
}
>
{
(field.options || []).map(o => {
return <MenuItem value={o.value}>{o.name}</MenuItem>
})
}
</Select>
</FormControl>
case 'fileupload': return <span><input
accept="image/*"
className={classes.input}
style={{ display: 'none' }}
id="raised-button-file"
multiple
type="file"
/>
<label htmlFor="raised-button-file">
<Button variant="raised" component="span" className={classes.button}>
Upload
</Button>
</label>
</span>
}

}

const renderForm = () => {
return <>
<FormControl className='w-full'>
{fields.map(field => {
return(
<div className='flex p-2'>
<div className='flex-1'>
{field.display}{field.required ? "*":""}
</div>
<div className='flex-1'>
{renderField(field)}
</div>
</div>

)
})}

</FormControl> </>
}
return (
<>
{renderForm()}
</>
);
};

export default PlayForm;
4 changes: 4 additions & 0 deletions src/common/const/git.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const GIT = {
GIT_REPO_NAME: "react-play",
GIT_REPO_USER: "reactplay",
};
2 changes: 2 additions & 0 deletions src/common/const/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./nhost";
export * from "./git";
5 changes: 5 additions & 0 deletions src/common/const/nhost.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const NHOST = {
AUTH_URL: `https://rgkjmwftqtbpayoyolwh.nhost.run/v1/auth/signin/provider/github?redirectTo=${encodeURI(
"http:https://localhost:3000/plays/create"
)}`,
};
Loading

0 comments on commit 2673b09

Please sign in to comment.