Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix (profile/partner section): Modify the items related to areas and … #41

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions components/Partner/PartnerList/PartnerCard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Box } from '@mui/material';
import {
WANT_TO_DO_WITH_PARTNER,
ROLE,
EDUCATION_STEP,
EDUCATION_STAGE,
} from '@/constants/member';
import moment from 'moment';
import { mapToTable } from '@/utils/helper';
Expand All @@ -25,7 +25,7 @@ import {

const WANT_TO_DO_WITH_PARTNER_TABLE = mapToTable(WANT_TO_DO_WITH_PARTNER);
const ROLELIST = mapToTable(ROLE);
const EDUCATION_STEP_TABLE = mapToTable(EDUCATION_STEP);
const EDUCATION_STAGE_TABLE = mapToTable(EDUCATION_STAGE);

function PartnerCard({
image,
Expand All @@ -43,7 +43,7 @@ function PartnerCard({
.join('、');

const role = roleList.length > 0 && ROLELIST[roleList[0]];
const edu = educationStage && EDUCATION_STEP_TABLE[educationStage];
const edu = educationStage && EDUCATION_STAGE_TABLE[educationStage];
const locations = location && location.split('@');

return (
Expand Down Expand Up @@ -72,7 +72,10 @@ function PartnerCard({
<LocationOnOutlinedIcon sx={{ marginRight: '10px' }} />
{location
? location.length >= 2
? locations.join('').replace('台灣', '')
? locations
.join('')
.replace('台灣', '')
.replace('null', '')
: locations.join('')
: '-'}
</>
Expand Down
7 changes: 6 additions & 1 deletion components/Partner/SearchField/SelectedAreas.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Select from '@/shared/components/Select';
import { AREAS } from '@/constants/areas';
import { TAIWAN_DISTRICT } from '@/constants/areas';
import useSearchParamsManager from '@/hooks/useSearchParamsManager';

export default function SelectedAreas() {
Expand All @@ -10,6 +10,11 @@ export default function SelectedAreas() {
pushState(QUERY_KEY, value.toString());
};

const AREAS = TAIWAN_DISTRICT.map(({ name }) => ({
name,
label: name,
})).concat([{ name: '國外', label: '國外' }]);

return (
<Select
multiple
Expand Down
4 changes: 2 additions & 2 deletions components/Partner/SearchField/SelectedEducationStep.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Select from '@/shared/components/Select';
import { EDUCATION_STEP } from '@/constants/member';
import { EDUCATION_STAGE } from '@/constants/member';
import useSearchParamsManager from '@/hooks/useSearchParamsManager';

export default function SelectedEducationStep() {
Expand All @@ -15,7 +15,7 @@ export default function SelectedEducationStep() {
multiple
value={getSearchParams(QUERY_KEY)}
onChange={handleChange}
items={EDUCATION_STEP}
items={EDUCATION_STAGE}
itemLabel="label"
itemValue="label"
renderValue={(selected) =>
Expand Down
7 changes: 6 additions & 1 deletion components/Partner/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useMemo } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { Box, Button } from '@mui/material';
import useMediaQuery from '@mui/material/useMediaQuery';
import { AREAS } from '@/constants/areas';
import { TAIWAN_DISTRICT } from '@/constants/areas';
import { fetchPartners } from '@/redux/actions/partners';
import { EDUCATION_STEP, ROLE } from '@/constants/member';
import { SEARCH_TAGS } from '@/constants/category';
Expand Down Expand Up @@ -36,6 +36,11 @@ const createObjFromArrary = (arr, keyProp = 'label', valueProp = 'label') => {
);
};

const AREAS = TAIWAN_DISTRICT.map(({ name }) => ({
name,
label: name,
})).concat([{ name: '國外', label: '國外' }]);

// constants
const keySelections = {
area: _map(AREAS, 'name'),
Expand Down
9 changes: 4 additions & 5 deletions components/Profile/Edit/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import toast from 'react-hot-toast';
import useMediaQuery from '@mui/material/useMediaQuery';
import { useRouter } from 'next/router';
import { useSelector } from 'react-redux';
import { TAIWAN_DISTRICT } from '@/constants/areas';
import COUNTIES from '@/constants/countries.json';
import { TAIWAN_DISTRICT, COUNTRIES } from '@/constants/areas';

import {
GENDER,
Expand Down Expand Up @@ -245,9 +244,9 @@ function EditPage() {
<MenuItem disabled value="-1">
<em>請選擇居住地</em>
</MenuItem>
{COUNTIES.map(({ name, alpha2 }) => (
<MenuItem key={alpha2} value={name}>
{name}
{COUNTRIES.map(({ name, label }) => (
<MenuItem key={name} value={name}>
{label}
</MenuItem>
))}
</Select>
Expand Down
3 changes: 2 additions & 1 deletion components/Profile/InputTags/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const Tag = ({ label, onCancel }) => {

const StyledTagsField = styled(TextField)`
input {
padding-left: 0;
padding-left: ${({ hasData }) => (hasData ? '0' : '16px')};
}
`;

Expand All @@ -53,6 +53,7 @@ function InputTags({ value = [], change }) {
};
return (
<StyledTagsField
hasData={value.length > 0}
fullWidth="true"
placeholder="搜尋或新增標籤"
onKeyDown={keyDownHandle}
Expand Down
7 changes: 4 additions & 3 deletions components/Profile/UserCard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ function UserCard({
updatedDate,
}) {
const router = useRouter();
const locations = location && location.split('@');

return (
<StyledProfileWrapper>
Expand Down Expand Up @@ -226,9 +227,9 @@ function UserCard({
<StyledProfileLocation>
<LocationOnOutlinedIcon sx={{ marginRight: '10px' }} />{' '}
{location
? location.split('@').length >= 2
? location.split('@').join('').replace('台灣', '')
: location.split('@').join('')
? location.length >= 2
? locations.join('').replace('台灣', '').replace('null', '')
: locations.join('')
: '-'}
</StyledProfileLocation>
</Box>
Expand Down
6 changes: 3 additions & 3 deletions components/Profile/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
import {
WANT_TO_DO_WITH_PARTNER,
ROLE,
EDUCATION_STEP,
EDUCATION_STAGE,
} from '@/constants/member';
import { mapToTable } from '@/utils/helper';
import SEOConfig from '@/shared/components/SEO';
Expand All @@ -29,7 +29,7 @@ const BottonBack = {
};
const WANT_TO_DO_WITH_PARTNER_TABLE = mapToTable(WANT_TO_DO_WITH_PARTNER);
const ROLELIST = mapToTable(ROLE);
const EDUCATION_STEP_TABLE = mapToTable(EDUCATION_STEP);
const EDUCATION_STAGE_TABLE = mapToTable(EDUCATION_STAGE);

const Profile = ({
name,
Expand All @@ -51,7 +51,7 @@ const Profile = ({
}) => {
const router = useRouter();
const role = roleList.length > 0 && ROLELIST[roleList[0]];
const edu = educationStage && EDUCATION_STEP_TABLE[educationStage];
const edu = educationStage && EDUCATION_STAGE_TABLE[educationStage];
const wantTodo = wantToDoList
.map((item) => WANT_TO_DO_WITH_PARTNER_TABLE[item])
.join('、');
Expand Down
5 changes: 5 additions & 0 deletions constants/areas.js
Original file line number Diff line number Diff line change
Expand Up @@ -1643,3 +1643,8 @@ export const TAIWAN_DISTRICT = [
name: '花蓮縣',
},
];

export const COUNTRIES = [
{ name: '國外', label: '國外' },
{ name: '台灣', label: '台灣' },
];
37 changes: 3 additions & 34 deletions constants/member.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,40 +106,9 @@ export const EDUCATION_STEP = [
},
];

export const EDUCATION_STAGE = [
{
label: '學齡前',
value: 'preschool',
},
{
label: '國小低年級',
value: 'elementary-junior',
},
{
label: '國小中年級',
value: 'elementary-middle',
},
{
label: '國小高年級',
value: 'elementary-senior',
},
{
label: '國中',
value: 'junior-high',
},
{
label: '高中',
value: 'high',
},
{
label: '大學',
value: 'university',
},
{
label: '大學以上',
value: 'other',
},
];
export const EDUCATION_STAGE = EDUCATION_STEP.filter(
(step) => step.key !== 'master' && step.key !== 'doctor',
);

export const WANT_TO_DO_WITH_PARTNER = [
{
Expand Down
Loading