-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Move brand store components into publisher (#4986)
- Loading branch information
Showing
104 changed files
with
185 additions
and
162 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,24 @@ | ||
import { useQuery } from "react-query"; | ||
|
||
function useBrand(id: string | undefined) { | ||
return useQuery({ | ||
queryKey: ["brand", id], | ||
queryFn: async () => { | ||
const response = await fetch(`/api/store/${id}/brand`); | ||
|
||
if (!response.ok) { | ||
throw new Error("There was a problem fetching models"); | ||
} | ||
|
||
const brandData = await response.json(); | ||
|
||
if (!brandData.success) { | ||
throw new Error(brandData.message); | ||
} | ||
|
||
return brandData.data; | ||
}, | ||
}); | ||
} | ||
|
||
export default useBrand; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,28 @@ | ||
import { useQuery, UseQueryResult } from "react-query"; | ||
import type { Model as ModelType } from "../types/shared"; | ||
|
||
const useModels = ( | ||
brandId: string | undefined, | ||
): UseQueryResult<ModelType[], Error> => { | ||
return useQuery<ModelType[], Error>({ | ||
queryKey: ["models", brandId], | ||
queryFn: async () => { | ||
const response = await fetch(`/api/store/${brandId}/models`); | ||
|
||
if (!response.ok) { | ||
throw new Error("There was a problem fetching models"); | ||
} | ||
|
||
const modelsData = await response.json(); | ||
|
||
if (!modelsData.success) { | ||
throw new Error(modelsData.message); | ||
} | ||
|
||
return modelsData.data; | ||
}, | ||
enabled: !!brandId, | ||
}); | ||
}; | ||
|
||
export default useModels; |
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,31 @@ | ||
import { useQuery } from "react-query"; | ||
import type { Policy } from "../types/shared"; | ||
import { UsePoliciesResponse, ApiError } from "../types/interfaces"; | ||
|
||
function usePolicies( | ||
brandId: string | undefined, | ||
modelId: string | undefined, | ||
): UsePoliciesResponse { | ||
return useQuery<Policy[], ApiError>({ | ||
queryKey: ["policies", brandId], | ||
queryFn: async () => { | ||
const response = await fetch( | ||
`/api/store/${brandId}/models/${modelId}/policies`, | ||
); | ||
|
||
if (!response.ok) { | ||
throw new Error("There was a problem fetching policies"); | ||
} | ||
|
||
const policiesData = await response.json(); | ||
|
||
if (!policiesData.success) { | ||
throw new Error(policiesData.message); | ||
} | ||
|
||
return policiesData.data; | ||
}, | ||
}); | ||
} | ||
|
||
export default usePolicies; |
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,19 @@ | ||
import { useQuery } from "react-query"; | ||
|
||
function usePublisher() { | ||
return useQuery("publisher", async () => { | ||
const response = await fetch("/account.json"); | ||
|
||
if (!response.ok) { | ||
return { | ||
publisher: null, | ||
}; | ||
} | ||
|
||
const publisherData = await response.json(); | ||
|
||
return publisherData; | ||
}); | ||
} | ||
|
||
export default usePublisher; |
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,27 @@ | ||
import { useQuery, UseQueryResult } from "react-query"; | ||
import type { SigningKey } from "../types/shared"; | ||
|
||
const useSigningKeys = ( | ||
brandId: string | undefined, | ||
): UseQueryResult<SigningKey[], Error> => { | ||
return useQuery<SigningKey[], Error>({ | ||
queryKey: ["signingKeys", brandId], | ||
queryFn: async () => { | ||
const response = await fetch(`/api/store/${brandId}/signing-keys`); | ||
|
||
if (!response.ok) { | ||
throw new Error("There was a problem fetching signing keys"); | ||
} | ||
|
||
const signingKeysData = await response.json(); | ||
|
||
if (!signingKeysData.success) { | ||
throw new Error(signingKeysData.message); | ||
} | ||
|
||
return signingKeysData.data; | ||
}, | ||
}); | ||
}; | ||
|
||
export default useSigningKeys; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,13 @@ | ||
import type { Policy } from "../types/shared"; | ||
|
||
export interface UsePoliciesResponse { | ||
isLoading: boolean; | ||
isError: boolean; | ||
error: unknown; | ||
refetch: () => void; | ||
data: Policy[] | undefined; | ||
} | ||
|
||
export interface ApiError { | ||
message: string; | ||
} |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...-store/utils/checkModelNameExists.test.ts → ...ls/__tests__/checkModelNameExists.test.ts
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
2 changes: 1 addition & 1 deletion
2
...store/utils/checkSigningKeyExists.test.ts → ...s/__tests__/checkSigningKeyExists.test.ts
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
2 changes: 1 addition & 1 deletion
2
...s/brand-store/utils/isClosedPanel.test.ts → ...her/utils/__tests__/isClosedPanel.test.ts
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
2 changes: 1 addition & 1 deletion
2
...c/js/brand-store/utils/maskString.test.ts → ...lisher/utils/__tests__/maskString.test.ts
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
2 changes: 1 addition & 1 deletion
2
...-store/utils/sortByDateDescending.test.ts → ...ls/__tests__/sortByDateDescending.test.ts
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.