11import { useContext , useEffect } from "react" ;
2- import _ from "lodash" ;
32import { ProjectsIntro } from "../styles/Projects.styled" ;
43import { Cmd , CmdDesc , CmdList , HelpWrapper } from "../styles/Help.styled" ;
54import {
65 checkRedirect ,
76 generateTabs ,
87 getCurrentCmdArry ,
8+ isArgInvalid ,
99} from "../../utils/funcs" ;
10- import { UsageDiv } from "../styles/Output.styled" ;
1110import { termContext } from "../Terminal" ;
11+ import Usage from "../Usage" ;
1212
1313const Socials : React . FC = ( ) => {
1414 const { arg, history, rerender } = useContext ( termContext ) ;
@@ -26,23 +26,13 @@ const Socials: React.FC = () => {
2626 } , [ arg , rerender , currentCommand ] ) ;
2727
2828 /* ===== check arg is valid ===== */
29- const checkArg = ( a : string [ ] ) => {
30- if (
31- a [ 0 ] !== "go" ||
32- ! _ . includes ( [ 1 , 2 , 3 , 4 ] , parseInt ( a [ 1 ] ) ) ||
33- arg . length > 2
34- )
35- return (
36- < UsageDiv data-testid = "socials-invalid-arg" >
37- Usage: socials go <social-no> < br />
38- eg: socials go 1
39- </ UsageDiv >
40- ) ;
41- return null ;
42- } ;
29+ const checkArg = ( ) =>
30+ isArgInvalid ( arg , "go" , [ "1" , "2" , "3" , "4" ] ) ? (
31+ < Usage cmd = "socials" />
32+ ) : null ;
4333
4434 return arg . length > 0 || arg . length > 2 ? (
45- checkArg ( arg )
35+ checkArg ( )
4636 ) : (
4737 < HelpWrapper data-testid = "socials" >
4838 < ProjectsIntro > Here are my social links</ ProjectsIntro >
@@ -53,10 +43,7 @@ const Socials: React.FC = () => {
5343 < CmdDesc > - { url } </ CmdDesc >
5444 </ CmdList >
5545 ) ) }
56- < UsageDiv marginY >
57- Usage: socials go <social-id> < br />
58- eg: socials go 1
59- </ UsageDiv >
46+ < Usage cmd = "socials" marginY />
6047 </ HelpWrapper >
6148 ) ;
6249} ;
0 commit comments