Last active
March 31, 2021 11:57
-
-
Save soxjke/35a8047eebc142dd1a390099d78406a0 to your computer and use it in GitHub Desktop.
Discriminated union
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { DestinationType, IBoxData, IWifiData, IWifiTypeData, SocialMediaItem } from '../../types/config/destination'; | |
export interface BaseDestinationConfigg { | |
readonly type: DestinationType; | |
readonly id: string; | |
readonly title: string; | |
readonly tooltip: string; | |
} | |
interface CallDestinationConfigg extends BaseDestinationConfigg { | |
readonly type: DestinationType.Call; | |
readonly boxDescription: string; | |
readonly placeholder: string; | |
} | |
interface EmailDestinationConfigg extends BaseDestinationConfigg { | |
readonly type: DestinationType.Email; | |
readonly emailAddress: IBoxData; | |
readonly subject: IBoxData; | |
readonly message: IBoxData; | |
} | |
interface SocialMediaDestinationConfigg extends BaseDestinationConfigg { | |
readonly type: DestinationType.SocialMedia; | |
readonly boxDescription: string; | |
readonly placeholder: string; | |
} | |
interface SocialMediaListDestinationConfigg extends BaseDestinationConfigg { | |
readonly type: DestinationType.SocialMediaList; | |
readonly socialList: SocialMediaItem[]; | |
} | |
interface TextMessageDestinationConfigg extends BaseDestinationConfigg { | |
readonly type: DestinationType.TextMessage; | |
readonly phoneNumber: IBoxData; | |
readonly message: IBoxData; | |
} | |
interface UploadFileDestinationConfigg extends BaseDestinationConfigg { | |
readonly type: DestinationType.UploadFile; | |
readonly boxDescription: string; | |
readonly placeholder: string; | |
} | |
interface UrlDestinationConfigg extends BaseDestinationConfigg { | |
readonly type: DestinationType.Url; | |
readonly boxDescription: string; | |
readonly placeholder: string; | |
} | |
interface VenmoDestinationConfigg extends BaseDestinationConfigg { | |
readonly type: DestinationType.Venmo; | |
readonly userName: IBoxData; | |
readonly value: IBoxData; | |
readonly note: IBoxData; | |
} | |
interface WifiDestinationConfigg extends BaseDestinationConfigg { | |
readonly type: DestinationType.Wifi; | |
readonly ssid: IWifiData; | |
readonly password: IBoxData; | |
readonly wifiTypes: IWifiTypeData[]; | |
readonly hiddenNetworkAvailable: boolean; | |
} | |
type DestinationConfig = CallDestinationConfigg | EmailDestinationConfigg | SocialMediaDestinationConfigg | | |
SocialMediaListDestinationConfigg | TextMessageDestinationConfigg | UploadFileDestinationConfigg | | |
UrlDestinationConfigg | VenmoDestinationConfigg | WifiDestinationConfigg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment