2022-09-07 10:00:28 +03:00
|
|
|
import React, { FC } from 'react';
|
2021-01-31 12:38:20 +03:00
|
|
|
import { Select } from 'antd';
|
2021-02-07 06:38:58 +03:00
|
|
|
import { SocialHandleDropdownItem } from '../../types/config-section';
|
|
|
|
import { OTHER_SOCIAL_HANDLE_OPTION } from '../../utils/config-constants';
|
2021-01-19 21:34:06 +03:00
|
|
|
|
2022-09-07 10:00:28 +03:00
|
|
|
export type DropdownProps = {
|
2021-01-24 07:16:01 +03:00
|
|
|
iconList: SocialHandleDropdownItem[];
|
2021-01-24 12:22:28 +03:00
|
|
|
selectedOption: string;
|
|
|
|
onSelected: any;
|
2022-09-07 10:00:28 +03:00
|
|
|
};
|
2021-01-19 21:34:06 +03:00
|
|
|
|
2022-09-07 10:00:28 +03:00
|
|
|
export const SocialDropdown: FC<DropdownProps> = ({ iconList, selectedOption, onSelected }) => {
|
2021-02-04 19:04:00 +03:00
|
|
|
const handleSelected = (value: string) => {
|
2021-01-24 12:22:28 +03:00
|
|
|
if (onSelected) {
|
|
|
|
onSelected(value);
|
|
|
|
}
|
2021-01-19 21:34:06 +03:00
|
|
|
};
|
2021-01-24 12:22:28 +03:00
|
|
|
const inititalSelected = selectedOption === '' ? null : selectedOption;
|
2021-01-19 21:34:06 +03:00
|
|
|
return (
|
|
|
|
<div className="social-dropdown-container">
|
2021-02-13 10:55:59 +03:00
|
|
|
<p className="description">
|
2021-01-31 12:38:20 +03:00
|
|
|
If you are looking for a platform name not on this list, please select Other and type in
|
|
|
|
your own name. A logo will not be provided.
|
|
|
|
</p>
|
|
|
|
|
2021-02-15 09:20:25 +03:00
|
|
|
<div className="formfield-container">
|
|
|
|
<div className="label-side">
|
|
|
|
<span className="formfield-label">Social Platform</span>
|
|
|
|
</div>
|
|
|
|
<div className="input-side">
|
|
|
|
<Select
|
|
|
|
style={{ width: 240 }}
|
|
|
|
className="social-dropdown"
|
|
|
|
placeholder="Social platform..."
|
|
|
|
defaultValue={inititalSelected}
|
|
|
|
value={inititalSelected}
|
|
|
|
onSelect={handleSelected}
|
|
|
|
>
|
|
|
|
{iconList.map(item => {
|
|
|
|
const { platform, icon, key } = item;
|
2021-03-26 06:06:29 +03:00
|
|
|
|
2021-02-15 09:20:25 +03:00
|
|
|
return (
|
|
|
|
<Select.Option className="social-option" key={`platform-${key}`} value={key}>
|
|
|
|
<span className="option-icon">
|
2022-10-19 09:35:36 +03:00
|
|
|
<img src={icon} alt="" className="option-icon" />
|
2021-02-15 09:20:25 +03:00
|
|
|
</span>
|
|
|
|
<span className="option-label">{platform}</span>
|
|
|
|
</Select.Option>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
<Select.Option
|
|
|
|
className="social-option"
|
|
|
|
key={`platform-${OTHER_SOCIAL_HANDLE_OPTION}`}
|
|
|
|
value={OTHER_SOCIAL_HANDLE_OPTION}
|
|
|
|
>
|
|
|
|
Other...
|
2021-01-19 21:34:06 +03:00
|
|
|
</Select.Option>
|
2021-02-15 09:20:25 +03:00
|
|
|
</Select>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-01-19 21:34:06 +03:00
|
|
|
</div>
|
|
|
|
);
|
2022-09-07 10:00:28 +03:00
|
|
|
};
|