Revert "Allow joining clipboards with 4-6 character codes"
Browse filesThis reverts commit d0dbbbad8f737927d9c9d93deb420df94b7e1407.
apps/frontend/src/components/JoinClipboardCard.tsx
CHANGED
|
@@ -33,14 +33,14 @@ export default function JoinClipboardCard() {
|
|
| 33 |
setRoomCode(lastCode);
|
| 34 |
|
| 35 |
// Check if it's valid
|
| 36 |
-
const isValid = lastCode.length
|
| 37 |
setIsComplete(isValid);
|
| 38 |
}
|
| 39 |
}, [savedClipboards]);
|
| 40 |
|
| 41 |
-
// Validate room code format (
|
| 42 |
const isValidRoomCode = (code: string): boolean => {
|
| 43 |
-
const roomCodeRegex = /^[A-Z0-9]{4
|
| 44 |
return roomCodeRegex.test(code);
|
| 45 |
};
|
| 46 |
|
|
@@ -105,7 +105,7 @@ export default function JoinClipboardCard() {
|
|
| 105 |
</div>
|
| 106 |
|
| 107 |
<p className="text-text-secondary mb-6 pl-1">
|
| 108 |
-
Enter a 4-
|
| 109 |
</p>
|
| 110 |
|
| 111 |
<form onSubmit={handleJoinClipboard} className="space-y-4">
|
|
@@ -121,34 +121,29 @@ export default function JoinClipboardCard() {
|
|
| 121 |
onPaste={(e) => {
|
| 122 |
e.preventDefault()
|
| 123 |
const pastedValue = e.clipboardData?.getData('text') || '';
|
| 124 |
-
const filteredValue = pastedValue
|
| 125 |
-
|
| 126 |
-
.toUpperCase()
|
| 127 |
-
.slice(0, 6);
|
| 128 |
-
|
| 129 |
-
if (filteredValue.length >= 4 && filteredValue.length <= 6) {
|
| 130 |
setRoomCode(filteredValue);
|
| 131 |
-
setIsComplete(isValidRoomCode(filteredValue));
|
| 132 |
}
|
| 133 |
}}
|
| 134 |
value={roomCode}
|
| 135 |
placeholder={lastVisitedClipboard}
|
| 136 |
onChange={(value: string) => {
|
| 137 |
// Convert to uppercase automatically
|
| 138 |
-
const uppercaseValue = value.toUpperCase()
|
| 139 |
setRoomCode(uppercaseValue);
|
| 140 |
setClipboardExists(true);
|
| 141 |
-
const isValid = uppercaseValue.length
|
| 142 |
setIsComplete(isValid)
|
| 143 |
}}
|
| 144 |
-
numInputs={
|
| 145 |
renderInput={(props, index) => (
|
| 146 |
<input
|
| 147 |
{...props}
|
| 148 |
className={`w-full h-full text-center text-xl sm:text-2xl font-mono font-bold
|
| 149 |
border-2 rounded-lg shadow-none outline-none
|
| 150 |
transition-colors duration-200 ease-in-out
|
| 151 |
-
${roomCode.length
|
| 152 |
? 'border-green-500 text-green-500 bg-green-500/5'
|
| 153 |
: props.value
|
| 154 |
? 'border-secondary text-text-primary bg-surface/80'
|
|
@@ -192,7 +187,7 @@ export default function JoinClipboardCard() {
|
|
| 192 |
onSelectClipboard={(code) => {
|
| 193 |
setRoomCode(code);
|
| 194 |
setClipboardExists(true);
|
| 195 |
-
setIsComplete(
|
| 196 |
// Don't automatically join - just fill the input
|
| 197 |
// This allows users to see the code before joining
|
| 198 |
}}
|
|
|
|
| 33 |
setRoomCode(lastCode);
|
| 34 |
|
| 35 |
// Check if it's valid
|
| 36 |
+
const isValid = lastCode.length === 4 && isValidRoomCode(lastCode);
|
| 37 |
setIsComplete(isValid);
|
| 38 |
}
|
| 39 |
}, [savedClipboards]);
|
| 40 |
|
| 41 |
+
// Validate room code format (6 alphanumeric characters, uppercase)
|
| 42 |
const isValidRoomCode = (code: string): boolean => {
|
| 43 |
+
const roomCodeRegex = /^[A-Z0-9]{4}$/;
|
| 44 |
return roomCodeRegex.test(code);
|
| 45 |
};
|
| 46 |
|
|
|
|
| 105 |
</div>
|
| 106 |
|
| 107 |
<p className="text-text-secondary mb-6 pl-1">
|
| 108 |
+
Enter a 4-character code to join an existing clipboard.
|
| 109 |
</p>
|
| 110 |
|
| 111 |
<form onSubmit={handleJoinClipboard} className="space-y-4">
|
|
|
|
| 121 |
onPaste={(e) => {
|
| 122 |
e.preventDefault()
|
| 123 |
const pastedValue = e.clipboardData?.getData('text') || '';
|
| 124 |
+
const filteredValue = pastedValue.replace(/[^a-zA-Z0-9]/g, '').toUpperCase();
|
| 125 |
+
if (filteredValue.length === 4) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
setRoomCode(filteredValue);
|
|
|
|
| 127 |
}
|
| 128 |
}}
|
| 129 |
value={roomCode}
|
| 130 |
placeholder={lastVisitedClipboard}
|
| 131 |
onChange={(value: string) => {
|
| 132 |
// Convert to uppercase automatically
|
| 133 |
+
const uppercaseValue = value.toUpperCase();
|
| 134 |
setRoomCode(uppercaseValue);
|
| 135 |
setClipboardExists(true);
|
| 136 |
+
const isValid = uppercaseValue.length === 4 && isValidRoomCode(uppercaseValue);
|
| 137 |
setIsComplete(isValid)
|
| 138 |
}}
|
| 139 |
+
numInputs={4}
|
| 140 |
renderInput={(props, index) => (
|
| 141 |
<input
|
| 142 |
{...props}
|
| 143 |
className={`w-full h-full text-center text-xl sm:text-2xl font-mono font-bold
|
| 144 |
border-2 rounded-lg shadow-none outline-none
|
| 145 |
transition-colors duration-200 ease-in-out
|
| 146 |
+
${roomCode.length === 4 && isComplete
|
| 147 |
? 'border-green-500 text-green-500 bg-green-500/5'
|
| 148 |
: props.value
|
| 149 |
? 'border-secondary text-text-primary bg-surface/80'
|
|
|
|
| 187 |
onSelectClipboard={(code) => {
|
| 188 |
setRoomCode(code);
|
| 189 |
setClipboardExists(true);
|
| 190 |
+
setIsComplete(true);
|
| 191 |
// Don't automatically join - just fill the input
|
| 192 |
// This allows users to see the code before joining
|
| 193 |
}}
|