Skip to content

Commit

Permalink
feat: start on get but I gtg
Browse files Browse the repository at this point in the history
  • Loading branch information
micahg committed Dec 13, 2024
1 parent a4e1401 commit ed18fa5
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ const CreateTokenFormComponent = () => {
/>
</FormControl>
<FormControl fullWidth>

<Controller
name="hitPoints"
control={control}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React, { lazy, Suspense } from 'react';

Check failure on line 1 in packages/mui/src/components/FindTokenComponent/FindTokenComponent.lazy.tsx

View workflow job for this annotation

GitHub Actions / test_mui

Replace `'react'` with `"react"`

const LazyFindTokenComponent = lazy(() => import('./FindTokenComponent'));

Check failure on line 3 in packages/mui/src/components/FindTokenComponent/FindTokenComponent.lazy.tsx

View workflow job for this annotation

GitHub Actions / test_mui

Replace `'./FindTokenComponent'` with `"./FindTokenComponent"`

const FindTokenComponent = (props: JSX.IntrinsicAttributes & { children?: React.ReactNode; }) => (

Check failure on line 5 in packages/mui/src/components/FindTokenComponent/FindTokenComponent.lazy.tsx

View workflow job for this annotation

GitHub Actions / test_mui

Replace `props:·JSX.IntrinsicAttributes·&·{·children?:·React.ReactNode;·}` with `⏎··props:·JSX.IntrinsicAttributes·&·{·children?:·React.ReactNode·},⏎`
<Suspense fallback={null}>
<LazyFindTokenComponent {...props} />
</Suspense>
);

export default FindTokenComponent;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.FindTokenComponent {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';

Check failure on line 1 in packages/mui/src/components/FindTokenComponent/FindTokenComponent.test.tsx

View workflow job for this annotation

GitHub Actions / test_mui

Replace `'react'` with `"react"`
import { render, screen } from '@testing-library/react';

Check failure on line 2 in packages/mui/src/components/FindTokenComponent/FindTokenComponent.test.tsx

View workflow job for this annotation

GitHub Actions / test_mui

Replace `'@testing-library/react'` with `"@testing-library/react"`
import '@testing-library/jest-dom';

Check failure on line 3 in packages/mui/src/components/FindTokenComponent/FindTokenComponent.test.tsx

View workflow job for this annotation

GitHub Actions / test_mui

Replace `'@testing-library/jest-dom'` with `"@testing-library/jest-dom"`
import FindTokenComponent from './FindTokenComponent';

Check failure on line 4 in packages/mui/src/components/FindTokenComponent/FindTokenComponent.test.tsx

View workflow job for this annotation

GitHub Actions / test_mui

Replace `'./FindTokenComponent'` with `"./FindTokenComponent"`

describe('<FindTokenComponent />', () => {

Check failure on line 6 in packages/mui/src/components/FindTokenComponent/FindTokenComponent.test.tsx

View workflow job for this annotation

GitHub Actions / test_mui

Replace `'<FindTokenComponent·/>'` with `"<FindTokenComponent·/>"`
test('it should mount', () => {

Check failure on line 7 in packages/mui/src/components/FindTokenComponent/FindTokenComponent.test.tsx

View workflow job for this annotation

GitHub Actions / test_mui

Replace `'it·should·mount'` with `"it·should·mount"`
render(<FindTokenComponent />);

const findTokenComponent = screen.getByTestId('FindTokenComponent');

Check failure on line 10 in packages/mui/src/components/FindTokenComponent/FindTokenComponent.test.tsx

View workflow job for this annotation

GitHub Actions / test_mui

Replace `'FindTokenComponent'` with `"FindTokenComponent"`

expect(findTokenComponent).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { Box, ListItem, ListSubheader, Paper, TextField } from "@mui/material";
import { AppReducerState } from "../../reducers/AppReducer";
import { useSelector } from "react-redux";
import { useEffect } from "react";
// import styles from "./FindTokenComponent.module.css";

// interface FindTokenComponentProps {}

const FindTokenComponent = () => {
const tokens = useSelector((state: AppReducerState) => state.content.tokens);

useEffect(() => {}, []);

/** {scenes.map((scene) => (
<ListItem
key={scene._id}
secondaryAction={
<IconButton
edge="end"
aria-label="delete"
onClick={() => handleDeleteScene(scene)}
>
<DeleteIcon />
</IconButton>
} */
return (
// , height: `calc(100vh - 72px)`
<Box sx={{ overflow: "auto" }}>
<ListSubheader>
<TextField
autoFocus
label="Name"
variant="standard"
// onChange={search}
sx={{ m: 1, margin: "1em" }}
></TextField>
</ListSubheader>
{/* <ListItem
key={scene._id}
secondaryAction={
<IconButton
edge="end"
aria-label="delete"
onClick={() => handleDeleteScene(scene)}
>
<DeleteIcon />
</IconButton>
}
> */}
{tokens.map((token) => (
<ListItem key={token._id}>{token.name}</ListItem>
))}
{/* <TextField
variant="standard"
label="Class"
defaultValue=""
disabled={classes.length === 0}
select
onChange={(event) => setClassSelected(event.target.value)}
sx={{ m: 1, margin: "1em" }}
>
{classes.map((classroom: ClassRoom) => (
<MenuItem key={classroom._id} value={classroom._id}>
{classroomText(classroom)}
</MenuItem>
))}
</TextField> */}
{/* <SearchResultsList
value={searchValue}
onSelected={(student: Student) => selected(student)}
/> */}
{/* The text field above is 3.5em, so we shrink the paper by 3.5em and let it handle overflow
to keep the scrolling to within the list it contains. */}
<Paper
sx={{
display: "flex",
justifyContent: "left",
flexWrap: "wrap",
listStyle: "none",
padding: 0,
margin: "0 0 3.5em 0",
overflow: "auto",
}}
component="ul"
elevation={0}
></Paper>
</Box>
);
};

export default FindTokenComponent;
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import {
ListItemButton,
ListItemIcon,
ListItemText,
Paper,
TextField,
} from "@mui/material";
import SearchIcon from "@mui/icons-material/Search";
import AddIcon from "@mui/icons-material/Add";
import { useState } from "react";
import { ExpandLess, ExpandMore } from "@mui/icons-material";
import CreateTokenFormComponent from "../CreateTokenFormComponent/CreateTokenFormComponent.lazy";
import FindTokenComponent from "../FindTokenComponent/FindTokenComponent.lazy";
// interface TokenInfoDrawerComponentProps {}

const TokenInfoDrawerComponent = () => {
Expand All @@ -37,47 +36,7 @@ const TokenInfoDrawerComponent = () => {
</ListItem>
<Collapse in={searchOpen} timeout="auto" unmountOnExit>
<ListItem>
<TextField
autoFocus
label="Name"
variant="standard"
// onChange={search}
sx={{ m: 1, margin: "1em" }}
></TextField>
{/* <TextField
variant="standard"
label="Class"
defaultValue=""
disabled={classes.length === 0}
select
onChange={(event) => setClassSelected(event.target.value)}
sx={{ m: 1, margin: "1em" }}
>
{classes.map((classroom: ClassRoom) => (
<MenuItem key={classroom._id} value={classroom._id}>
{classroomText(classroom)}
</MenuItem>
))}
</TextField> */}
{/* <SearchResultsList
value={searchValue}
onSelected={(student: Student) => selected(student)}
/> */}
{/* The text field above is 3.5em, so we shrink the paper by 3.5em and let it handle overflow
to keep the scrolling to within the list it contains. */}
<Paper
sx={{
display: "flex",
justifyContent: "left",
flexWrap: "wrap",
listStyle: "none",
padding: 0,
margin: "0 0 3.5em 0",
overflow: "auto",
}}
component="ul"
elevation={0}
></Paper>
<FindTokenComponent />
</ListItem>
<Divider />
</Collapse>
Expand Down
26 changes: 22 additions & 4 deletions packages/mui/src/middleware/ContentMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ function isBlob(payload: URL | Blob): payload is File {

type Operation = "put" | "delete";

const FriendlyOperation : {[key in Operation]: string } = {
"put": "Update succesfull",
"delete": "Deletion successful"
}
const FriendlyOperation: { [key in Operation]: string } = {
put: "Update succesfull",
delete: "Deletion successful",
};

async function update<T extends Asset | Token>(
state: AppReducerState,
Expand Down Expand Up @@ -94,6 +94,21 @@ async function operate<T extends Asset | Token>(
next({ type: "content/error", payload: err });
}
}
// async function retrieve(
// state: AppReducerState,
// store: MiddlewareAPI<Dispatch<AnyAction>, unknown>,
// path: string,
// action: unknown & { type: string; payload: T },
// ) {
// const url = `${state.environment.api}/${path}`;
// getToken(state, store)
// .then((headers) => axios.get(url, { headers: headers }))
// .then((value) => next({ type: action.type, payload: value.data }))
// .catch((err) =>
// // TODO MICAH display error
// console.error(`Unable to fetch assets: ${JSON.stringify(err)}`),
// );
// }

async function updateAssetData(
state: AppReducerState,
Expand Down Expand Up @@ -226,6 +241,9 @@ export const ContentMiddleware: Middleware =
operate(state, store, next, "delete", "asset", action);
break;
}
case "content/tokens": {
// operate(state, store, next, "get", "asset");
}
case "content/assets": {
const url = `${state.environment.api}/asset`;
getToken(state, store)
Expand Down

0 comments on commit ed18fa5

Please sign in to comment.