feat: add userType filter on fetch list
This commit is contained in:
parent
a6ad08ce84
commit
776600c19b
1 changed files with 16 additions and 7 deletions
|
|
@ -15,7 +15,7 @@ import axios from 'axios';
|
||||||
import useBranchStore from '../branch';
|
import useBranchStore from '../branch';
|
||||||
import { Branch } from '../branch/types';
|
import { Branch } from '../branch/types';
|
||||||
|
|
||||||
const branchStore = useBranchStore()
|
const branchStore = useBranchStore();
|
||||||
|
|
||||||
const useUserStore = defineStore('api-user', () => {
|
const useUserStore = defineStore('api-user', () => {
|
||||||
const userOption = ref<UserOption>({
|
const userOption = ref<UserOption>({
|
||||||
|
|
@ -34,10 +34,15 @@ const useUserStore = defineStore('api-user', () => {
|
||||||
],
|
],
|
||||||
responsibleAreaOpts: [
|
responsibleAreaOpts: [
|
||||||
{ label: 'เขตพื้นที่ 1 บางรัก ปทุมวัน ยานนาวสาทร และบางคอแหลม' },
|
{ label: 'เขตพื้นที่ 1 บางรัก ปทุมวัน ยานนาวสาทร และบางคอแหลม' },
|
||||||
{ label: 'เขตพื้นที่ 2 จอมทอง ทุ่งครุ บางขุนเทียน บางบอน และราษฎร์บูรณะ' },
|
{
|
||||||
|
label: 'เขตพื้นที่ 2 จอมทอง ทุ่งครุ บางขุนเทียน บางบอน และราษฎร์บูรณะ',
|
||||||
|
},
|
||||||
{ label: 'เขตพื้นที่ 3 คลองเตย บางนา ประเวศ พระโขนง วัฒนา และสวนหลวง' },
|
{ label: 'เขตพื้นที่ 3 คลองเตย บางนา ประเวศ พระโขนง วัฒนา และสวนหลวง' },
|
||||||
{ label: 'เขตพื้นที่ 4 คันนายาว บางกะปิ ลาดพร้าว บึงกุ่ม และวังทางหลาง' },
|
{ label: 'เขตพื้นที่ 4 คันนายาว บางกะปิ ลาดพร้าว บึงกุ่ม และวังทางหลาง' },
|
||||||
{ label: 'เขตพื้นที่ 5 คลองสามวา มีนบุรี ลาดกระบัง สะพานสูง หนองจอก และสายไหม' },
|
{
|
||||||
|
label:
|
||||||
|
'เขตพื้นที่ 5 คลองสามวา มีนบุรี ลาดกระบัง สะพานสูง หนองจอก และสายไหม',
|
||||||
|
},
|
||||||
{ label: 'เขตพื้นที่ 6 คลองสาน ธนบุรี บางกอกน้อย บางกอกใหญ่ และบางพลัด' },
|
{ label: 'เขตพื้นที่ 6 คลองสาน ธนบุรี บางกอกน้อย บางกอกใหญ่ และบางพลัด' },
|
||||||
{ label: 'เขตพื้นที่ 7 ตลิ่งชัน ทวีวัฒนา บางแค ภาษีเจริญ และหนองแขม' },
|
{ label: 'เขตพื้นที่ 7 ตลิ่งชัน ทวีวัฒนา บางแค ภาษีเจริญ และหนองแขม' },
|
||||||
{ label: 'เขตพื้นที่ 8 ดุสิต พระนครป้อมปราบศัตรูพ่าย และสัมพันธวงศ์' },
|
{ label: 'เขตพื้นที่ 8 ดุสิต พระนครป้อมปราบศัตรูพ่าย และสัมพันธวงศ์' },
|
||||||
|
|
@ -70,13 +75,16 @@ const useUserStore = defineStore('api-user', () => {
|
||||||
|
|
||||||
const ageDate = new Date(diff);
|
const ageDate = new Date(diff);
|
||||||
const years = ageDate.getUTCFullYear() - 1970;
|
const years = ageDate.getUTCFullYear() - 1970;
|
||||||
const result = `${years} ปี`
|
const result = `${years} ปี`;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchHqOption() {
|
async function fetchHqOption() {
|
||||||
if (userOption.value.hqOpts.length === 0) {
|
if (userOption.value.hqOpts.length === 0) {
|
||||||
const res = await branchStore.fetchList({ pageSize: 999, filter: 'head' });
|
const res = await branchStore.fetchList({
|
||||||
|
pageSize: 999,
|
||||||
|
filter: 'head',
|
||||||
|
});
|
||||||
if (res) {
|
if (res) {
|
||||||
res.result.map((item) => {
|
res.result.map((item) => {
|
||||||
userOption.value.hqOpts.push({
|
userOption.value.hqOpts.push({
|
||||||
|
|
@ -88,7 +96,6 @@ const useUserStore = defineStore('api-user', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function fetchBrOption(id: string) {
|
async function fetchBrOption(id: string) {
|
||||||
const res = await branchStore.fetchById(id, {
|
const res = await branchStore.fetchById(id, {
|
||||||
includeSubBranch: true,
|
includeSubBranch: true,
|
||||||
|
|
@ -229,6 +236,7 @@ const useUserStore = defineStore('api-user', () => {
|
||||||
zipCode?: string;
|
zipCode?: string;
|
||||||
query?: string;
|
query?: string;
|
||||||
includeBranch?: boolean;
|
includeBranch?: boolean;
|
||||||
|
userType?: string;
|
||||||
},
|
},
|
||||||
flow?: {
|
flow?: {
|
||||||
sessionId: string;
|
sessionId: string;
|
||||||
|
|
@ -245,6 +253,7 @@ const useUserStore = defineStore('api-user', () => {
|
||||||
if (opts?.zipCode) params.append('zipCode', opts.zipCode);
|
if (opts?.zipCode) params.append('zipCode', opts.zipCode);
|
||||||
if (opts?.query) params.append('query', opts.query);
|
if (opts?.query) params.append('query', opts.query);
|
||||||
if (opts?.includeBranch) params.append('includeBranch', 'true');
|
if (opts?.includeBranch) params.append('includeBranch', 'true');
|
||||||
|
if (opts?.userType) params.append('userType', opts.userType);
|
||||||
|
|
||||||
const query = params.toString();
|
const query = params.toString();
|
||||||
|
|
||||||
|
|
@ -332,7 +341,7 @@ const useUserStore = defineStore('api-user', () => {
|
||||||
transactionId: string;
|
transactionId: string;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const { profileImage, ...payload } = data
|
const { profileImage, ...payload } = data;
|
||||||
const res = await api.put<User & { profileImageUploadUrl: string }>(
|
const res = await api.put<User & { profileImageUploadUrl: string }>(
|
||||||
`/user/${id}`,
|
`/user/${id}`,
|
||||||
payload,
|
payload,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue