Skip to content

Commit

Permalink
feat: Renamed file to sampleFile
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayur committed Nov 16, 2024
1 parent a9fc92c commit 72976bd
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions apps/widget/src/components/Common/Container/Container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function Container({ children }: PropsWithChildren<{}>) {
setSecondaryPayload({
accessToken: data.value.accessToken,
host: data.value.host,
file: data.value.file,
sampleFile: data.value.sampleFile,
projectId: data.value.projectId,
uuid: data.value.uuid,
extra: isObject(data.value.extra) ? JSON.stringify(data.value.extra) : data.value.extra,
Expand Down Expand Up @@ -340,7 +340,7 @@ export function Container({ children }: PropsWithChildren<{}>) {
authHeaderValue={secondaryPayload?.authHeaderValue}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
primaryColor={secondaryPayload.primaryColor!}
file={secondaryPayload?.file}
sampleFile={secondaryPayload?.sampleFile}
>
{children}
</Provider>
Expand Down
6 changes: 3 additions & 3 deletions apps/widget/src/components/Common/Provider/Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface IProviderProps {
texts: typeof WIDGET_TEXTS;
primaryColor: string;
output?: string;
file?: File | Blob;
sampleFile?: File | Blob;
schema?: string;
data?: string;
host: string;
Expand All @@ -32,7 +32,7 @@ export function Provider(props: PropsWithChildren<IProviderProps>) {
api,
data,
title,
file,
sampleFile,
texts,
output,
projectId,
Expand Down Expand Up @@ -60,7 +60,7 @@ export function Provider(props: PropsWithChildren<IProviderProps>) {
host={host}
data={data}
title={title}
file={file}
sampleFile={sampleFile}
texts={texts}
output={output}
schema={schema}
Expand Down
4 changes: 2 additions & 2 deletions apps/widget/src/hooks/Phase0/usePhase0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function usePhase0({ goNext }: IUsePhase0Props) {
const { api } = useAPIState();
const { projectId, templateId } = useImplerState();
const [fileError, setFileError] = useState<string | null>(null);
const { schema, setImportConfig, showWidget, setFlow, file } = useAppState();
const { schema, setImportConfig, showWidget, setFlow, sampleFile } = useAppState();

const { mutate: fetchImportConfig } = useMutation<IImportConfig, IErrorObject, void>(
['importConfig', projectId, templateId],
Expand All @@ -34,7 +34,7 @@ export function usePhase0({ goNext }: IUsePhase0Props) {
FileMimeTypesEnum.EXCELX,
];

if (file && !isValidFileType(file as Blob)) {
if (sampleFile && !isValidFileType(sampleFile as Blob)) {
setFileError(`Only ${allowedTypes.join(',')} are supported`);
} else {
goNext();
Expand Down
8 changes: 4 additions & 4 deletions apps/widget/src/hooks/Phase1/usePhase1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function usePhase1({ goNext, texts, onManuallyEnterData }: IUsePhase1Prop
const { templateId, authHeaderValue, extra } = useImplerState();
const [excelSheetNames, setExcelSheetNames] = useState<string[]>([]);
const [isDownloadInProgress, setIsDownloadInProgress] = useState<boolean>(false);
const { setUploadInfo, setTemplateInfo, output, schema, data, importId, imageSchema, file } = useAppState();
const { setUploadInfo, setTemplateInfo, output, schema, data, importId, imageSchema, sampleFile } = useAppState();

const selectedTemplateId = watch('templateId');

Expand Down Expand Up @@ -108,10 +108,10 @@ export function usePhase1({ goNext, texts, onManuallyEnterData }: IUsePhase1Prop
}
};
const onDownloadClick = async () => {
if (file) {
const fileName = (file as File).name;
if (sampleFile) {
const fileName = (sampleFile as File).name;
const fileBaseName = fileName.split('.')[0];
downloadFile(file as Blob, fileBaseName);
downloadFile(sampleFile as Blob, fileBaseName);
}

setIsDownloadInProgress(true);
Expand Down
4 changes: 2 additions & 2 deletions apps/widget/src/store/app.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const AppContextProvider = ({
title,
texts,
data,
file,
sampleFile,
schema,
output,
host,
Expand Down Expand Up @@ -67,7 +67,7 @@ const AppContextProvider = ({
uploadInfo,
setImportId,
imageSchema,
file,
sampleFile,
templateInfo,
importConfig,
primaryColor,
Expand Down
2 changes: 1 addition & 1 deletion apps/widget/src/types/store.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export interface IAppStore {
schema?: string;
output?: string;
flow: FlowsEnum;
file?: File | Blob;
sampleFile?: File | Blob;
showWidget: boolean;
importConfig: IImportConfig;
setFlow: (flow: FlowsEnum) => void;
Expand Down
2 changes: 1 addition & 1 deletion libs/shared/src/types/widget/widget.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface ICommonShowPayload {
primaryColor?: string;
colorScheme?: string;
title?: string;
file?: File | Blob;
sampleFile?: File | Blob;
projectId: string;
accessToken: string;
uuid: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export interface IShowWidgetProps {
projectId: string;
templateId: string;
accessToken: string;
file?: File | Blob;
sampleFile?: File | Blob;
texts?: CustomTexts;
title?: string;
primaryColor?: string;
Expand Down
6 changes: 3 additions & 3 deletions packages/react/src/hooks/useImpler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ export function useImpler({
const showWidget = async ({
colorScheme,
data,
file,
sampleFile,
schema,
output,
}: Pick<IShowWidgetProps, 'colorScheme' | 'data' | 'schema' | 'output' | 'file'> = {}) => {
}: Pick<IShowWidgetProps, 'colorScheme' | 'data' | 'schema' | 'output' | 'sampleFile'> = {}) => {
if (window.impler && isImplerInitiated) {
const payload: IShowWidgetProps & { uuid: string; host: string } = {
uuid,
Expand All @@ -92,7 +92,7 @@ export function useImpler({
accessToken,
schema,
data,
file,
sampleFile,
output,
title,
extra,
Expand Down

0 comments on commit 72976bd

Please sign in to comment.