Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ By centralizing data management and offering flexible access to it, ARM empowers

```javascript
// Example usage in ReactJS/NextJS
import { observer } from 'mobx-react-lite'
import { observer } from 'mobx-react'
import { ARM } from '@/components/providers/arm-config-provider'

const App = observer(() => {
Expand Down Expand Up @@ -506,6 +506,22 @@ See example [here](https://github.com/michaeljymsgutierrez/arm-js-library/tree/m
</ul>
```

- **getRequestAlias(aliasName)**
- Retrieving the [returned object](#returned-object-request-functions-from-server) from the request functions.
- See example [here](https://github.com/michaeljymsgutierrez/arm-js-library/tree/main/apps/create-next-app/src/app/demo/retrieve-functions-from-collections/get-request-alias)

```javascript
const addresses = ARM.getRequestAlias('customerAddresses')

ARM.findAll('addresses', { alias: 'customerAddresses' })

<ul>
{addresses.data.map((address, index) => (
<li key={index}>{address.get('id')}</li>
))}
</ul>
```

#### Create collection record function

---
Expand Down Expand Up @@ -1063,4 +1079,4 @@ const addresses = [

## License

This project is licensed under the MIT License.
This project is licensed under the [MIT](https://github.com/michaeljymsgutierrez/arm-js-library/blob/main/LICENSE.md) License.
3 changes: 3 additions & 0 deletions apps/create-next-app/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
turbopack: {
root: '../../',
},
async redirects() {
return [
{
Expand Down
13 changes: 11 additions & 2 deletions apps/create-next-app/src/app/demo/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const DemoPage = () => {
'/demo/request-functions-from-server/query',
'/demo/request-functions-from-server/returned-object',
'/demo/retrieve-functions-from-collections/get-alias',
'/demo/retrieve-functions-from-collections/get-request-alias',
'/demo/retrieve-functions-from-collections/get-collection',
'/demo/retrieve-functions-from-collections/peek-all',
'/demo/retrieve-functions-from-collections/peek-record',
Expand All @@ -54,10 +55,18 @@ const DemoPage = () => {
return (
<div className="flex justify-center items-center min-h-screen bg-gray-100 p-5">
<div className="bg-white p-8 rounded-lg shadow-xl w-full max-w-2xl">
<h1 className="text-3xl font-bold text-center mb-8">Demo Links</h1>
<a href="https://www.npmjs.com/package/arm-js-library">
<img
src="https://assets-omega-neon.vercel.app/images/arm-js-title-logo.png"
alt="arm-js-logo"
height="200"
width="143.7"
className="my-8 mx-auto"
/>
</a>
<input
type="text"
placeholder="Search demos..."
placeholder="Search demo links..."
className="w-full p-3 mb-6 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use client'

import { ARM } from '@/components/providers/arm-config-provider'

const Controller = () => {
return {
addresses: ARM.getRequestAlias('customerAddresses'),
}
}

export default Controller
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use client'

import { ARM } from '@/components/providers/arm-config-provider'

const Model = () => {
return {
addresses: ARM.findAll('addresses', { alias: 'customerAddresses' }),
}
}

export default Model
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
'use client'

import { observer } from 'mobx-react'
import Controller from './controller'
import Model from './model'

const Page = observer(() => {
const controller = Controller()
const { isLoading } = Model()

return (
<table>
<thead>
<tr>
<th>ADDRESS1</th>
<th>ADDRESS2</th>
<th>CITY</th>
<th>POST CODE</th>
<th>LANDMARK</th>
<th>KIND</th>
<th>LABEL</th>
<th>LONGITUDE</th>
<th>LATITUDE</th>
</tr>
</thead>
<tbody>
{isLoading && (
<tr>
<td colSpan="9">Loading...</td>
</tr>
)}

{!isLoading &&
controller.addresses?.data.map((address) => (
<tr key={address.get('id')}>
<td>{address.get('attributes.address1')}</td>
<td>{address.get('attributes.address2')}</td>
<td>{address.get('attributes.city')}</td>
<td>{address.get('attributes.post-code')}</td>
<td>{address.get('attributes.landmark')}</td>
<td>{address.get('attributes.kind')}</td>
<td>{address.get('attributes.label')}</td>
<td>{address.get('attributes.longitude')}</td>
<td>{address.get('attributes.latitude')}</td>
</tr>
))}
</tbody>
</table>
)
})

export default Page
Loading
Loading