1
0
mirror of https://github.com/uetchy/namae.git synced 2025-07-01 22:10:04 +09:00

38 lines
989 B
TypeScript
Raw Normal View History

2020-08-31 08:41:53 +09:00
import React from 'react';
import { useTranslation } from 'react-i18next';
import { FaSlack } from 'react-icons/fa';
2019-08-06 00:45:18 +09:00
2020-08-31 08:41:53 +09:00
import { Card, DedicatedAvailability, Repeater } from '../core';
2019-07-31 13:11:00 +09:00
2020-08-20 00:57:33 +09:00
const SlackCard: React.FC<{ query: string }> = ({ query }) => {
2020-08-31 08:41:53 +09:00
const { t } = useTranslation();
2020-06-11 22:00:16 +09:00
2020-08-31 08:41:53 +09:00
const sanitizedQuery = query
.replace(/[^0-9a-zA-Z_-]/g, '')
.replace(/_/g, '-');
const lowerCase = sanitizedQuery.toLowerCase();
2019-07-31 13:11:00 +09:00
2020-08-31 08:41:53 +09:00
const names = [lowerCase];
2019-08-06 00:45:18 +09:00
2019-07-31 13:11:00 +09:00
return (
2019-08-06 00:45:18 +09:00
<Card title={t('providers.slack')}>
<Repeater items={names}>
{(name) => (
<DedicatedAvailability
name={name}
service="slack"
2019-08-07 22:25:51 +09:00
message="Create Slack Team"
link="https://slack.com/create"
messageIfTaken={`Go to ${name}.slack.com`}
linkIfTaken={`https://${name}.slack.com`}
2019-08-06 00:45:18 +09:00
suffix=".slack.com"
icon={<FaSlack />}
/>
)}
</Repeater>
2019-07-31 13:11:00 +09:00
</Card>
2020-08-31 08:41:53 +09:00
);
};
2019-09-01 01:28:24 +09:00
2020-08-31 08:41:53 +09:00
export default SlackCard;