Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to deal with enum data model with other data model type script?

I have these different data models.
I used enum type in other data models.
now can I compare __typename?

enum ActivtiyCardType  {
    Dance,
    ReferralTransaction,
  }

  type ActivityCardData = {
    __typename:ActivtiyCardType,
            id:string,
            from:{
                __typename:string,
                from:string,
                id:string
            }
            to:{
                __typename:string,
                to:string,
                id:string
            }
            date:Date,
            message:string,
            danceSuccessful:boolean,
            amount?: number
  }
    
  type ActivityCardsProps = {
    data: ActivityCardData[]
}

{data?.map((activity:ActivityCardData) => {
       
                return (
                    <Paper
                        key={activity.id}
                        sx={{
                            m: 1,
                            p: 3,
                        }}
                    >
                      
                            <Box>
                                **{activity.__typename === 'Dance' ? (**

How to compare __typename in this context?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Well why not just this?

activity.__typename === ActivtiyCardType.Dance
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading