Spaces:
Sleeping
Sleeping
| // import { create } from 'zustand'; | |
| // interface StoreState { | |
| // fvInfos: object | null; | |
| // ownUrl: string; | |
| // ownImage: string | null; | |
| // ownImageBase64: string | null; | |
| // ownImageName: string; | |
| // competitionUrls: string[]; | |
| // absentImage: string | null; | |
| // mainRadio: string; | |
| // submittedSecondRadio: 'url' | 'upload'; | |
| // submittedOwnUrl: string; | |
| // submittedOwnImage: string | null; | |
| // setSubmittedSecondRadio: (val: 'url' | 'upload') => void; | |
| // setSubmittedOwnUrl: (url: string) => void; | |
| // setSubmittedOwnImage: (img: string | null) => void; | |
| // setFvInfos: (infos: object | null) => void; | |
| // setMainRadio: (val: string) => void; | |
| // setAbsentImage: (img: string | null) => void; | |
| // setOwnUrl: (url: string) => void; | |
| // setOwnImage: (image: string | null) => void; | |
| // setOwnImageBase64: (image: string | null) => void; | |
| // setOwnImageName: (name: string) => void; | |
| // setCompetitionUrls: (urls: string[]) => void; | |
| // } | |
| // export const useInputStore = create<StoreState>((set) => ({ | |
| // fvInfos: null, | |
| // ownUrl: '', | |
| // ownImage: null, | |
| // absentImage: null, | |
| // ownImageBase64: null, | |
| // ownImageName: '', | |
| // competitionUrls: [], | |
| // mainRadio: 'exist', | |
| // submittedSecondRadio: 'url', | |
| // submittedOwnUrl: '', | |
| // submittedOwnImage: null, | |
| // setSubmittedSecondRadio: (val) => set({ submittedSecondRadio: val }), | |
| // setSubmittedOwnUrl: (url) => set({ submittedOwnUrl: url }), | |
| // setSubmittedOwnImage: (img) => set({ submittedOwnImage: img }), | |
| // setFvInfos: (infos) => set({ fvInfos: infos }), | |
| // setMainRadio: (radio) => set({ mainRadio: radio }), | |
| // setAbsentImage: (img) => set({ absentImage: img }), | |
| // setOwnUrl: (url: string) => set(() => ({ ownUrl: url })), | |
| // setOwnImage: (img) => set({ ownImage: img }), | |
| // setOwnImageBase64: (image: string | null) => set(() => ({ ownImageBase64: image })), | |
| // setOwnImageName: (name) => set({ ownImageName: name }), | |
| // setCompetitionUrls: (urls: string[]) => set(() => ({ competitionUrls: urls })), | |
| // })); | |
| import { create } from 'zustand'; | |
| interface SectionVisibility { | |
| [key: string]: { | |
| visible: boolean; | |
| order: number; | |
| }; | |
| } | |
| interface InputFormData { | |
| ownUrl: string; | |
| urlText: string[]; | |
| ownImage: string; | |
| ownImageName: string; | |
| user_email: string; | |
| } | |
| interface StoreState { | |
| ownUrl: string; | |
| competitionUrls: string[]; | |
| purpose: string; | |
| fvInfos: Record<string, unknown> | null; | |
| cnInfo: Record<string, unknown> | null; | |
| scoreDict: object | null; | |
| inputFormData: InputFormData | null; | |
| ownImage: string | null; | |
| ownImageBase64: string | null; | |
| ownImageName: string; | |
| absentImage: string | null; | |
| mainRadio: string; | |
| submittedSecondRadio: 'url' | 'upload'; | |
| submittedOwnUrl: string; | |
| submittedOwnImage: string | null; | |
| ownFile: File | null; | |
| // 最終的に選択されたモーメント(改善案生成APIに送信される実際のデータ) | |
| selectedMoments: string[]; | |
| // refresh-moments画面の状態管理 | |
| refreshMomentsDefaultMoments: { text: string; value: boolean }[]; // デフォルトの方向性選択肢 | |
| refreshMomentsCheckedMoments: Record<string, boolean>; // AI提案モーメントのチェック状態(UI表示用) | |
| refreshMomentsFreeInputs: { text: string; value: boolean }[]; // フリー入力の選択肢 | |
| // セクション管理の状態(タブごとに保存) | |
| sectionVisibilities: Record<string, SectionVisibility>; | |
| // 画像バリデーションエラー(check_url APIレスポンス後に設定される) | |
| checkUrlFvErrors: string[]; | |
| setOwnFile: (ownFile: File | null) => void; | |
| setSubmittedSecondRadio: (val: 'url' | 'upload') => void; | |
| setSubmittedOwnUrl: (url: string) => void; | |
| setSubmittedOwnImage: (img: string | null) => void; | |
| setFvInfos: (infos: Record<string, unknown> | null) => void; | |
| setCnInfo: (infos: Record<string, unknown> | null) => void; | |
| setScoreDict: (dict: object | null) => void; | |
| setInputFormData: (data: InputFormData | null) => void; | |
| setPurpose: (purpose: string) => void; | |
| setMainRadio: (val: string) => void; | |
| setAbsentImage: (img: string | null) => void; | |
| setOwnUrl: (url: string) => void; | |
| setOwnImage: (image: string | null) => void; | |
| setOwnImageBase64: (image: string | null) => void; | |
| setOwnImageName: (name: string) => void; | |
| setCompetitionUrls: (urls: string[]) => void; | |
| setSelectedMoments: (selectedMoments: string[]) => void; | |
| // refresh-moments画面の状態管理メソッド | |
| setRefreshMomentsDefaultMoments: (moments: { text: string; value: boolean }[]) => void; | |
| setRefreshMomentsCheckedMoments: (moments: Record<string, boolean>) => void; | |
| setRefreshMomentsFreeInputs: (inputs: { text: string; value: boolean }[]) => void; | |
| // セクション管理メソッド | |
| setSectionVisibility: (tabName: string, visibility: SectionVisibility) => void; | |
| getSectionVisibility: (tabName: string) => SectionVisibility | undefined; | |
| // 画像バリデーションエラー管理メソッド | |
| setCheckUrlFvErrors: (errors: string[]) => void; | |
| } | |
| export const useInputStore = create<StoreState>((set, get) => ({ | |
| ownUrl: '', | |
| competitionUrls: [], | |
| purpose: '', | |
| fvInfos: null, | |
| cnInfo: null, | |
| scoreDict: null, | |
| inputFormData: null, | |
| ownImage: null, | |
| ownImageBase64: null, | |
| ownImageName: '', | |
| absentImage: null, | |
| mainRadio: 'exist', | |
| submittedSecondRadio: 'url', | |
| submittedOwnUrl: '', | |
| submittedOwnImage: null, | |
| ownFile: null, | |
| selectedMoments: [], | |
| // refresh-moments画面の初期状態 | |
| refreshMomentsDefaultMoments: [ | |
| { | |
| text: '購買前(まだ商品について詳しくないが、商品の情報収集を実施している状態)', | |
| value: false, | |
| }, | |
| { | |
| text: '比較検討中(他社と比較をして迷い、決め手を探している状態)', | |
| value: false, | |
| }, | |
| { | |
| text: '購買検討中(ある程度購入意欲は高いが、最後の決め手を探してる)', | |
| value: false, | |
| }, | |
| ], | |
| refreshMomentsCheckedMoments: {}, | |
| refreshMomentsFreeInputs: [ | |
| { text: '', value: false }, | |
| { text: '', value: false }, | |
| { text: '', value: false }, | |
| ], | |
| // セクション管理の初期状態 | |
| sectionVisibilities: {}, | |
| // 画像バリデーションエラーの初期状態 | |
| checkUrlFvErrors: [], | |
| setOwnFile: (ownFile) => set({ ownFile }), | |
| setSubmittedSecondRadio: (val) => set({ submittedSecondRadio: val }), | |
| setSubmittedOwnUrl: (url) => set({ submittedOwnUrl: url }), | |
| setSubmittedOwnImage: (img) => set({ submittedOwnImage: img }), | |
| setFvInfos: (infos) => set({ fvInfos: infos }), | |
| setCnInfo: (infos) => set({ cnInfo: infos }), | |
| setScoreDict: (dict) => set({ scoreDict: dict }), | |
| setInputFormData: (data) => set({ inputFormData: data }), | |
| setPurpose: (purpose) => set({ purpose }), | |
| setMainRadio: (radio) => set({ mainRadio: radio }), | |
| setAbsentImage: (img) => set({ absentImage: img }), | |
| setOwnUrl: (url: string) => set(() => ({ ownUrl: url })), | |
| setOwnImage: (img) => set({ ownImage: img }), | |
| setOwnImageBase64: (image: string | null) => set(() => ({ ownImageBase64: image })), | |
| setOwnImageName: (name) => set({ ownImageName: name }), | |
| setCompetitionUrls: (urls: string[]) => set(() => ({ competitionUrls: urls })), | |
| setSelectedMoments: (selectedMoments) => set({ selectedMoments }), | |
| // refresh-moments画面の状態管理メソッド | |
| setRefreshMomentsDefaultMoments: (moments) => set({ refreshMomentsDefaultMoments: moments }), | |
| setRefreshMomentsCheckedMoments: (moments) => set({ refreshMomentsCheckedMoments: moments }), | |
| setRefreshMomentsFreeInputs: (inputs) => set({ refreshMomentsFreeInputs: inputs }), | |
| // セクション管理メソッド | |
| setSectionVisibility: (tabName, visibility) => | |
| set((state) => ({ | |
| sectionVisibilities: { | |
| ...state.sectionVisibilities, | |
| [tabName]: visibility, | |
| }, | |
| })), | |
| getSectionVisibility: (tabName: string) => { | |
| return get().sectionVisibilities[tabName]; | |
| }, | |
| // 画像バリデーションエラー管理メソッド | |
| setCheckUrlFvErrors: (errors: string[]) => set({ checkUrlFvErrors: errors }), | |
| })); | |