CustomDetailComponent.tsx 594 B

123456789101112131415161718
  1. import { Card, useDetailComponentData } from '@vendure/admin-ui/react';
  2. import React from 'react';
  3. export function CustomDetailComponent(props: any) {
  4. const { entity, detailForm } = useDetailComponentData();
  5. const updateName = () => {
  6. detailForm.get('name')?.setValue('New name');
  7. detailForm.markAsDirty();
  8. };
  9. return (
  10. <Card title={'Custom Detail Component'}>
  11. <button className="button" onClick={updateName}>
  12. Update name
  13. </button>
  14. <pre>{JSON.stringify(entity, null, 2)}</pre>
  15. </Card>
  16. );
  17. }