MCPcopy
hub / github.com/amplication/amplication / EntityList

Function EntityList

packages/amplication-client/src/Entity/EntityList.tsx:65–289  ·  view source on GitHub ↗
({ match, innerRoutes })

Source from the content-addressed store, hash-verified

63const POLL_INTERVAL = 30000;
64
65const EntityList: React.FC<Props> = ({ match, innerRoutes }) => {
66 const { resource } = match.params;
67 const [error, setError] = useState<Error>();
68 const pageTitle = "Entities";
69 const [searchPhrase, setSearchPhrase] = useState<string>("");
70 const [newEntity, setNewEntity] = useState<boolean>(false);
71
72 const { baseUrl } = useResourceBaseUrl();
73
74 const query = useUrlQuery();
75 const view = query.get("view");
76
77 const displayModeValue: DisplayModeType = view === "erd" ? "erd" : "list";
78
79 const [displayMode, setDisplayMode] =
80 useState<DisplayModeType>(displayModeValue);
81
82 const setDisplayModeValue = useCallback(
83 (mode: DisplayModeType) => {
84 setDisplayMode(mode);
85 query.set("view", mode);
86 window.history.replaceState(
87 null,
88 "",
89 `${window.location.pathname}?${query.toString()}`
90 );
91 },
92 [query]
93 );
94
95 const handleNewEntityClick = useCallback(() => {
96 setNewEntity(!newEntity);
97 }, [newEntity, setNewEntity]);
98
99 const {
100 data,
101 loading,
102 error: errorLoading,
103 refetch,
104 stopPolling,
105 startPolling,
106 } = useQuery<TData>(GET_ENTITIES, {
107 variables: {
108 id: resource,
109 orderBy: {
110 [NAME_FIELD]: models.SortOrder.Asc,
111 },
112 whereName:
113 searchPhrase !== ""
114 ? { contains: searchPhrase, mode: models.QueryMode.Insensitive }
115 : undefined,
116 },
117 });
118
119 const handleSearchChange = useCallback(
120 (value) => {
121 setSearchPhrase(value);
122 },

Callers

nothing calls this directly

Calls 9

useResourceBaseUrlFunction · 0.90
useUrlQueryFunction · 0.90
formatErrorFunction · 0.90
pluralizeFunction · 0.90
mapMethod · 0.80
getMethod · 0.65
setMethod · 0.65
toStringMethod · 0.65
catchMethod · 0.45

Tested by

no test coverage detected