Skip to content

Commit

Permalink
hotfix: check completion status, add tag and line validate
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnsonMao committed Nov 11, 2024
1 parent 22e4d0a commit 32c5b60
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions components/Group/Form/Fields/TagsField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function TagsField({ name, helperText, control, value = [] }) {
const handleChange = (e) => {
const _value = e.target.value;
if (_value.length > 8) setError('標籤最多 8 個字');
else if (value.includes(_value)) setError('請勿重複輸入');
else setError('');
setInput(_value);
};
Expand Down
2 changes: 2 additions & 0 deletions components/Group/Form/Form.styled.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export const StyledLabel = styled(InputLabel)`
`;

export const StyledGroup = styled.div`
width: 100%;
& + & {
margin-top: 20px;
}
Expand Down
11 changes: 6 additions & 5 deletions components/Profile/Edit/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
import { MobileDatePicker } from '@mui/x-date-pickers/MobileDatePicker';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import InputTags from '../InputTags';
import ErrorMessage from './ErrorMessage';

import TheAvator from './TheAvator';
Expand All @@ -49,6 +48,7 @@ import {
StyledButtonGroup,
StyledButton,
} from './Edit.styled';
import Fields from '@/components/Group/Form/Fields';

function EditPage() {
const mobileScreen = useMediaQuery('(max-width: 767px)');
Expand Down Expand Up @@ -453,11 +453,12 @@ function EditPage() {
</StyledGroup>
<StyledGroup>
<Typography sx={{ fontWeight: 500 }}>標籤</Typography>
<InputTags
ref={(element) => setRef('tagList', element)}
<Fields.TagsField
name="tagList"
value={userState.tagList}
change={(value) => {
onChangeHandler({ key: 'tagList', value, isMultiple: true });
control={{
setRef: (name, element) => setRef(name, element),
onChange: ({ target }) => onChangeHandler({ key: target.name, value: target.value })
}}
/>
<Typography
Expand Down
6 changes: 3 additions & 3 deletions components/Profile/Edit/useEditProfile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const initialState = {
tagList: [],
selfIntroduction: '',
share: '',
isOpenLocation: false,
isOpenProfile: false,
isOpenLocation: true,
isOpenProfile: true,
isLoadingSubmit: false,
country: '',
city: '',
Expand Down Expand Up @@ -72,7 +72,7 @@ const schema = z.object({
),
line: buildValidator(
20,
/^($|[a-zA-Z0-9_.]{6,20})$/,
/^($|[a-zA-Z0-9_.]{3,20})$/,
'長度最多20個字元',
'長度最少6個字元,支援英文、數字、底線、句號',
),
Expand Down
1 change: 1 addition & 0 deletions redux/reducers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const reducer = (state = initialState, action) => {
...state,
...action.payload,
apiState: 'Resolve',
isComplete: checkIsComplete(action.payload),
};
}
case 'UPDATE_USER_PROFILE_API_STATE_RESET': {
Expand Down

0 comments on commit 32c5b60

Please sign in to comment.