Forcing usage of id to getOne

This commit is contained in:
2025-04-21 20:24:27 +02:00
parent 309b55f25f
commit 9e823d003e
2 changed files with 5 additions and 2 deletions

View File

@@ -33,7 +33,7 @@ export const FirmRoutes = () => {
const FirmHome = () => { const FirmHome = () => {
const { currentFirm } = useContext(FirmContext); const { currentFirm } = useContext(FirmContext);
const { data: firm, isError, error, isLoading } = useOne({resource: 'firm', id: `${currentFirm.instance}/${currentFirm.firm}`, errorNotification: false}) const { data: firm, isError, error, isLoading } = useOne({resource: 'firm', id: `${currentFirm.instance}/${currentFirm.firm}/`, errorNotification: false})
if (isLoading) { if (isLoading) {
return <h1>Loading...</h1> return <h1>Loading...</h1>

View File

@@ -4,7 +4,10 @@ const API_URL = "/api/v1";
export const dataProvider: DataProvider = { export const dataProvider: DataProvider = {
getOne: async ({ resource, id, meta }) => { getOne: async ({ resource, id, meta }) => {
const response = id !== "" ? await fetch(`${API_URL}/${resource}/${id}`) : await fetch(`${API_URL}/${resource}`); if (id === "") {
return { data: undefined };
}
const response = await fetch(`${API_URL}/${resource}/${id}`);
if (response.status < 200 || response.status > 299) { if (response.status < 200 || response.status > 299) {
if (response.status == 405) { if (response.status == 405) {
const error: HttpError = { const error: HttpError = {