-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
480 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/// <reference path="../pb_data/types.d.ts" /> | ||
migrate((app) => { | ||
const collection = new Collection({ | ||
"createRule": null, | ||
"deleteRule": null, | ||
"fields": [ | ||
{ | ||
"autogeneratePattern": "[a-z0-9]{15}", | ||
"hidden": false, | ||
"id": "text3208210256", | ||
"max": 15, | ||
"min": 15, | ||
"name": "id", | ||
"pattern": "^[a-z0-9]+$", | ||
"presentable": false, | ||
"primaryKey": true, | ||
"required": true, | ||
"system": true, | ||
"type": "text" | ||
}, | ||
{ | ||
"hidden": false, | ||
"id": "bool4087400498", | ||
"name": "enable", | ||
"presentable": false, | ||
"required": false, | ||
"system": false, | ||
"type": "bool" | ||
}, | ||
{ | ||
"autogeneratePattern": "", | ||
"hidden": false, | ||
"id": "text1579384326", | ||
"max": 0, | ||
"min": 0, | ||
"name": "name", | ||
"pattern": "", | ||
"presentable": false, | ||
"primaryKey": false, | ||
"required": false, | ||
"system": false, | ||
"type": "text" | ||
}, | ||
{ | ||
"hidden": false, | ||
"id": "autodate2990389176", | ||
"name": "created", | ||
"onCreate": true, | ||
"onUpdate": false, | ||
"presentable": false, | ||
"system": false, | ||
"type": "autodate" | ||
}, | ||
{ | ||
"hidden": false, | ||
"id": "autodate3332085495", | ||
"name": "updated", | ||
"onCreate": true, | ||
"onUpdate": true, | ||
"presentable": false, | ||
"system": false, | ||
"type": "autodate" | ||
} | ||
], | ||
"id": "pbc_728725186", | ||
"indexes": [], | ||
"listRule": null, | ||
"name": "feature_flags", | ||
"system": false, | ||
"type": "base", | ||
"updateRule": null, | ||
"viewRule": null | ||
}); | ||
|
||
return app.save(collection); | ||
}, (app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_728725186"); | ||
|
||
return app.delete(collection); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/// <reference path="../pb_data/types.d.ts" /> | ||
migrate((app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_728725186") | ||
|
||
// add field | ||
collection.fields.addAt(3, new Field({ | ||
"autogeneratePattern": "", | ||
"hidden": false, | ||
"id": "text1843675174", | ||
"max": 0, | ||
"min": 0, | ||
"name": "description", | ||
"pattern": "", | ||
"presentable": false, | ||
"primaryKey": false, | ||
"required": false, | ||
"system": false, | ||
"type": "text" | ||
})) | ||
|
||
// update field | ||
collection.fields.addAt(1, new Field({ | ||
"hidden": false, | ||
"id": "bool4087400498", | ||
"name": "enabled", | ||
"presentable": false, | ||
"required": false, | ||
"system": false, | ||
"type": "bool" | ||
})) | ||
|
||
return app.save(collection) | ||
}, (app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_728725186") | ||
|
||
// remove field | ||
collection.fields.removeById("text1843675174") | ||
|
||
// update field | ||
collection.fields.addAt(1, new Field({ | ||
"hidden": false, | ||
"id": "bool4087400498", | ||
"name": "enable", | ||
"presentable": false, | ||
"required": false, | ||
"system": false, | ||
"type": "bool" | ||
})) | ||
|
||
return app.save(collection) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/// <reference path="../pb_data/types.d.ts" /> | ||
migrate((app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_728725186") | ||
|
||
// update collection data | ||
unmarshal({ | ||
"listRule": "" | ||
}, collection) | ||
|
||
return app.save(collection) | ||
}, (app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_728725186") | ||
|
||
// update collection data | ||
unmarshal({ | ||
"listRule": null | ||
}, collection) | ||
|
||
return app.save(collection) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
"use client" | ||
|
||
import React, { createContext, useContext, ReactNode, useEffect, useState } from 'react'; | ||
import { FeatureFlag, loadFeatureFlags, defaultFeatureFlags } from '@/pocketbase/featureFlags'; | ||
|
||
const FeatureFlagsContext = createContext<FeatureFlag | undefined>(undefined); | ||
|
||
interface FeatureFlagsProviderProps { | ||
children: ReactNode; | ||
initialFlags?: FeatureFlag; | ||
} | ||
|
||
export const FeatureFlagsProvider: React.FC<FeatureFlagsProviderProps> = ({ | ||
children, | ||
initialFlags, | ||
}) => { | ||
const [flags, setFlags] = useState<FeatureFlag>(initialFlags || defaultFeatureFlags); | ||
|
||
useEffect(() => { | ||
if (!initialFlags) { | ||
const loadFlags = async () => { | ||
try { | ||
const loadedFlags = await loadFeatureFlags(); | ||
setFlags(loadedFlags); | ||
} catch (error) { | ||
console.error('Failed to load feature flags:', error); | ||
} | ||
}; | ||
|
||
loadFlags(); | ||
} | ||
}, [initialFlags]); | ||
|
||
return ( | ||
<FeatureFlagsContext.Provider value={flags}> | ||
{children} | ||
</FeatureFlagsContext.Provider> | ||
); | ||
}; | ||
|
||
// Utility hook to check a specific feature flag | ||
export const useFeatureFlag = (flagName: keyof FeatureFlag): boolean => { | ||
const context = useContext(FeatureFlagsContext); | ||
if (context === undefined) { | ||
throw new Error('useFeatureFlags must be used within a FeatureFlagsProvider'); | ||
} | ||
return context[flagName]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
'use client'; | ||
|
||
import { createContext, useContext, ReactNode, useState } from 'react'; | ||
|
||
interface SearchItemAttributes { | ||
bean_type: string; | ||
origin: string; | ||
packaging_type: string; | ||
processing_method: string; | ||
roast_level: string; | ||
variety: string; | ||
} | ||
|
||
export interface SearchItem { | ||
id: number; | ||
name: string; | ||
description: string; | ||
price: number; | ||
quantity: number; | ||
rating: number; | ||
imageUrl: string; | ||
attributes: SearchItemAttributes; | ||
tags: string[]; | ||
} | ||
|
||
interface SearchContextType { | ||
searchItems: SearchItem[]; | ||
setSearchItems: (items: SearchItem[]) => void; | ||
selectedItem: SearchItem | null; | ||
setSelectedItem: (item: SearchItem | null) => void; | ||
isLoading: boolean; | ||
setIsLoading: (loading: boolean) => void; | ||
} | ||
|
||
const SearchContext = createContext<SearchContextType | undefined>(undefined); | ||
|
||
export function SearchProvider({ children }: { children: ReactNode }) { | ||
const [searchItems, setSearchItems] = useState<SearchItem[]>([]); | ||
const [selectedItem, setSelectedItem] = useState<SearchItem | null>(null); | ||
const [isLoading, setIsLoading] = useState(false); | ||
|
||
return ( | ||
<SearchContext.Provider | ||
value={{ | ||
searchItems, | ||
setSearchItems, | ||
selectedItem, | ||
setSelectedItem, | ||
isLoading, | ||
setIsLoading, | ||
}} | ||
> | ||
{children} | ||
</SearchContext.Provider> | ||
); | ||
} | ||
|
||
export function useSearch() { | ||
const context = useContext(SearchContext); | ||
if (context === undefined) { | ||
throw new Error('useSearch must be used within a SearchProvider'); | ||
} | ||
return context; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.