2021-01-24 10:22:28 +01:00
|
|
|
import React from 'react';
|
2021-01-31 10:38:20 +01:00
|
|
|
import { Select } from 'antd';
|
2021-02-07 04:38:58 +01:00
|
|
|
import { SocialHandleDropdownItem } from '../../types/config-section';
|
|
|
|
import { NEXT_PUBLIC_API_HOST } from '../../utils/apis';
|
|
|
|
import { OTHER_SOCIAL_HANDLE_OPTION } from '../../utils/config-constants';
|
2021-01-19 19:34:06 +01:00
|
|
|
|
|
|
|
interface DropdownProps {
|
2021-01-24 05:16:01 +01:00
|
|
|
iconList: SocialHandleDropdownItem[];
|
2021-01-24 10:22:28 +01:00
|
|
|
selectedOption: string;
|
|
|
|
onSelected: any;
|
2021-01-19 19:34:06 +01:00
|
|
|
}
|
|
|
|
|
2021-01-24 10:22:28 +01:00
|
|
|
export default function SocialDropdown({ iconList, selectedOption, onSelected }: DropdownProps) {
|
2021-02-04 17:04:00 +01:00
|
|
|
const handleSelected = (value: string) => {
|
2021-01-24 10:22:28 +01:00
|
|
|
if (onSelected) {
|
|
|
|
onSelected(value);
|
|
|
|
}
|
2021-01-19 19:34:06 +01:00
|
|
|
};
|
2021-01-24 10:22:28 +01:00
|
|
|
const inititalSelected = selectedOption === '' ? null : selectedOption;
|
2021-01-19 19:34:06 +01:00
|
|
|
return (
|
|
|
|
<div className="social-dropdown-container">
|
2021-02-13 08:55:59 +01:00
|
|
|
<p className="description">
|
2021-01-31 10:38:20 +01: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 07:20:25 +01: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-07-09 20:42:01 +02:00
|
|
|
const iconUrl = `${NEXT_PUBLIC_API_HOST}${icon.slice(1)}`;
|
2021-03-26 04:06:29 +01:00
|
|
|
|
2021-02-15 07:20:25 +01:00
|
|
|
return (
|
|
|
|
<Select.Option className="social-option" key={`platform-${key}`} value={key}>
|
|
|
|
<span className="option-icon">
|
2021-03-26 04:06:29 +01:00
|
|
|
<img src={iconUrl} alt="" className="option-icon" />
|
2021-02-15 07:20:25 +01: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 19:34:06 +01:00
|
|
|
</Select.Option>
|
2021-02-15 07:20:25 +01:00
|
|
|
</Select>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-01-19 19:34:06 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|