-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: app router support #76
Conversation
🦋 Changeset detectedLatest commit: 78b6728 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
data.forEach((item, index) => { | ||
Object.keys(item).forEach((key) => { | ||
let itemValue; | ||
|
||
if (typeof item[key] === "object" && item[key] !== null) { | ||
switch (item[key].type) { | ||
case "link": | ||
itemValue = item[key].value.label; | ||
break; | ||
case "count": | ||
itemValue = item[key].value; | ||
break; | ||
case "date": | ||
itemValue = item[key].value.toString(); | ||
break; | ||
default: | ||
itemValue = item[key].id; | ||
break; | ||
} | ||
|
||
item[key].__nextadmin_formatted = itemValue; | ||
} else if (isScalar(item[key]) && item[key] !== null) { | ||
item[key] = { | ||
type: "scalar", | ||
value: item[key], | ||
__nextadmin_formatted: item[key].toString(), | ||
}; | ||
itemValue = item[key].value; | ||
} | ||
|
||
if ( | ||
appDir && | ||
key in listFields && | ||
listFields[key as keyof typeof listFields]?.formatter && | ||
!!itemValue | ||
) { | ||
item[key].__nextadmin_formatted = listFields[ | ||
key as keyof typeof listFields | ||
// @ts-expect-error | ||
]?.formatter?.(itemValue ?? item[key]); | ||
} else { | ||
data[index][key] = item[key]; | ||
} | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need these new formatters ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the initial behavior was to pass the options
object as a prop of the NextAdmin
component, which was causing issues with the fields with the formatter
function since those were not serializable. So for the app router, the idea was to run the formatting on the server side. To achieve that, we needed to take the behavior of the Cell
component and apply it on the server side
6677a08
to
906d1fc
Compare
#54