brave / ads-ui

Self-service ads UI
Mozilla Public License 2.0
24 stars 11 forks source link

refactor: update based on graphql schema changes #1246

Closed tackley closed 3 months ago

tackley commented 3 months ago

Notably the type code simplifications in https://github.com/brave/ads-serve/pull/4019.

I haven't done a full switchover to use typeCode rather than type.code, and so therefore we're still dependent on that deprecated field. But this at least means we can regenerate the graphql definitions.

github-actions[bot] commented 3 months ago

[puLL-Merge] - brave/ads-ui@1246

Description

This PR updates the GraphQL schema and related types, primarily focusing on the AdSet and Creative entities. It introduces an AdSetState enum, modifies the CreativeInput type, and updates various components and hooks to use these new types. The changes aim to improve type safety and align the codebase with the updated GraphQL schema.

Changes ### Changes 1. `src/graphql-client/graphql.ts`: - Added `AdSetState` enum - Updated `AdSet` type to use `AdSetState` instead of string for the `state` field - Added `CreativeTypeCode` enum - Updated `Creative` type to include `typeCode` field - Removed deprecated fields and types related to engagements and confirmations 2. `src/components/Creatives/CreativeType.tsx`: - Updated import to use `CreativeInputWithType` instead of `CreativeInput` 3. `src/components/Creatives/hooks/useGetCreativeDetails.tsx`: - Updated to use `CreativeInputWithType` instead of `CreativeInput` 4. `src/components/Creatives/hooks/useSubmitCreative.tsx`: - Updated to use `CreativeInputWithType` instead of `CreativeInput` 5. `src/components/Datagrid/renderers.tsx`: - Updated `adSetOnOffState` function to cast state to `AdSetState` 6. `src/graphql/creative.graphql`: - Added eslint-disable comment for deprecated `type` field 7. `src/user/library/index.test.ts`: - Updated test cases to use `AdSetState` enum instead of string literals 8. `src/user/views/adsManager/types/index.ts`: - Added `AdSetState` import - Updated `AdSetForm` type to use `AdSetState` for the `state` field - Created `CreativeInputWithType` type - Updated `Creative` type to extend `CreativeInputWithType`

Possible Issues

Security Hotspots

No significant security issues are apparent in this change.