Skip to content

Commit

Permalink
feat: add hydra prefix support
Browse files Browse the repository at this point in the history
  • Loading branch information
29Hido committed Mar 28, 2024
1 parent 6ca7a1c commit 9f6dbf0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/generators/ReactNativeGeneratorV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ export default class extends BaseGenerator {
// static files
[
"lib/types/ApiResource.ts",
"lib/types/HydraView.ts",
"lib/types/HydraResponse.ts",
"lib/hooks/data.ts",
"lib/hooks/mercure.ts",
"lib/hooks/modal.ts",
Expand All @@ -133,6 +131,8 @@ export default class extends BaseGenerator {
"components/%s/CreateEditModal.tsx",
"components/%s/Form.tsx",
"components/%s/LogsRenderer.tsx",
"lib/types/HydraView.ts",
"lib/types/HydraResponse.ts",
].forEach((pattern) =>
this.createFileFromPattern(pattern, dir, [lc], context)
);
Expand Down
4 changes: 2 additions & 2 deletions templates/react-native-v2/app/(tabs)/foos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export default function Books() {

useEffect(() => {
if (isSuccess) {
setMember(data["hydra:member"]);
setView(data['hydra:view']);
setMember(data["{{{hydraPrefix}}}member"]);
setView(data['{{{hydraPrefix}}}view']);
}
}, [isSuccess, data]);

Expand Down
8 changes: 4 additions & 4 deletions templates/react-native-v2/components/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export default function Navigation(props: { view: HydraView }) {
const router = useRouter();

const {
"hydra:first": first,
"hydra:previous": previous,
"hydra:next": next,
"hydra:last": last,
"{{{hydraPrefix}}}first": first,
"{{{hydraPrefix}}}previous": previous,
"{{{hydraPrefix}}}next": next,
"{{{hydraPrefix}}}last": last,
} = view;

return (
Expand Down
4 changes: 2 additions & 2 deletions templates/react-native-v2/lib/types/HydraResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import ApiResource from "./ApiResource";
import { HydraView } from "./HydraView";

export interface HydraResponse<T extends ApiResource> {
'hydra:member'?: Array<T>;
'hydra:view'?: HydraView;
'{{{hydraPrefix}}}member'?: Array<T>;
'{{{hydraPrefix}}}view'?: HydraView;
}
8 changes: 4 additions & 4 deletions templates/react-native-v2/lib/types/HydraView.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export interface HydraView {
'hydra:first'?: string;
'hydra:last'?: string;
'hydra:previous'?: string;
'hydra:next'?: string;
'{{{hydraPrefix}}}first'?: string;
'{{{hydraPrefix}}}last'?: string;
'{{{hydraPrefix}}}previous'?: string;
'{{{hydraPrefix}}}next'?: string;
}

0 comments on commit 9f6dbf0

Please sign in to comment.