Skip to content

Commit

Permalink
Merge pull request #295 from cp-20:feat/suggest-already-implemented-g…
Browse files Browse the repository at this point in the history
…ame-system

フィードバック内で既に対応しているゲームシステムに対して警告を出すように
  • Loading branch information
cp-20 authored Feb 15, 2025
2 parents 569e3ca + 18a657e commit 5a6d8fd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { Input } from '@/shared/components/ui/input';
import { Label } from '@/shared/components/ui/label';
import { useToast } from '@/shared/components/ui/use-toast';
import { sendGameSystemRequest } from '@/shared/lib/webhook';
import { DialogDescription } from '@radix-ui/react-dialog';
import { IconMessageReply } from '@tabler/icons-react';
import { t } from 'i18next';
import { useState, type FC } from 'react';
Expand All @@ -23,6 +22,15 @@ export const GameSystemRequest: FC = () => {
const [open, setOpen] = useState(false);
const [system, setSystem] = useState('');
const [logFile, setLogFile] = useState<File | null>(null);
const [errorMessage, setErrorMessage] = useState<string | null>(null);

const validate = (value: string) => {
if (/(CoC|||)/.test(value)) {
setErrorMessage(t('analyze-logs:game-system-request:already-implemented'));
} else {
setErrorMessage(null);
}
};

const submitHandler = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
Expand Down Expand Up @@ -63,9 +71,13 @@ export const GameSystemRequest: FC = () => {
<Input
id="request-form-name"
value={system}
onChange={(e) => setSystem(e.currentTarget.value)}
onChange={(e) => {
setSystem(e.currentTarget.value);
validate(e.currentTarget.value);
}}
required
/>
{errorMessage && <div className="text-red-500 text-sm">{errorMessage}</div>}
</div>
<div className="space-y-1">
<Label htmlFor="request-form-logs">{t('analyze-logs:game-system-request:logs')}</Label>
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export const en = {
submitted: 'Request submitted!',
'submitted-description': 'Thank you for your request!',
error: 'Failed to submit request',
'already-implemented': 'This game system has already been implemented.',
},
upload: {
button: 'Click to upload or drag and drop to upload',
Expand Down
1 change: 1 addition & 0 deletions src/locales/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export const ja = {
submitted: 'リクエストを送信しました!',
'submitted-description': 'リクエストありがとうございます!',
error: 'リクエストの送信に失敗しました',
'already-implemented': 'このゲームシステムは今すぐ使えます',
},
upload: {
button: 'クリックしてアップロード、あるいはドラッグアンドドロップしてアップロード',
Expand Down

0 comments on commit 5a6d8fd

Please sign in to comment.